Summary
Memories already support typed relationships (memory_relationships), but there is no way to visualize them. Add a knowledge graph view — a classic force-directed graph with nodes sized by their number of incoming relationships.
Changes
Backend
- New
IGraphService / GraphService (auto-registered via [AutoRegisterInterfaces]), depending on NpgsqlDataSource — does not extend IStorage, so no test-fake churn.
GetKnowledgeGraphAsync(WorkspaceId? workspaceId, ProjectId? projectId):
- Nodes: memories with
archetype IN (0,1), optionally scoped by owner (workspace subtree via recursive CTE, or a single project).
- Edges:
memory_relationships where both endpoints are non-archived and within scope.
- New models
GraphData, GraphNode { id, title, type }, GraphEdge { from, to, type }.
- New endpoints in
HomeController: GET /api/graph?workspaceId=&projectId= (JSON) and /graph (page).
Frontend
- New
Views/Home/Graph.cshtml rendering with vis-network 9.x (CDN, consistent with existing marked/mermaid/Prism usage).
- Node size ∝ indegree (number of incoming relationships); minimum size for isolated nodes.
- Node color by memory type; edge color by relationship type (reuse the existing
getRelationshipBadgeColor color mapping).
- Click a node →
/view/{id}; hover tooltip shows the title; barnesHut physics; zoom/pan built in.
- Light/dark theme support (read
data-theme, MutationObserver on the <html data-theme> attribute to re-style on toggle).
- Empty state when there are no relationships.
- Sidebar nav link ("Graph") in the primary-actions row of
_Layout.cshtml.
Files
- New:
src/Memorizer/Services/IGraphService.cs, Services/GraphService.cs, Models/GraphData.cs, Views/Home/Graph.cshtml
- Modified:
src/Memorizer/Controllers/HomeController.cs, Views/Shared/_Layout.cshtml, wwwroot/css/site.css
Notes
Summary
Memories already support typed relationships (
memory_relationships), but there is no way to visualize them. Add a knowledge graph view — a classic force-directed graph with nodes sized by their number of incoming relationships.Changes
Backend
IGraphService/GraphService(auto-registered via[AutoRegisterInterfaces]), depending onNpgsqlDataSource— does not extendIStorage, so no test-fake churn.GetKnowledgeGraphAsync(WorkspaceId? workspaceId, ProjectId? projectId):archetype IN (0,1), optionally scoped by owner (workspace subtree via recursive CTE, or a single project).memory_relationshipswhere both endpoints are non-archived and within scope.GraphData,GraphNode { id, title, type },GraphEdge { from, to, type }.HomeController:GET /api/graph?workspaceId=&projectId=(JSON) and/graph(page).Frontend
Views/Home/Graph.cshtmlrendering with vis-network 9.x (CDN, consistent with existing marked/mermaid/Prism usage).getRelationshipBadgeColorcolor mapping)./view/{id}; hover tooltip shows the title; barnesHut physics; zoom/pan built in.data-theme,MutationObserveron the<html data-theme>attribute to re-style on toggle)._Layout.cshtml.Files
src/Memorizer/Services/IGraphService.cs,Services/GraphService.cs,Models/GraphData.cs,Views/Home/Graph.cshtmlsrc/Memorizer/Controllers/HomeController.cs,Views/Shared/_Layout.cshtml,wwwroot/css/site.cssNotes