Knowledge Graphs
Connect decisions, code, and documentation in a queryable graph. Understand how your project's knowledge is interconnected.
What are Knowledge Graphs?
Knowledge graphs represent information as nodes (entities) connected by edges (relationships). In ContextStream, knowledge graphs help you:
Track Dependencies
See how decisions affect other parts of your system
Connect Context
Link related memories, code, and documentation
Trace Impact
Understand what changes when you modify something
Discover Insights
Find non-obvious connections in your knowledge base
Creating Knowledge Nodes
Create a node representing a piece of knowledge:
curl -X POST https://api.contextstream.io/api/v1/memory/nodes \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"workspace_id": "your-workspace-id",
"category": "decision",
"summary": "Use PostgreSQL for primary database",
"details": "Chose PostgreSQL over MySQL for better JSON support and advanced features.",
"tags": ["database", "architecture"],
"confidence": 0.95
}'Connecting Nodes
Create relationships between nodes:
curl -X POST https://api.contextstream.io/api/v1/graph/knowledge/edges \
-H "Authorization: Bearer YOUR_API_KEY" \
-d '{
"workspace_id": "your-workspace-id",
"source_node_id": "node-postgres-decision",
"target_node_id": "node-schema-design",
"relation_type": "influences",
"weight": 0.9,
"context": "Database choice affects schema capabilities"
}'Common relation types:
influencesdepends_onsupersedesrelated_toimplementsQuerying the Graph
Find related knowledge nodes:
curl -X POST https://api.contextstream.io/api/v1/graph/knowledge/related \
-H "Authorization: Bearer YOUR_API_KEY" \
-d '{
"workspace_id": "your-workspace-id",
"node_id": "node-postgres-decision",
"max_depth": 2,
"relation_types": ["influences", "depends_on"]
}'Get all decisions in a workspace:
curl https://api.contextstream.io/api/v1/graph/knowledge/decisions?workspace_id=your-workspace-id \
-H "Authorization: Bearer YOUR_API_KEY"Impact Analysis
Understand what's affected when you change something:
curl -X POST https://api.contextstream.io/api/v1/graph/impact-analysis \
-H "Authorization: Bearer YOUR_API_KEY" \
-d '{
"workspace_id": "your-workspace-id",
"node_id": "node-auth-system",
"change_type": "modify"
}'Returns a list of nodes that could be impacted by changes to the specified node, along with confidence scores and the relationship paths.