Context Engineering includes a built-in interactive graph visualization powered by Cytoscape.js, a battle-tested graph visualization library used in biological research, drug discovery, and network analysis. The visualization shows how your organizational knowledge is connected - ADRs, Failures, Meetings, and Snapshots reference each other, forming a knowledge graph that helps you understand relationships and dependencies.
- Battle-tested: Used by major research institutions and pharmaceutical companies
- Performance: Handles thousands of nodes efficiently
- Layouts: Multiple algorithms (force-directed, circular, grid, hierarchical)
- Extensible: Rich ecosystem of plugins and extensions
- Well-documented: Extensive API documentation and examples
- Active development: Regular updates and community support
The easiest way to visualize your knowledge graph:
# Start the server
mix phx.server
# Open browser to:
http://localhost:4000/graphOr use the Mix task to auto-open:
mix context.graph --webGet graph statistics without starting the web server:
mix context.graphOutput:
Knowledge Graph Statistics:
---------------------------
Total Nodes: 42
- ADRs: 15
- Failures: 18
- Meetings: 7
- Snapshots: 2
Total Edges: 67
Relationship Types:
- references: 67
Most Referenced Items:
- ADR-001: Use PostgreSQL (12 references)
- FAIL-023: DB timeout (8 references)
Each knowledge item is a node in the graph:
-
ADR (Blue, Box) - Architecture Decision Records
- Size increases with reference count
- Shows which decisions are most influential
-
Failure (Red, Diamond) - Incident/Outage records
- Highlights what went wrong
- Links to related ADRs and meetings
-
Meeting (Green, Ellipse) - Meeting notes and decisions
- Connects discussions to actions
- References ADRs and failures discussed
-
Snapshot (Orange, Triangle) - Git commit snapshots
- Shows code state at specific points
- Links to relevant decisions
Edges represent references between items:
- "references" - One item explicitly mentions another
- Example: FAIL-023 mentions "see ADR-001"
- Auto-detected from content (ADR-\d+, FAIL-\d+, etc.)
- Strength indicates relevance (default: 1.0)
When you create content with IDs like:
This failure occurred because we didn't follow ADR-001.
See also FAIL-023 and MEET-005 for context.
The system automatically creates edges:
- Current item -> ADR-001
- Current item -> FAIL-023
- Current item -> MEET-005
Located at the top of the visualization:
- Include Archived Items - Show/hide archived nodes
- Max Nodes - Limit displayed nodes (10-5000)
- Refresh Graph - Reload with current settings
- Fit to Screen - Reset zoom and center view
Choose different layout algorithms from the dropdown:
- Force-Directed (CoSE) - Physics-based simulation (default)
- Circle - Nodes arranged in a circle
- Grid - Nodes in a regular grid
- Concentric - Circular rings by reference count
- Click node - View details in info panel (bottom-right)
- Drag node - Reposition manually (temporary)
- Scroll - Zoom in/out
- Drag background - Pan around
- Hover node - Highlight with thicker border
- Click background - Deselect and hide info panel
Color key shown in top-right corner:
- Blue = ADR
- Red = Failure
- Green = Meeting
- Orange = Snapshot
Export the entire graph as JSON:
mix context.graph --export graph.jsonInclude archived items:
mix context.graph --export graph.json --include-archivedLimit node count:
mix context.graph --export graph.json --max-nodes 500{
"nodes": [
{
"id": "ADR-001",
"type": "adr",
"title": "Use PostgreSQL for persistence",
"status": "active",
"tags": ["database", "postgresql"],
"created_date": "2024-01-15",
"reference_count": 12
},
{
"id": "FAIL-023",
"type": "failure",
"title": "Database connection timeout",
"severity": "high",
"status": "resolved",
"tags": ["database", "performance"],
"created_date": "2024-02-01",
"reference_count": 8
}
],
"edges": [
{
"from": "FAIL-023",
"from_type": "failure",
"to": "ADR-001",
"to_type": "adr",
"type": "references",
"strength": 1.0
}
]
}curl http://localhost:4000/api/graph/exportWith query parameters:
curl "http://localhost:4000/api/graph/export?max_nodes=100&include_archived=false"Response: JSON with nodes and edges arrays
Find items connected to a specific node:
curl http://localhost:4000/api/graph/related/ADR-001?depth=2Parameters:
depth- How many hops to traverse (default: 2)- Returns all items within N relationships
Response:
{
"item_id": "ADR-001",
"related": [
{
"id": "FAIL-023",
"type": "failure",
"relationship": "references",
"strength": 1.0
}
]
}Question: "If I change this ADR, what might break?"
curl http://localhost:4000/api/graph/related/ADR-001?depth=3Shows all failures, meetings, and snapshots that reference this decision.
Question: "Why do we keep having this failure?"
Open the graph visualization and click on a failure node. Follow edges to see:
- Related ADRs (was this anticipated?)
- Related failures (is this a pattern?)
- Related meetings (was this discussed?)
Question: "Why did we make this decision?"
Click an ADR in the graph to see:
- What failures led to this decision
- Which meetings discussed it
- What snapshots show the implementation
Question: "What's not connected?"
Look for isolated nodes (no edges):
- ADRs with no failures = untested decisions
- Failures with no ADRs = undocumented incidents
- Meetings with no outcomes = unactionable discussions
Question: "What are our most important decisions?"
Look at node size - larger nodes have more references:
- These are your architectural keystones
- Changes here have wide impact
- Should be well-documented and tested
The exported JSON works with many battle-tested graph visualization tools:
If you want to customize the visualization, consider these proven alternatives:
1. Cytoscape.js (current implementation)
- Website: https://js.cytoscape.org/
- Use case: Network graphs, biological pathways, social networks
- Pros: Most flexible, excellent documentation, multiple layouts
- Best for: Production applications requiring customization
2. Sigma.js
- Website: https://www.sigmajs.org/
- Use case: Large graphs (10K+ nodes)
- Pros: WebGL rendering, excellent performance
- Best for: Very large knowledge bases
3. Apache ECharts
- Website: https://echarts.apache.org/
- Use case: Data visualization with graph components
- Pros: Charts + graphs in one library, huge community
- Best for: Dashboards combining graphs and charts
4. vis.js (Network)
- Website: https://visjs.org/
- Use case: Interactive networks and timelines
- Pros: Easy to use, good physics simulation
- Best for: Quick prototypes
Gephi (Desktop Application)
- Download: https://gephi.org/
- Industry standard for graph analysis
- Steps:
- Export graph:
mix context.graph --export graph.json - Convert to GEXF format or use JSON import plugin
- Apply layout algorithms (ForceAtlas2 recommended)
- Analyze metrics (betweenness, clustering, PageRank)
- Export high-resolution images
- Export graph:
Neo4j (Graph Database)
- Download: https://neo4j.com/
- Import the graph for Cypher queries:
// Example: Find all failures related to database decisions
MATCH (f:Failure)-[:REFERENCES]->(a:ADR)
WHERE a.tags CONTAINS 'database'
RETURN f, a
// Find shortest path between two items
MATCH path = shortestPath(
(start {id: 'ADR-001'})-[*]-(end {id: 'FAIL-023'})
)
RETURN pathGraphviz (Command-line)
- Website: https://graphviz.org/
- Convert to DOT format:
# Export graph
mix context.graph --export graph.json
# Convert JSON to DOT (custom script needed)
# Render with Graphviz
dot -Tpng graph.dot -o graph.png
neato -Tsvg graph.dot -o graph.svgUse the JSON directly in custom D3.js visualizations:
fetch('/api/graph/export')
.then(r => r.json())
.then(data => {
// data.nodes and data.edges are ready for D3
const simulation = d3.forceSimulation(data.nodes)
.force("link", d3.forceLink(data.edges).id(d => d.id))
.force("charge", d3.forceManyBody().strength(-300))
.force("center", d3.forceCenter(width / 2, height / 2));
// Render nodes and edges
// ... custom visualization code
});For graphs with 1000+ nodes:
-
Use max_nodes parameter
curl "http://localhost:4000/api/graph/export?max_nodes=500" -
Filter by type Query specific node types via API
-
Exclude archived Reduces noise from old items
-
Physics optimization The web UI disables physics after initial layout
- Each node: ~1KB
- Each edge: ~200 bytes
- 1000 nodes + 2000 edges = ~2.4MB JSON
Check if you have any data:
# Create some test data
mix context.adr --title "Test Decision" --decision "Test" --context "Test"
mix context.failure --title "Test Failure" --symptoms "Test" --root-cause "Test" --resolution "Test"Ensure you reference IDs in content:
# In ADR context field:
"This supersedes ADR-001 and addresses FAIL-042"
The system auto-detects patterns like ADR-\d+, FAIL-\d+, etc.
- Check server is running:
curl http://localhost:4000/api/graph/export - Check browser console for JavaScript errors
- Try clearing browser cache
- Verify vis.js CDN is accessible
If mix context.graph fails to start:
# Check database connection
mix ecto.migrate
# Verify app compiles
mix compile
# Check for errors
iex -S mixAlways use full IDs when referencing:
- Good: "see ADR-001"
- Bad: "see the postgres ADR"
Add context when referencing:
- "This failure was caused by incomplete implementation of ADR-001"
- "Meeting discussed alternatives mentioned in FAIL-023"
Use the graph to review your knowledge base:
- Weekly: Check for new isolated nodes
- Monthly: Identify over-referenced items needing updates
- Quarterly: Archive obsolete nodes
Use consistent tags to group related items:
- Technical:
database,api,frontend,auth - Domains:
billing,notifications,analytics - Status:
experimental,deprecated,critical
When appropriate, create bidirectional references:
- ADR-002: "This supersedes ADR-001"
- ADR-001: "Superseded by ADR-002"
This makes graph traversal more informative.
ADR-001: Use PostgreSQL
^
|
FAIL-023: Connection pool exhausted
^
|
MEET-005: Discussed scaling strategy
^
|
ADR-015: Add connection pooling
^
|
SNAP-042: Implemented connection pool
ADR-003: Use JWT tokens
^
|
FAIL-010: Token expiry issues
|
v
MEET-012: Security review
|
v
ADR-024: Add refresh tokens
|
v
FAIL-089: Refresh token leaked
|
v
ADR-031: Move to OAuth2
Potential additions to graph visualization:
- Timeline view (nodes arranged by date)
- Clustering by tags
- Path finding (shortest path between two items)
- Subgraph extraction
- Impact analysis preview
- Change history visualization
- Export to various formats (PNG, SVG, PDF)
- Collaborative annotations
- Real-time updates (WebSocket)
Remember: The knowledge graph is a living representation of your organization's memory. Keep it updated, review it regularly, and use it to guide decisions.