{"id":37170330,"url":"https://github.com/abhigyanpatwari/GitNexus","last_synced_at":"2026-01-21T23:00:55.902Z","repository":{"id":307923905,"uuid":"1031059905","full_name":"abhigyanpatwari/GitNexus","owner":"abhigyanpatwari","description":"GitNexus: The Zero-Server Code Intelligence Engine -       GitNexus is a client-side knowledge graph creator that runs entirely in your browser. Drop in a GitHub repo or ZIP file, and get an interactive knowledge graph wit a built in Graph RAG Agent. Perfect for code exploration","archived":false,"fork":false,"pushed_at":"2026-01-18T00:57:04.000Z","size":11306,"stargazers_count":319,"open_issues_count":2,"forks_count":28,"subscribers_count":4,"default_branch":"main","last_synced_at":"2026-01-18T03:44:52.566Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"https://gitnexus.vercel.app","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/abhigyanpatwari.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2025-08-02T23:20:31.000Z","updated_at":"2026-01-18T02:39:36.000Z","dependencies_parsed_at":null,"dependency_job_id":"70e7e0df-30f0-4b7e-b523-1167d34dfe14","html_url":"https://github.com/abhigyanpatwari/GitNexus","commit_stats":null,"previous_names":["abhigyanpatwari/codenexus","abhigyanpatwari/gitnexus"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/abhigyanpatwari/GitNexus","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/abhigyanpatwari%2FGitNexus","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/abhigyanpatwari%2FGitNexus/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/abhigyanpatwari%2FGitNexus/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/abhigyanpatwari%2FGitNexus/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/abhigyanpatwari","download_url":"https://codeload.github.com/abhigyanpatwari/GitNexus/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/abhigyanpatwari%2FGitNexus/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28646494,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-21T21:29:11.980Z","status":"ssl_error","status_checked_at":"2026-01-21T21:24:31.872Z","response_time":86,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2026-01-14T20:00:22.942Z","updated_at":"2026-01-21T23:00:55.888Z","avatar_url":"https://github.com/abhigyanpatwari.png","language":"TypeScript","funding_links":[],"categories":["TypeScript","🛠️ LLM DevTools \u0026 Orchestration Infrastructure","Repos","Open-source repos","others","🛠️ Developer Tools","Supporting Infrastructure","好玩项目","Code Analysis \u0026 Search"],"sub_categories":["Codebase Context","黑科技","Other IDEs"],"readme":"# GitNexus V2\n\n**Zero-Server, Graph-Based Code Intelligence Engine**\nWorks fully in-browser through WebAssembly. (DB engine, Embeddings model, AST parsing, all happens inside browser)\n\nhttps://github.com/user-attachments/assets/2fb7c522-20d1-48f6-9583-36c3969aa4dc\n\nhttps://gitnexus.vercel.app\nBeing client sided, it costs me zero to deploy, so you can use it for free :-) (would love a ⭐ though)\n\n\u003e *Like DeepWiki, but deeper.* 😉\n\nDeepWiki helps you *understand* code. GitNexus lets you *analyze* it—because a knowledge graph tracks every dependency, call chain, and relationship. \n\nThat's the difference between:\n- \"What does this function do?\" → *understanding*\n- \"What breaks if I change this function?\" → *analysis*\n\n**Some quick tech jargon:**\n- **Enhanced Search**: BM25 + Semantic + 1-hop graph expansion via Cypher\n- **Full WASM Stack**: Tree-sitter parsing + KuzuDB graph database, all in-browser\n- **Repo Map**: Complete code knowledge graph with CALLS, IMPORTS, EXTENDS relations\n- **Vector Index**: HNSW embeddings for semantic similarity search\n- **Cypher Queries**: Relational analysis for accurate context retrieval\n- **Grounded AI**: Every answer cites `[[file:line]]` as proof\n\n**What you can do:**\n\n| Capability | Description |\n|------------|-------------|\n| **Codebase-wide audits** | Find layer violations, forbidden dependencies |\n| **Blast radius analysis** | See every function affected by a change |\n| **Dead code detection** | Identify orphaned nodes with zero incoming calls |\n| **Dependency tracing** | Follow import chains across the entire codebase |\n| **AI analyses with citations** | Ask questions, analyze, get answers with `[[file:line]]` proof |\n\n**100% client-side.** Your code never leaves your browser.\n\n**Supports:** TypeScript, JavaScript, Python (Go, Java, C in progress)\n\n\u003cimg width=\"2550\" height=\"1343\" alt=\"gitnexus_img\" src=\"https://github.com/user-attachments/assets/cc5d637d-e0e5-48e6-93ff-5bcfdb929285\" /\u003e\n\n---\n\n## 🔍 The Problem with AI Coding Tools\n\nTools like **Cursor**, **Claude Code**, **Cline**, **Roo Code**, and **Windsurf** are powerful—but they share a fundamental limitation: **they don't truly know your codebase structure**.\n\n| Tool | Context Strategy | The Gap |\n|------|------------------|---------|\n| **Cursor** | Files in tabs + embeddings | No call graph. Can't trace \"what calls this?\" |\n| **Claude Code** | File search + grep | Text-based. Misses semantic connections |\n| **Cline/Roo Code** | Repo map + tree-sitter | Static structure. No runtime dependencies tracked |\n| **Windsurf** | Cascade context | Limited dependency depth |\n\n**What happens:**\n1. AI edits `UserService.validate()` \n2. Doesn't know 47 functions depend on its return type\n3. **Breaking changes ship** 💥\n\n### The Solution: Graph Coverage\n\nA knowledge graph tracks **actual relationships**, not just file contents:\n\n```mermaid\ngraph LR\n    EDIT[AI wants to edit UserService.validate] --\u003e QUERY[Graph Query: What depends on this?]\n    QUERY --\u003e DEPS[\"47 callers across 12 files\"]\n    DEPS --\u003e SAFE[AI sees full blast radius first]\n```\n\n**Current state:** GitNexus is a standalone tool—a better DeepWiki that's 100% client-side with graph-powered analysis.\n\n**Future goal (MCP):** Expose GitNexus as an MCP server so tools like Cursor and Claude Code can query it for accurate context. They ask \"what calls X?\", GitNexus returns the actual call graph. No more guessing.\n\n\n---\n\n## 🚀 Quick Start\n\n```bash\ngit clone \u003crepository-url\u003e\ncd gitnexus\nnpm install\nnpm run dev\n```\n\nOpen http://localhost:5173, drag \u0026 drop a ZIP of your codebase, and start exploring.\n\n---\n\n## 🏗️ Indexing Architecture\n\nTwo-phase indexing: **Knowledge Graph** (blocking) → **Embeddings** (background).\n\n### Phase 1-5: Knowledge Graph Creation\n\n```mermaid\nflowchart TD\n    subgraph P1[\"Phase 1: Extract (0-15%)\"]\n        E1[Decompress ZIP] --\u003e E2[Collect file paths]\n    end\n    \n    subgraph P2[\"Phase 2: Structure (15-30%)\"]\n        S1[Build folder tree] --\u003e S2[Create CONTAINS edges]\n    end\n    \n    subgraph P3[\"Phase 3: Parse (30-70%)\"]\n        PA1[Load Tree-sitter WASM] --\u003e PA2[Generate ASTs]\n        PA2 --\u003e PA3[Extract symbols]\n        PA3 --\u003e PA4[Populate Symbol Table]\n    end\n    \n    subgraph P4[\"Phase 4: Imports (70-82%)\"]\n        I1[Find import statements] --\u003e I2[Resolve paths]\n        I2 --\u003e I3[Create IMPORTS edges]\n    end\n    \n    subgraph P5[\"Phase 5: Calls + Heritage (82-100%)\"]\n        C1[Find function calls] --\u003e C2[Resolve via Symbol Table]\n        C2 --\u003e C3[Create CALLS edges]\n        C3 --\u003e H1[Find extends/implements]\n        H1 --\u003e H2[Create EXTENDS/IMPLEMENTS edges]\n    end\n    \n    P1 --\u003e P2 --\u003e P3 --\u003e P4 --\u003e P5\n    P5 --\u003e DB[(KuzuDB WASM)]\n    DB --\u003e READY[Graph Ready!]\n```\n\n### Symbol Table: Dual HashMap\n\nResolution strategy for function calls:\n\n```mermaid\nflowchart TD\n    CALL[Found call: validateUser] --\u003e CHECK1{In Import Map?}\n    CHECK1 --\u003e|Yes| FOUND1[Use imported definition]\n    CHECK1 --\u003e|No| CHECK2{In Current File?}\n    CHECK2 --\u003e|Yes| FOUND2[Use local definition]\n    CHECK2 --\u003e|No| CHECK3{Global Search}\n    CHECK3 --\u003e|Found| FOUND3[Use first match]\n    CHECK3 --\u003e|Not Found| SKIP[Skip - unresolved]\n    \n    FOUND1 --\u003e EDGE[Create CALLS edge]\n    FOUND2 --\u003e EDGE\n    FOUND3 --\u003e EDGE\n```\n\n**Data structure:**\n```\nFile-Scoped: Map\u003cFilePath, Map\u003cSymbolName, NodeID\u003e\u003e\nGlobal:      Map\u003cSymbolName, SymbolDefinition[]\u003e\n```\n\n### Phase 6+: Background Embeddings\n\n```mermaid\nflowchart LR\n    subgraph BG[\"Background (Non-blocking)\"]\n        M1[Load snowflake-arctic-embed-xs] --\u003e M2[Initialize WebGPU/WASM]\n        M2 --\u003e E1[Batch embed nodes]\n        E1 --\u003e E2[INSERT into CodeEmbedding table]\n        E2 --\u003e V1[Create HNSW Vector Index]\n        V1 --\u003e B1[Build BM25 Index]\n    end\n    \n    BG --\u003e AI[AI Search Ready!]\n```\n\nUser can explore the graph during embedding. AI features unlock when complete.\n\n---\n\n## 📊 Graph Schema\n\n### Node Types\n\n| Label | Description | Properties |\n|-------|-------------|------------|\n| `Folder` | Directory | `name`, `filePath` |\n| `File` | Source file | `name`, `filePath`, `language` |\n| `Function` | Function def | `name`, `filePath`, `startLine`, `endLine`, `isExported` |\n| `Class` | Class def | `name`, `filePath`, `startLine`, `endLine` |\n| `Interface` | Interface def | `name`, `filePath`, `startLine`, `endLine` |\n| `Method` | Class method | `name`, `filePath`, `startLine`, `endLine` |\n| `CodeElement` | Generic symbol | `name`, `filePath` |\n\n### Relationship Table: `CodeRelation`\n\nSingle edge table with `type` property:\n\n| Type | From | To | Description |\n|------|------|-----|-------------|\n| `CONTAINS` | Folder | File/Folder | Directory structure |\n| `DEFINES` | File | Function/Class/etc | Code definitions |\n| `IMPORTS` | File | File | Module dependencies |\n| `CALLS` | Function/Method | Function/Method | Call graph |\n| `EXTENDS` | Class | Class | Inheritance |\n| `IMPLEMENTS` | Class | Interface | Interface implementation |\n\n---\n\n## 🛠️ Agent Tools Architecture\n\nThe LangChain ReAct agent has **5 tools** for code exploration. These tools **use the graph** built during indexing.\n\n### Tool 1: `search` — Hybrid Search with Graph Context\n\nCombines **BM25** (keyword) + **Semantic** (vector) + **1-hop expansion**:\n\n```mermaid\nflowchart TD\n    Q[Query: auth middleware] --\u003e BM25[BM25 Keyword Search]\n    Q --\u003e SEM[Semantic Vector Search]\n    \n    BM25 --\u003e RRF[Reciprocal Rank Fusion]\n    SEM --\u003e RRF\n    \n    RRF --\u003e TOP[Top K Results]\n    TOP --\u003e HOP[1-Hop Graph Expansion]\n    \n    HOP --\u003e OUT[\"Each result includes:\n    • ID, file, score\n    • Incoming connections (who calls this)\n    • Outgoing connections (what this calls)\"]\n```\n\n**How 1-hop works:**\n```cypher\nMATCH (n {id: $nodeId})\nOPTIONAL MATCH (n)-[r1:CodeRelation]-\u003e(dst)\nOPTIONAL MATCH (src)-[r2:CodeRelation]-\u003e(n)\nRETURN collect(dst.name), collect(src.name)\n```\n\nThe agent sees not just *what matches*, but *what connects to it*.\n\n---\n\n### Tool 2: `cypher` — Raw Graph Queries with Auto-Embedding\n\nExecute Cypher directly. If you include `{{QUERY_VECTOR}}`, it auto-embeds:\n\n```mermaid\nflowchart LR\n    CQ[Cypher with placeholder] --\u003e CHECK{Contains QUERY_VECTOR?}\n    CHECK --\u003e|Yes| EMBED[Embed query text]\n    EMBED --\u003e REPLACE[Replace placeholder with vector]\n    CHECK --\u003e|No| EXEC\n    REPLACE --\u003e EXEC[Execute Cypher]\n    EXEC --\u003e RES[Return Results]\n```\n\n**Example with auto-embedding:**\n```cypher\nCALL QUERY_VECTOR_INDEX('CodeEmbedding', 'idx', {{QUERY_VECTOR}}, 10)\nYIELD node, distance\nWHERE distance \u003c 0.4\nMATCH (caller:Function)-[:CodeRelation {type: 'CALLS'}]-\u003e(n:Function {id: node.nodeId})\nRETURN caller.name, n.name\n```\n\nThe agent provides `query: \"authentication\"` → system embeds it → injects the vector.\n\n---\n\n### Tool 3: `grep` — Regex Pattern Matching\n\nFor exact strings, error codes, TODOs:\n\n```mermaid\nflowchart LR\n    PAT[\"Pattern: TODO|FIXME\"] --\u003e REGEX[Compile Regex]\n    REGEX --\u003e SCAN[Scan all files]\n    SCAN --\u003e MATCH[Match per line]\n    MATCH --\u003e RES[\"file:line: content\"]\n```\n\n---\n\n### Tool 4: `read` — Smart File Reader\n\nFuzzy path matching with suggestions:\n\n```mermaid\nflowchart TD\n    REQ[Request: src/utils.ts] --\u003e EXACT{Exact match?}\n    EXACT --\u003e|Yes| RET[Return content]\n    EXACT --\u003e|No| FUZZY[Fuzzy match by segments]\n    FUZZY --\u003e FOUND{Found?}\n    FOUND --\u003e|Yes| RET\n    FOUND --\u003e|No| SUGGEST[Suggest similar files]\n```\n\n---\n\n### Tool 5: `highlight` — Visual Graph Feedback\n\nEmits a marker that the UI parses to highlight nodes:\n```\n[HIGHLIGHT_NODES:Function:src/auth.ts:validate,Class:src/user.ts:UserService]\n```\n\n---\n\n## 💡 Key Discovery: Unified Vector + Graph\n\nMost Graph RAG systems use **separate databases**—vector DB for semantic search, graph DB for traversal.\n\nKuzuDB supports **native vector indexing (HNSW)**, so we do both in **one Cypher query**:\n\n```cypher\n-- Semantic search + graph traversal in ONE query\nCALL QUERY_VECTOR_INDEX('CodeEmbedding', 'code_embedding_idx', $queryVector, 20)\nYIELD node AS emb, distance\nWITH emb, distance WHERE distance \u003c 0.4\nMATCH (n:Function {id: emb.nodeId})\u003c-[:CodeRelation {type: 'CALLS'}]-(caller:Function)\nRETURN n.name, caller.name, distance\nORDER BY distance\n```\n\n**Why this matters:**\n- 🎯 **Single query execution** — No round-trips between systems\n- 📊 **Built-in relevance ranking** — Distance IS the score\n- ⚡ **No separate vector DB** — One database, one query language\n- 🌳 **LLM-friendly** — Agent writes one Cypher, gets semantic + structural results\n\n---\n\n## 🔬 Deep Dive: Copy-on-Write Memory Issue\n\nHit an interesting problem storing embeddings worth documenting.\n\n**Setup:** Store 384-dim embeddings alongside code nodes.\n```cypher\nMATCH (n:CodeNode {id: $id}) SET n.embedding = $vec\n```\n\n**Problem:** Worked for ~20 nodes, exploded at ~1000:\n```\nBuffer manager exception: Unable to allocate memory!\n```\n\n**Root cause: Copy-on-Write.** Each `UPDATE` copies the entire record (~2KB of code content). 1000 updates = massive memory duplication in WASM.\n\n```mermaid\nflowchart LR\n    subgraph COW[\"Copy-on-Write Effect\"]\n        OLD[Old: 2KB] --\u003e NEW[New: 3.5KB]\n    end\n    COW --\u003e|\"× 1000 nodes\"| BOOM[💥 Buffer Exhausted]\n```\n\n**Fix:** Separate `CodeEmbedding` table with `INSERT` only:\n\n```mermaid\nflowchart TD\n    subgraph Old[\"❌ Single Table\"]\n        CN1[CodeNode with embedding\u003cbr/\u003eUPDATE triggers COW]\n    end\n    \n    subgraph New[\"✅ Separate Table\"]\n        CN2[CodeNode\u003cbr/\u003eid, name, content]\n        CE[CodeEmbedding\u003cbr/\u003enodeId, embedding\u003cbr/\u003eINSERT only]\n    end\n    \n    Old --\u003e|\"Memory explosion\"| FAIL\n    New --\u003e|\"Works at scale\"| WIN\n```\n\n**Lesson:** In-memory WASM DBs have hard limits. Profile at scale, not happy path.\n\n---\n\n## ⚡ V2 Technical Improvements\n\n### Sigma.js + WebGL\n- V1: D3.js, choked at ~3k nodes\n- V2: Sigma.js + GPU rendering, smooth at 10k+\n\n### Dual HashMap Symbol Table\n- V1: Trie (prefix tree) - clever but slow\n- V2: File-scoped + Global hashmaps - **~2x speedup**\n\n### LRU AST Cache\n- Tree-sitter ASTs live in WASM memory\n- LRU cache (50 slots) with `tree.delete()` for cleanup\n- Memory stays bounded even for huge codebases\n\n### ForceAtlas2 in Web Worker\n- Layout algorithm runs off main thread\n- UI stays responsive during graph positioning\n\n---\n\n## 🚧 Roadmap\n\n### Actively Building\n\n- [ ] **MCP Support** - Model Context Protocol for tool extensibility\n- [ ] **External DB Support** - Connect to Neo4j (hosted or Docker)\n- [ ] **Blast Radius Analysis Tool** - Dedicated UI for impact analysis\n- [ ] **Multi-Worker Pool** - Parallel parsing across Web Workers\n- [ ] **Ollama Support** - Local LLM integration\n- [ ] **CSV Export** - Export node/relationship tables\n\n### 🎯 The Vision: Browser-Based MCP Server\n\n**Goal:** Expose GitNexus as a local MCP server directly from the browser.\n\nThis would let AI coding tools like **Cursor**, **Claude Code**, **Windsurf**, etc. connect to your running GitNexus instance and use its knowledge graph for:\n- 🔍 **Reliable context gathering** — AI gets actual dependencies, not grep guesses\n- 💥 **Blast radius detection** — Before making changes, query what would break\n- 🔐 **Codebase-wide audits** — Find violations, dead code, circular dependencies\n- 🧠 **Grounded answers** — Every response backed by graph traversal, not hallucination\n\n```mermaid\ngraph LR\n    subgraph Browser[\"GitNexus (Browser)\"]\n        KG[Knowledge Graph]\n        MCP[MCP Server]\n    end\n    \n    subgraph Tools[\"AI Coding Tools\"]\n        CURSOR[Cursor]\n        CLAUDE[Claude Code]\n        WIND[Windsurf]\n    end\n    \n    KG --\u003e MCP\n    MCP \u003c--\u003e|localhost| CURSOR\n    MCP \u003c--\u003e|localhost| CLAUDE\n    MCP \u003c--\u003e|localhost| WIND\n```\n\n**Why this matters:** Current AI coding tools are blind to real dependencies. They use grep or embeddings—better than nothing, but not enough to prevent breaking changes. A knowledge graph MCP would give them the accurate, structural context they need.\n\n### Recently Completed ✅\n\n- [x] Graph RAG Agent with 5 tools (search, cypher, grep, read, highlight)\n- [x] Browser embeddings (snowflake-arctic-embed-xs, 22M params)\n- [x] Vector index with HNSW in KuzuDB\n- [x] Hybrid search (BM25 + semantic + RRF)\n- [x] Streaming AI chat with tool visibility\n- [x] Grounded citations (`[[file:line]]` format)\n- [x] Multiple LLM providers (OpenAI, Azure, Gemini, Anthropic)\n\n---\n\n## 🛠 Tech Stack\n\n| Layer | Technology |\n|-------|------------|\n| **Frontend** | React 18, TypeScript, Vite, Tailwind v4 |\n| **Visualization** | Sigma.js, Graphology, ForceAtlas2 (WebGL) |\n| **Parsing** | Tree-sitter WASM (TS, JS, Python) |\n| **Database** | KuzuDB WASM (graph + vector HNSW) |\n| **Embeddings** | transformers.js, snowflake-arctic-embed-xs (22M) |\n| **AI** | LangChain ReAct agent, streaming |\n| **Concurrency** | Web Workers + Comlink |\n\n---\n\n## 🔐 Security \u0026 Privacy\n\n- All processing happens in your browser\n- No code uploaded to any server\n- API keys stored in localStorage only\n- Open source—audit the code yourself\n\n---\n\n## 📝 License\n\nMIT License\n\n---\n\n## 🙏 Acknowledgments\n\n- [Tree-sitter](https://tree-sitter.github.io/) - AST parsing\n- [KuzuDB](https://kuzudb.com/) - Embedded graph database with vector support\n- [Sigma.js](https://www.sigmajs.org/) - WebGL graph rendering\n- [transformers.js](https://huggingface.co/docs/transformers.js) - Browser ML\n- [LangChain](https://langchain.com/) - Agent orchestration\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fabhigyanpatwari%2FGitNexus","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fabhigyanpatwari%2FGitNexus","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fabhigyanpatwari%2FGitNexus/lists"}