Knowledge Graph
An interactive, AI-agent-built knowledge graph explorer. Renders nodes and edges as an SVG force-directed graph with draggable nodes, zoom controls, search/filter, minimap, detail panel, and real-time agent activity logging.
Preview
Interactive AI system knowledge graph with 18 nodes and 20 edges. Click nodes, drag to reposition, scroll to zoom.
Graph construction complete: 18 nodes, 20 edges
7:41:25 AM
Added evaluation and feedback loops
7:41:15 AM
Connected planning module to agent orchestration
7:41:05 AM
Added AI Agent and tool execution capabilities
7:40:50 AM
Identified hallucination risk and linked mitigations
7:40:35 AM
Added vector database and embedding infrastructure
7:40:20 AM
Connected RAG Pipeline -> LLM (augments)
7:40:10 AM
Added "RAG Pipeline" as concept node
7:39:55 AM
Added "Large Language Model" as model node
7:39:45 AM
Started knowledge graph construction
7:39:30 AM
Agent Building Animation
Watch the AI agent build a graph node by node in real time. Click the button to start.
Agent ready. Click "Start Building" to begin.
7:41:30 AM
Hierarchical Layout
Nodes arranged in layers by type for a structured, top-down view.
Radial Layout
Nodes arranged in a circle, useful for seeing all connections at a glance.
Props
KnowledgeGraph component API reference
| Prop | Type | Default | Description |
|---|---|---|---|
nodes | GraphNode[] | [] | Array of graph nodes to display |
edges | GraphEdge[] | [] | Array of edges connecting nodes |
isAgentBuilding | boolean | false | Whether to show the agent building animation and pulse effects |
agentLog | AgentLogEntry[] | [] | Activity log entries from the AI agent |
layout | 'force-directed' | 'hierarchical' | 'radial' | 'force-directed' | Layout algorithm for node positioning |
onNodeSelect | (node: GraphNode | null) => void | — | Callback when a node is selected or deselected |
onLayoutChange | (layout: LayoutMode) => void | — | Callback when layout mode changes via toolbar |
showMinimap | boolean | true | Show the minimap overview in the bottom-right corner |
showLegend | boolean | true | Show the node type legend in the bottom-left corner |
showAgentLog | boolean | true | Show the agent activity log side panel |
height | number | string | 600 | Height of the graph visualization area |
className | string | — | Additional CSS classes for the root container |
GraphNode Type
Structure for individual graph nodes
interface GraphNode { id: string // Unique identifier label: string // Display label type: NodeType // 'concept' | 'entity' | 'action' | 'data' | 'model' | 'risk' description?: string // Shown in detail panel metadata?: Record<string, string> // Key-value pairs group?: string // Optional grouping}GraphEdge Type
Structure for graph edges
interface GraphEdge { id: string // Unique identifier source: string // Source node ID target: string // Target node ID label?: string // Relationship label (e.g., "depends on") weight?: number // Affects layout attraction strength}AgentLogEntry Type
Structure for agent activity log entries
interface AgentLogEntry { timestamp: Date message: string type: 'add-node' | 'add-edge' | 'remove' | 'update' | 'info'}Usage
Import and implementation example
import { KnowledgeGraph, type GraphNode, type GraphEdge } from '@/blocks/agentic/knowledge-graph'
const nodes: GraphNode[] = [ { id: 'a', label: 'Machine Learning', type: 'concept', description: 'Core ML concepts' }, { id: 'b', label: 'Training Data', type: 'data' }, { id: 'c', label: 'Neural Network', type: 'model' }, { id: 'd', label: 'Bias Risk', type: 'risk' },]
const edges: GraphEdge[] = [ { id: 'e1', source: 'b', target: 'a', label: 'feeds' }, { id: 'e2', source: 'a', target: 'c', label: 'trains' }, { id: 'e3', source: 'd', target: 'b', label: 'originates from' },]
export default function Example() { return ( <KnowledgeGraph nodes={nodes} edges={edges} isAgentBuilding={false} layout="force-directed" onNodeSelect={(node) => console.log('Selected:', node)} height={500} /> )}Built With
3 componentsThis block uses the following UI components from the design system:
Features
Built-in functionality
- Force-directed layout: Physics-based simulation with node repulsion and edge attraction for organic graph layouts
- Three layout modes: Force-directed, hierarchical (layered by type), and radial (circular) layouts
- Draggable nodes: Click and drag any node to reposition it; simulation pauses during drag
- Node detail panel: Click a node to view its description, connections, and metadata in a side panel
- Agent building animation: Pulse effects, floating particles, and activity log when the AI is constructing the graph
- Zoom and pan: Scroll to zoom, drag background to pan, plus zoom controls and fit-to-view button
- Minimap: Overview minimap in the corner showing the full graph and current viewport
- Search and filter: Search nodes by name, filter by type, or click legend items to isolate categories
- Typed nodes: Six node types (concept, entity, action, data, model, risk) each with distinct colors and icons
- Labeled edges: Edges display relationship labels and curve for clarity
- Agent activity log: Chronological log of all agent actions: nodes added, edges created, updates
- Dark mode support: Full dark mode styling for all graph elements and UI controls
Accessibility
Accessibility considerations
ARIA Attributes
Interactive elements are keyboard-focusableNode selection state conveyed visually through selection ring and dimmingAgent building status announced through Badge textKeyboard Navigation
| Key | Action |
|---|---|
| Tab | Navigate between toolbar controls |
| Enter / Space | Activate buttons, toggle layout, select filters |
| Escape | Clear search or deselect node (when focused) |
Notes
- SVG graph nodes use pointer events for interaction; consider adding keyboard navigation for full accessibility
- Minimap is decorative and does not require keyboard access
- Filter and search controls provide text-based alternatives to visual graph exploration
- Consider adding aria-live regions for agent activity log updates