Skip to content

feat(graph): search, filter, and fact inspector in graph explorer #197

Closed

Description

@hurttlocker

Summary

Enhance the 2D graph explorer (shipped in v0.5.0) with interactive search, filtering, and a fact inspector sidebar.

Architecture

Where code lives

  • Visualizer HTML: internal/graph/visualizer.html (1,123 lines, embedded via //go:embed)
  • Graph API: internal/graph/graph.go — serves /api/cluster endpoint returning nodes + edges JSON
  • Server: internal/graph/server.go — HTTP server on configurable port (default :8090)
  • Graph data: internal/graph/graph.go — BuildClusterGraph() queries store for facts → nodes/edges

Current state

  • 2D force-directed graph using D3.js (embedded in visualizer.html)
  • Cluster view: groups nodes by shared subject
  • Node tooltips on hover
  • 78 nodes, 85 edges at current DB size (28K facts)
  • No search, no filtering, no click-to-inspect

Key APIs the frontend can call

The graph server already serves the visualizer HTML at / and cluster data at /api/cluster. New endpoints needed:

GET /api/cluster              — existing, returns {nodes, edges}
GET /api/facts?subject=X      — NEW: return all facts for a subject
GET /api/search?q=term        — NEW: return matching nodes/facts
GET /api/facts?memory_id=N    — NEW: return facts linked to a memory

Implementation tasks

Backend (Go)

  • Add GET /api/facts?subject=X endpoint to internal/graph/server.go
    • Query store.ListFacts() filtered by subject
    • Return JSON array of facts with id, subject, predicate, object, type, confidence, source
  • Add GET /api/search?q=term endpoint
    • Use search.Engine.Search() to find matching memories
    • Return node highlights (which nodes match the query)
  • Add GET /api/facts?memory_id=N endpoint
    • Return all facts extracted from a specific memory
  • Add node metadata to cluster API response: fact_count, last_updated, source_types
  • Tests in internal/graph/graph_test.go for new endpoints

Frontend (visualizer.html)

  • Search bar (top of page): type to filter/highlight nodes
    • Debounced input (300ms), calls /api/search?q=term
    • Matching nodes get highlighted color + enlarged
    • Non-matching nodes fade to 20% opacity
    • Clear button resets view
  • Click-to-inspect sidebar (right side, 300px):
    • Click any node → sidebar slides in
    • Shows: subject name, fact count, all facts (subject-predicate-object), source memories, connected nodes
    • Facts sorted by confidence (highest first)
    • Each fact shows type badge (identity, temporal, decision, etc.)
    • Click a connected node → navigates to that node
  • Node coloring by type:
    • Determine node "type" from its most common fact type
    • Color scheme: identity=blue, temporal=orange, decision=green, preference=purple, kv=gray, relationship=red
    • Legend in bottom-left corner
  • Time filter:
    • Range slider or date picker at top
    • Filters to nodes with facts updated within the selected window
    • Default: all time. Presets: today, this week, this month
  • Edge labels on hover:
    • Show predicate text when hovering over an edge line
    • Use D3 tooltip or SVG text element

CSS/Layout

  • Sidebar: fixed right, 300px wide, white background, scrollable
  • Search bar: fixed top, full width, z-index above graph
  • Graph canvas: fills remaining space
  • Responsive: sidebar collapses to bottom on narrow screens

Acceptance criteria

  • Search highlights matching nodes in < 500ms
  • Click any node → sidebar shows its facts and connections
  • Node colors reflect primary fact type
  • Time filter correctly hides/shows nodes
  • Edge labels appear on hover
  • All existing Go tests still pass (13 packages)
  • Works in Chrome, Firefox, Safari

Dependencies

  • D3.js (already embedded in visualizer.html)
  • No new Go dependencies

Design reference

The current visualizer uses a dark theme with colored nodes. Keep the same aesthetic. The sidebar should feel like a property inspector (VS Code style).

Activity

  1. added
    enhancement
    v0.7.0
    on Feb 24, 2026
  2. hurttlocker commented on Feb 24, 2026

    @hurttlocker
    OwnerAuthor

    Shipped in v0.7.0 — verified via full audit (13/13 test packages passing, clean build, code reviewed).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementv0.7.0

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions