Summary
Port the Entity Graph implementation from folio-mapper to ontokit-web as a full-stack feature: a server-side BFS graph building endpoint on the API side, and enhanced React Flow visualization components on the frontend.
This replaces the current client-side graph building (Phase 6A) with a faster, more scalable server-driven approach while preserving ontokit's ontology-agnostic node type system.
Motivation
The current graph visualization builds the graph client-side by iteratively fetching individual class details — limited to ~100 nodes and slow for deep hierarchies. folio-mapper's implementation uses server-side BFS traversal that returns a complete subgraph in one response (up to 200 nodes with truncation detection), handles seeAlso cross-links properly, and supports progressive node expansion.
Proposed Changes
Backend (ontokit-api)
- New endpoint:
GET /api/v1/projects/{id}/ontology/graph/{iri} — server-side BFS traversal
- Configurable:
ancestors_depth, descendants_depth, max_nodes, include_see_also
- Returns: nodes + edges + truncation flag + total concept count
- BFS upward (ancestors to root), downward (descendants), and lateral (seeAlso cross-links)
Frontend (ontokit-web)
- Replace
buildGraphData.ts (client-side builder) with API-backed data fetching
- Port
EntityGraphModal — full-screen overlay with close/Esc support
- Port
ConceptNode — adapted with ontokit's node types (focus, class, root, individual, property, external, unexplored)
- Port
HierarchyEdge — subClassOf (solid) + seeAlso (dashed purple) + equivalentClass + disjointWith
- Port
useELKLayout — ELK layered algorithm with TB/LR direction toggle
- Keep both inline graph (detail panel toggle) AND full-screen modal (expand button)
Coloring (ontology-agnostic)
- Branch root / ultimate ancestor nodes: red accent
- Other ancestor nodes: dark gray accent
- Focus node: blue accent
- seeAlso edges: purple dashed
- subClassOf edges: solid gray
- No hardcoded ontology-specific colors — lineage determines color
Reference Implementation
- folio-mapper frontend:
packages/ui/src/components/mapping/graph/ (EntityGraph, ConceptNode, HierarchyEdge, useELKLayout)
- folio-mapper backend:
backend/app/services/folio_service.py lines 861-1024 (build_entity_graph())
- folio-mapper types:
packages/core/src/folio/graph-types.ts
Testing Plan
🤖 Generated with Claude Code
Summary
Port the Entity Graph implementation from folio-mapper to ontokit-web as a full-stack feature: a server-side BFS graph building endpoint on the API side, and enhanced React Flow visualization components on the frontend.
This replaces the current client-side graph building (Phase 6A) with a faster, more scalable server-driven approach while preserving ontokit's ontology-agnostic node type system.
Motivation
The current graph visualization builds the graph client-side by iteratively fetching individual class details — limited to ~100 nodes and slow for deep hierarchies. folio-mapper's implementation uses server-side BFS traversal that returns a complete subgraph in one response (up to 200 nodes with truncation detection), handles
seeAlsocross-links properly, and supports progressive node expansion.Proposed Changes
Backend (ontokit-api)
GET /api/v1/projects/{id}/ontology/graph/{iri}— server-side BFS traversalancestors_depth,descendants_depth,max_nodes,include_see_alsoFrontend (ontokit-web)
buildGraphData.ts(client-side builder) with API-backed data fetchingEntityGraphModal— full-screen overlay with close/Esc supportConceptNode— adapted with ontokit's node types (focus, class, root, individual, property, external, unexplored)HierarchyEdge— subClassOf (solid) + seeAlso (dashed purple) + equivalentClass + disjointWithuseELKLayout— ELK layered algorithm with TB/LR direction toggleColoring (ontology-agnostic)
Reference Implementation
packages/ui/src/components/mapping/graph/(EntityGraph, ConceptNode, HierarchyEdge, useELKLayout)backend/app/services/folio_service.pylines 861-1024 (build_entity_graph())packages/core/src/folio/graph-types.tsTesting Plan
🤖 Generated with Claude Code