Design an implementation plan for adding realtime graph updates to the depgraph project via external CSV files.
The depgraph project is a dependency graph visualizer. Here’s the current data flow:
Source Code (HTML) → extractJS() → analyzeCode() via Acorn AST → {functions: Map, globals: Map}
→ clusterFunctions() + computeAffinities() → buildGraph() → computeLayout() → renderGraph() (D3 SVG)
Key files:
/Users/zack/Documents/depgraph/prototypes/index.html (~4744 lines) — entire frontend app/Users/zack/Documents/depgraph/depgraph-server.mjs (258 lines) — Node.js HTTP server + SSE/Users/zack/Documents/depgraph/codegen/codemap.py (246 lines) — Python codemap generator/Users/zack/Documents/depgraph/runtime/depgraph.md — codemap (clusters of functions)/Users/zack/Documents/depgraph/codegen/codegen.md — documentation of the codegen process/Users/zack/Documents/depgraph/inspect.json — project configruntime/nodes.csv and runtime/edges.csv (no CSV headers)src and codemap files. When those change, recompute runtime/nodes.csv and runtime/edges.csv.HEAVILY tangled. Here are the coupling points:
analyzeCode() returns { globals: Map<name, {kind, line}>, functions: Map<name, {reads, writes, rw, calls, params, locals, line, endLine, lines}> }analyzeFunction() (lines 806-877) walks function bodies for reads/writes/callsSix hardcoded edge layers, all assuming function properties:
calls: uses a.calls.has(nameB)calledBy: reverse of callsshared: uses a.reads, a.writes, a.rw SetssharedWrites: uses a.writes, a.rw Setsimportance: uses a.calls + reads/writes/rwuses/writesTo: created directly in buildGraph for hypergraph modeanalysis.functions with type: 'function'type: 'global'functions.keys() for pairwise edge computationclusterFunctions() maps function names to cluster IDs from codemap sectionsinfo.reads, info.writes, info.rw, info.calls for affinity weightsloadAndAnalyze() fetches HTML source, extracts JS, runs AST analysis/focus-events endpoint (lines 198-210)runtime/depgraph-focus.json (lines 44-61)/target/src (source file) and codemapsrc and codemap files, regenerates CSVs when they changePlease design a detailed implementation plan covering: