How nxpatterns/gitnexus works
1. Repository shape
- This is a multi-package monorepo centered on the gitnexus CLI and MCP server, plus a separate gitnexus-web browser app.
- The core architectural idea is the same across both: index a codebase into a knowledge graph, persist it, and expose higher-level queries for agents and humans.
2. Primary product boundary: CLI vs Web
- gitnexus/ is the local, Node.js-based product for indexing repos, storing graph state, serving MCP tools, and generating docs.
- gitnexus-web/ is the browser UI for visual exploration and chat, using WebAssembly versions of the parser/database stack.
- Both share the same conceptual pipeline and graph model, but differ in runtime and storage: native Node/KuzuDB for CLI, in-browser WASM for the web app.
3. Indexing pipeline is the central subsystem
- The core graph is built in phases under src/core/ingestion/ in both packages.
- The pipeline walks the filesystem, parses code with Tree-sitter, resolves imports/calls, enriches symbol metadata, detects frameworks, clusters related symbols, and derives execution processes.
- This is the main data-production flow: source files in, structured graph and derived relationships out.
4. Language parsing and AST handling
- Tree-sitter is the parsing boundary.
- Native bindings are used in the CLI; WASM parsers live under gitnexus-web/public/wasm/.
- Parsing output feeds symbol tables, import resolution, call graph extraction, and structural metadata; it is the foundation for all downstream graph features.
5. Graph persistence layer
- The persistent graph store is KuzuDB.
- In the CLI, KuzuDB is native and stored per repo under .gitnexus/.
- In the web app, KuzuDB runs as WASM and is session-scoped in browser memory.
- This layer is the canonical source for graph queries, symbol context, cluster membership, and process traces.
6. Embeddings and hybrid search
- src/core/embeddings/ builds text embeddings for code and metadata, and src/core/search/ combines BM25 lexical retrieval with semantic search.
- Search is not just keyword-based; it is designed to return process-grouped and graph-aware results.
- This subsystem is what powers the query tool and the browser search experience.
7. Graph intelligence features
- Higher-level analysis lives in modules such as clustering, community detection, heritage, process extraction, entry-point scoring, and impact analysis.
- These features transform raw code relationships into actionable summaries like “what depends on this symbol,” “what execution flow does this belong to,” and “which cluster does it fit in.”
- This is the main differentiation from a plain code indexer: relationships are precomputed so tools can answer in one call.
8. CLI orchestration and local repo storage
- The CLI entrypoints under src/cli/ orchestrate indexing, status checks, cleanup, server startup, MCP registration, augmentation, and wiki generation.
- Repo-local state lives in .gitnexus/, while a global registry under ~/.gitnexus/ tracks all indexed repos for multi-repo access.
- src/storage/ manages filesystem and git-aware repo handling; this is the boundary between codebase contents and GitNexus metadata.
9. MCP server and agent-facing tools
- src/mcp/ turns the indexed graph into MCP resources and tools.
- The exposed capabilities include repository listing, hybrid query, symbol context, impact analysis, change detection, rename planning, and raw Cypher access.
- This is the main integration boundary for external AI agents such as Claude Code, Cursor, Windsurf, and OpenCode.
10. Hooks, skills, and editor integration
- The repo includes packaged skills and hook scripts for Claude and Cursor integrations.
- Claude-specific hooks can augment tool use automatically, while skills provide guided workflows for exploring, debugging, impact analysis, and refactoring.
- These are thin integration layers around the MCP/core system; they do not own the graph, but improve how agents consume it.
11. Web app architecture
- gitnexus-web/ is a React + TypeScript + Vite frontend with Sigma.js/Graphology for graph visualization.
- It includes panels for file trees, clusters, processes, code references, settings, and an LLM chat/agent experience.
- Its ingestion and analysis logic mirrors the CLI, but runs in browser workers and WASM to keep everything local to the session.
12. Web backend bridge mode
- The web app can run standalone or connect to a local backend started by gitnexus serve.
- In bridge mode, the browser UI does not re-index; it queries the local CLI-backed server for repo data and AI tools.
- This creates a second data path: browser UI → backend API → local indexed repos.
13. Evaluation and benchmarking
- The eval/ package is a separate Python-based evaluation harness.
- It contains agents, prompts, model configs, a Docker environment, and result analysis scripts for comparing modes and models.
- This subsystem is not part of the product runtime; it exists to benchmark how well the graph-backed context improves agent behavior.
14. Net architecture summary
- At a high level, GitNexus is a pipeline from source code to graph database to agent/human interfaces.
- The key boundaries are: filesystem/codebase ingestion, graph persistence, retrieval/analysis, agent protocol exposure, and UI/visualization.
- The central design choice is precomputing code relationships so downstream tools can retrieve architectural context directly instead of reconstructing it live.
Main entry points: server.ts MCP server · index.ts CLI · App.tsx Web shell · pipeline.ts Ingest pipeline
Components 23
CLI product
Local Node.js product for indexing, serving, and repo management.
- CLI · Command surface for indexing, serving, status, cleanup, wiki generation, and MCP setup.
gitnexus/src/cli/index.ts - Repo store · Filesystem and git-aware repository management plus local/global GitNexus state.
gitnexus/src/storage/repo-manager.ts - Ingest pipeline · Coordinates filesystem walking, parsing, and graph enrichment for local repos.
gitnexus/src/core/ingestion/pipeline.ts - Parse workers · Worker pool and parse worker used to parallelize AST extraction in the CLI.
gitnexus/src/core/ingestion/workers/worker-pool.ts - MCP server · Exposes indexed graph capabilities as MCP resources and tools.
gitnexus/src/mcp/server.ts - Local API · Backend API and local backend bridge used by server and web integration modes.
gitnexus/src/server/api.ts - Wiki docs · Generates repository documentation and HTML views from graph queries.
gitnexus/src/core/wiki/generator.ts
Web app
Browser UI and in-session graph stack.
- Web shell · React/Vite application shell for local exploration, chat, and graph visualization.
gitnexus-web/src/App.tsx - Graph canvas · Sigma.js/Graphology-based graph exploration and rendering surface.
gitnexus-web/src/components/GraphCanvas.tsx - Browser ingest · Browser-side ingestion pipeline running in workers and WASM.
gitnexus-web/src/core/ingestion/pipeline.ts - WASM stack · WebAssembly parsers and Kuzu database used for in-browser local processing.
gitnexus-web/public/wasm/kuzu-wasm.wasm - Web search · Browser hybrid search over local session data and graph state.
gitnexus-web/src/core/search/hybrid-search.ts - Chat agent · Browser LLM context builder, tools, and agent experience.
gitnexus-web/src/core/llm/agent.ts
Shared core
Architecture shared across runtimes: ingestion, graph, search, embeddings, and persistence.
- Graph model · Canonical graph entities and relationships used by ingestion, search, MCP, and UI.
gitnexus/src/core/graph/graph.ts - Tree-sitter · Language parsing boundary and parser loader for syntax-aware analysis.
gitnexus/src/core/tree-sitter/parser-loader.ts - Symbol analysis · AST cache, symbol table, imports, calls, structure, heritage, and framework detection.
gitnexus/src/core/ingestion/symbol-table.ts - Graph intelligence · Clustering, community detection, entry-point scoring, process extraction, and impact-oriented summaries.
gitnexus/src/core/ingestion/cluster-enricher.ts - KuzuDB · Persistent graph store used as the canonical query layer for symbols, clusters, and processes.
gitnexus/src/core/kuzu/kuzu-adapter.ts - Embeddings · Builds embeddings from code and metadata for semantic retrieval.
gitnexus/src/core/embeddings/embedding-pipeline.ts - Hybrid search · Combines BM25 lexical search with semantic search and graph-aware result shaping.
gitnexus/src/core/search/hybrid-search.ts - MCP tools · Repository listing, hybrid query, symbol context, impact analysis, change detection, rename planning, and raw Cypher access.
gitnexus/src/mcp/tools.ts
Agent integrations
Hooks and skills that wrap GitNexus for external agents and editors.
- Hooks & skills · Claude and Cursor hooks plus packaged workflows for exploring, debugging, impact analysis, and refactoring.
gitnexus-claude-plugin/hooks/gitnexus-hook.js
Evaluation
Benchmarking harness for agent performance and modes.
- Eval harness · Python-based evaluation environment, prompts, agents, and result analysis.
eval/run_eval.py
Connections 26
- CLI → Repo store: manage repos · CLI commands read and update indexed repository state.
- CLI → Ingest pipeline: index · CLI starts the repository ingestion pipeline.
- Ingest pipeline → Parse workers: parallel parse · The ingestion pipeline offloads AST parsing to workers.
- Ingest pipeline → Tree-sitter: parse code · Source files are parsed through Tree-sitter.
- Ingest pipeline → Symbol analysis: extract facts · Ingestion derives symbols, imports, calls, and structure.
- Symbol analysis → Graph intelligence: enrich · Derived symbols feed clustering, community, and process analysis.
- Graph intelligence → Graph model: materialize · Higher-level relationships are written into the canonical graph model.
- Graph model → KuzuDB: persist · Graph data is stored in KuzuDB as the authoritative query layer.
- Embeddings → Hybrid search: semantic input · Embeddings power semantic ranking within hybrid retrieval.
- Graph model → Hybrid search: graph-aware lookup · Search combines lexical/semantic retrieval with graph context.
- KuzuDB → Hybrid search: query · Retrieval consults the persisted graph database.
- KuzuDB → MCP tools: serve context · MCP tools query the graph store for agent-facing answers.
- MCP server → MCP tools: expose tools · The server publishes the tool surface to external agents.
- Local API → MCP server: bridge · Local backend mode routes UI requests through the CLI-backed server.
- CLI → MCP server: start · CLI entrypoints can launch MCP serving.
- CLI → Wiki docs: generate docs · Wiki generation uses graph queries and LLM-assisted rendering.
- Web shell → Graph canvas: render graph · The frontend delegates visual exploration to the graph canvas.
- Web shell → Browser ingest: ingest locally · The browser app can build a session-local graph in workers.
- Browser ingest → Tree-sitter: parse code · Browser ingestion uses the same parsing boundary conceptually.
- Browser ingest → WASM stack: use wasm · Browser-side parsing and storage run on WebAssembly.
- Web search → WASM stack: query session · Search operates over the browser-local graph database.
- Web shell → Web search: search · The UI surfaces hybrid search to users.
- Web shell → Chat agent: chat · The frontend connects chat, context building, and tool calls.
- Hooks & skills → MCP server: guide usage · Skills and hooks sit on top of the MCP/core system.
- Eval harness → MCP server: benchmark · Evaluation drives the agent-facing backend through scripted runs.
- Eval harness → Chat agent: compare modes · Evaluation can also assess different prompting and agent modes.