Section 3.1Source:
server/src/graph/models/Graph.tsGraph Data Structure
The canonical 5-map in-memory data structure that represents files, declarations, npm packages, and system modules as an indexed directed graph.
Source:
server/src/graph/models/Graph.tsThe 5 Synchronized In-Memory Maps
The canonical Graph interface is designed for instantaneous $O(1)$ lookups and high-performance traversals:
server/src/graph/models/Graph.ts
1234567export interface Graph { nodes: Map<string, GraphNode>; // nodeId -> Node object (O(1) lookup) edges: Map<string, GraphEdge>; // edgeId -> Edge object (O(1) lookup) nodesByKind: Map<GraphNodeKind, Set<string>>; // kind -> Set of nodeIds (O(1) kind iteration) outgoingEdges: Map<string, Set<string>>; // nodeId -> Set of outgoing edgeIds incomingEdges: Map<string, Set<string>>; // nodeId -> Set of incoming edgeIds }
| Map Field | Type | Operational Purpose |
|---|---|---|
| nodes | Map<string, GraphNode> | Primary node registry storing full payloads (name, location, kind). |
| edges | Map<string, GraphEdge> | Primary edge registry storing directional relationship types. |
| nodesByKind | Map<GraphNodeKind, Set<string>> | Pre-indexes node IDs by kind ('file', 'symbol', 'dependency', 'module'). |
| outgoingEdges | Map<string, Set<string>> | Forward adjacency index for forward reachability, DFS, and Kahn's sort. |
| incomingEdges | Map<string, Set<string>> | Backward adjacency index for impact analysis and Tarjan's SCC. |
Node Kinds & Prefixed ID Convention
All node IDs are strictly prefixed with their discriminant kind via getGraphNodeId(kind, rawId):
Prefixed Node ID Examples
1234file: file:/abs/path/to/src/auth/service.ts symbol: symbol:/abs/path/to/src/auth/service.ts:14:4:validateToken dependency: dependency:express module: module:fs
This prefix prevents collisions between file paths, symbols, and npm dependencies sharing similar names.