Skip to content

Note Graph View API #280

@ElioNeto

Description

@ElioNeto

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

  1. Start with the target note as root node
  2. 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
  3. Apply filters (tag, path prefix, max nodes)
  4. 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

  • Graph endpoint returns valid D3.js-compatible JSON
  • Depth parameter controls traversal correctly
  • Circular links do not cause infinite loops
  • Tag filtering works (only show notes with specific tag)
  • Non-existent notes return 404
  • Unit tests for graph assembly logic
  • Integration test with REST API

Parent Epic

#275

Metadata

Metadata

Assignees

No one assigned

    Labels

    apifeatnotesNote storage and indexingobsidianObsidian-like note-taking features

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions