$ show abhigyanpatwari/GitNexus
GitNexus is a graph-powered code intelligence platform that indexes any codebase into a knowledge graph, then exposes it through MCP tools and a web UI. It supports 14+ languages with deep scope-based resolution (RFC #909), cross-file type inference, control-flow graphs (CFG), program dependence graphs (PDG), taint analysis, and hybrid search (BM25 + semantic + RRF). The system has two main components: a CLI/MCP server (Node.js) for AI agent integration with tools like Cursor, Claude Code, and Codex; and a web UI (React + Vite) for visual graph exploration. The architecture is a multi-phase ingestion pipeline: scan β structure β parse β scope resolution β clustering β process detection β search indexing. The codebase demonstrates strong engineering with comprehensive test coverage (1100+ tests), a shared types package (gitnexus-shared), vendored tree-sitter grammars with prebuilt binaries, Docker containerization with cosign signing, and CI/CD with security scanning. The eval harness for SWE-bench evaluation shows research-grade rigor. Key architectural decisions include the registry-primary scope resolution system, the language provider pattern with compile-time exhaustive dispatch, and the worker pool for parallel parsing with self-healing capabilities.
The LLM identified 8 files worth highlighting for reuse:
Core lookup engine implementing a 7-step resolution protocol: exact FQN β scope-walk β guarded fuzzy fallback. The registry pattern with ClassRegistry, MethodRegistry, and FieldRegistry provides O(1) lookups while maintaining correctness across languages. The tie-break system uses evidence weights and origin priority for deterministic resolution. Pure functions with no side effects β fully reusable for any scope-resolution need.
Compile-time exhaustive language provider registry using TypeScript's `satisfies` constraint. Adding a new language requires: (1) add enum member, (2) create provider file, (3) add one line to the table. The `getProviderForFile` function uses a pre-built extensionβprovider map for O(1) lookup. This pattern is a textbook example of the strategy pattern with static safety guarantees.
DAG-based pipeline runner where phases declare typed dependencies and execute in topological order. The PhaseRegistry pattern allows opt-in phases (like PDG) with `enabledWhen` guards. Each phase produces a typed result consumed by downstream phases. The runner handles lifecycle (try/finally cleanup), error wrapping, and cycle detection. This is a clean implementation of the chain-of-responsibility pattern with explicit dependency management.
Embedding pipeline supporting local ONNX runtime and remote HTTP endpoints with batching, dimension validation, and streaming processing. Handles GPU/CPU/WebGPU backends with graceful degradation. The pipeline integrates with the graph database for semantic search capabilities.
BM25 full-text search using LadybugDB's FTS indexes with parallel queries across multiple node tables (File, Function, Class, Method). Results are merged by file with top-3 node score summation. Supports both direct CLI access and MCP connection pool routing. The hybrid search combines BM25 with semantic embeddings using RRF (Reciprocal Rank Fusion).
HTTP route extraction framework with per-language plugins (Java, Kotlin, Go, Python, PHP, JavaScript, TypeScript). Uses a registry pattern keyed by file extension, with a shared HttpLanguagePlugin interface. The framework handles both annotation-based (Spring) and file-based (Express, FastAPI) route definitions. Easily extensible to new languages by adding a plugin file.
Multi-branch indexing primitives that route each branch to either a flat (primary) slot or a per-branch sub-directory. Uses SHA256 hashing to prevent slug collisions for branches like `feature/x` vs `feature_x`. The `resolveBranchPlacement` function implements the placement logic with proper handling of detached HEAD, non-git folders, and CI checkouts.
Type-safe lazy action factory for CLI commands that defers heavy imports (tree-sitter, ONNX, LadybugDB) until invocation. Uses constrained generics to validate export names against module types at compile time. This pattern significantly improves `gitnexus mcp` startup time by avoiding unnecessary native module loads.