Note Graph View API
Build an API endpoint that assembles a graph representation of note connections (links and backlinks) for visualization in the frontend graph view.
Graph Data Structure
Return a JSON structure consumable by D3.js force layout or vis.js:
{
"nodes": [
{ "id": "note-path", "label": "Display Name", "group": "tag-group", "size": 5 }
],
"edges": [
{ "source": "from-path", "target": "to-path", "weight": 1 }
]
}
API Endpoint
GET /notes/{path}/graph?depth=1&include_tags=true
depth: Number of hops to traverse (default: 1, max: 3)
include_tags: Whether to include tag-based edges
- Returns JSON graph structure
Implementation
Use existing infrastructure:
NoteIndex::get_backlinks() and NoteIndex::get_forward_links() for edges
TagIndex::search_by_tag() for tag grouping
Engine::search_prefix("note:") to check which paths exist
Graph Assembly Algorithm
- Start with the target note as root node
- For each depth level:
- Fetch forward links and backlinks for each node at current frontier
- Add new nodes and edges to the graph
- Deduplicate by node ID
- Apply filters (tag, path prefix, max nodes)
- Return serialized JSON
Performance Requirements
- Depth-1 graph for 50 connected notes: < 50ms
- Depth-2 graph for 200 connected notes: < 200ms
- Maximum 500 nodes per response
Acceptance Criteria
Parent Epic
#275
Note Graph View API
Build an API endpoint that assembles a graph representation of note connections (links and backlinks) for visualization in the frontend graph view.
Graph Data Structure
Return a JSON structure consumable by D3.js force layout or vis.js:
{ "nodes": [ { "id": "note-path", "label": "Display Name", "group": "tag-group", "size": 5 } ], "edges": [ { "source": "from-path", "target": "to-path", "weight": 1 } ] }API Endpoint
depth: Number of hops to traverse (default: 1, max: 3)include_tags: Whether to include tag-based edgesImplementation
Use existing infrastructure:
NoteIndex::get_backlinks()andNoteIndex::get_forward_links()for edgesTagIndex::search_by_tag()for tag groupingEngine::search_prefix("note:")to check which paths existGraph Assembly Algorithm
Performance Requirements
Acceptance Criteria
Parent Epic
#275