Knowledge Graph Explorer (Interactive Neo4j Entity/Relationship Visualization in Admin UI)
#61 opened on Aug 8, 2026
Repository metrics
- Stars
- (43 stars)
- PR merge metrics
- (PR metrics pending)
Description
Summary
Add an interactive Knowledge Graph Explorer to the admin UI so admins can visually browse the Neo4j entity/relationship graph that Lumina already builds during ingestion, instead of only seeing aggregate counts via knowledge:graph:status.
Problem
Every knowledge source is chunked, embedded into Pinecone, and run through entity extraction into Neo4j (Document → Chunk → Entity, linked by RELATED_TO, see server/src/services/graphKnowledge.ts). Right now the only visibility into that graph is:
npm run knowledge:graph:status— four aggregate numbers (documentCount,chunkCount,entityCount,relationshipCount), no detail.npm run knowledge:graph:rebuild[:clean]— blunt, all-or-nothing rebuild.
There's no way to answer basic questions like "what entities did we extract from the profile source?", "is this entity linked to sources it shouldn't be?", or "did the last edit actually change the graph?" without opening the Neo4j AuraDB console directly (which most admins won't have credentials for). This makes the graph side of RAG effectively a black box compared to the vector side, which is now fully visible and editable via the Knowledge Manager UI (#34).
Proposed Solution
Backend (server/src/routes/knowledge.ts, server/src/services/graphKnowledge.ts)
- Add
GET /api/knowledge/graph(admin-only, samerequireAdmingate as the rest of the router):- Query params:
sourceId(optional filter to one document's subgraph),entityType(optional),limit(capped, e.g. max 500 nodes) to keep responses renderable. - Returns a
{ nodes, edges }payload — nodes typeddocument | chunk | entitywith label/type metadata, edges typed by the existingRELATED_TOrelationship (plusDocument -[:HAS_CHUNK]-> Chunk/Chunk -[:MENTIONS]-> Entityif those relationship types exist — confirm exact schema iningestChunksToGraph). - Reuse the existing Neo4j session/driver pattern from
getGraphStats; do not add a second driver instance.
- Query params:
- Add
GET /api/knowledge/graph/statsas a thin wrapper if the raw counts are still useful standalone (or fold into the payload above under astatskey — avoid two round trips if we can help it).
Frontend (client/src/pages/KnowledgeAdmin.tsx or a new KnowledgeGraphExplorer.tsx)
- New tab/panel in the Knowledge Manager: "Graph" alongside the existing sources table.
- Force-directed graph view (e.g.
react-force-graphorvis-network, whichever is lighter given the existing bundle-size warning onnpm run build) with:- Color/shape coded by node type (document, chunk, entity).
- Click a node → side panel with its properties; clicking a document/chunk node deep-links to that source's edit dialog (reuse
openEdit+ theGET /api/knowledge/:idendpoint added in #60). - Filter dropdown scoped to a single source, and a search box that highlights matching entity names.
- Empty/disabled state when Neo4j isn't configured (
isNeo4jConfigured() === false), matching how the CLI already degrades gracefully.
Docs
- Document the new endpoint(s) in
openapi.yaml. - Add a "Graph Explorer" subsection to
UPDATE_KNOWLEDGE.mdnear the existing Architecture Overview / graph troubleshooting sections, and a screenshot to the README's admin UI section.
Acceptance Criteria
- Admin can open a graph view scoped to "all sources" or a single source and see real nodes/edges pulled from Neo4j, not placeholder data.
- Graph responses are capped/paginated so a large graph can't hang the browser tab or the Neo4j query.
- Clicking a document/chunk node navigates to the corresponding source's edit view.
- The panel degrades to a clear "Graph RAG not configured" message when
NEO4J_URIetc. are unset, rather than erroring. openapi.yamland docs updated to match the shipped endpoint contract.
Out of Scope
- Editing the graph directly from the visualization (creating/deleting entities or relationships by hand) — read-only explorer for now.
- Graph algorithms (community detection, shortest path, centrality) — just browsing/filtering.
- Non-admin access to any graph data.
Suggested Tasks
- Confirm exact Neo4j relationship types used by
ingestChunksToGraph(RELATED_TOand anyHAS_CHUNK/MENTIONStypes) so the API response is accurate. - Add
GET /api/knowledge/graph(+ optional/stats) withrequireAdminguard and a hard node-count cap. - Add graph visualization panel to the Knowledge Manager admin page.
- Wire node click-through to existing source edit flow.
- Handle the Neo4j-not-configured state gracefully in the UI.
- Update
openapi.yaml,UPDATE_KNOWLEDGE.md, and README with the new capability.