# gurdeepsinghiet/codebase-memory-mcp architecture

> Architecture diagram of the GitHub repository gurdeepsinghiet/codebase-memory-mcp, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-09-26). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/gurdeepsinghiet/codebase-memory-mcp
- Repository: https://github.com/gurdeepsinghiet/codebase-memory-mcp

## Overview

codebase-memory-mcp indexes local repositories into a persistent code knowledge graph and exposes structural analysis to coding agents through MCP, with a built-in graph UI. The main workflow is an agent request to index a repository, followed by parsing, semantic enrichment, and graph persistence; later queries return structural insights. The README also documents incremental indexing, infrastructure-as-code coverage, cross-service links, and agent-client setup. Several backend subsystems are documented but their implementation wiring was not sampled, so those links are shown only where supported by the README or excerpts.

Main entry points: [`src/pipeline/pipeline.c`](https://github.com/gurdeepsinghiet/codebase-memory-mcp/blob/main/src/pipeline/pipeline.c) (Index orchestrator), [`graph-ui/src/App.tsx`](https://github.com/gurdeepsinghiet/codebase-memory-mcp/blob/main/graph-ui/src/App.tsx) (Graph UI), [`src/main.c`](https://github.com/gurdeepsinghiet/codebase-memory-mcp/blob/main/src/main.c) (MCP server), [`src/pipeline/pipeline_incremental.c`](https://github.com/gurdeepsinghiet/codebase-memory-mcp/blob/main/src/pipeline/pipeline_incremental.c) (Incremental indexing)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_interface["Agent and UI"]
  node_mcp["MCP server<br/>[main.c]"]
  node_agent_setup["Client setup<br/>[agent_clients.c]"]
  node_daemon["Session daemon<br/>[application.c]"]
  node_local_api["Local UI API"]
end

subgraph group_indexing["Indexing pipeline"]
  node_pipeline["Index orchestrator<br/>[pipeline.c]"]
  node_incremental["Incremental indexing"]
  node_delta["Delta repair<br/>[pipeline_delta.c]"]
  node_grammars["Language grammars"]
  node_extraction["Fact extraction<br/>[extract_unified.c]"]
end

subgraph group_intelligence["Graph intelligence"]
  node_lsp["Hybrid LSP<br/>[lsp_all.c]"]
  node_service_links["Service linking<br/>[service_patterns.c]"]
  node_graph_store[("Persistent graph<br/>[sqlite_writer.c]")]
  node_mcp_tools["Analysis tools<br/>[main.c]"]
end

subgraph group_exploration["Graph exploration"]
  node_ui["Graph UI<br/>[App.tsx]"]
  node_ui_rpc["UI RPC client<br/>[rpc.ts]"]
  node_graph_view["Graph visualization<br/>[GraphScene.tsx]"]
  node_stats["Project statistics<br/>[StatsTab.tsx]"]
  node_controls["Graph controls<br/>[ControlTab.tsx]"]
end

node_agent(("Coding agent"))
node_repo["Local repository"]

node_agent -->|"sends requests"| node_mcp
node_agent_setup -->|"configures client"| node_agent
node_mcp -->|"opens sessions"| node_daemon
node_daemon -->|"starts index jobs"| node_pipeline
node_pipeline -->|"reads source"| node_repo
node_pipeline -->|"parses languages"| node_grammars
node_pipeline -->|"extracts facts"| node_extraction
node_pipeline -->|"resolves symbols"| node_lsp
node_pipeline -->|"classifies calls"| node_service_links
node_pipeline -->|"writes graph"| node_graph_store
node_pipeline -->|"uses stored hashes"| node_incremental
node_incremental -->|"stages repairs"| node_delta
node_incremental -->|"updates graph"| node_graph_store
node_mcp -->|"dispatches tools"| node_mcp_tools
node_mcp_tools -->|"queries graph"| node_graph_store
node_agent -->|"opens visualization"| node_ui
node_ui -->|"requests data"| node_ui_rpc
node_ui_rpc -->|"calls local API"| node_local_api
node_ui -->|"renders graph"| node_graph_view
node_ui -->|"shows statistics"| node_stats
node_ui -->|"shows controls"| node_controls

click node_mcp "https://github.com/gurdeepsinghiet/codebase-memory-mcp/blob/main/src/main.c"
click node_agent_setup "https://github.com/gurdeepsinghiet/codebase-memory-mcp/blob/main/src/cli/agent_clients.c"
click node_daemon "https://github.com/gurdeepsinghiet/codebase-memory-mcp/blob/main/src/daemon/application.c"
click node_pipeline "https://github.com/gurdeepsinghiet/codebase-memory-mcp/blob/main/src/pipeline/pipeline.c"
click node_incremental "https://github.com/gurdeepsinghiet/codebase-memory-mcp/blob/main/src/pipeline/pipeline_incremental.c"
click node_delta "https://github.com/gurdeepsinghiet/codebase-memory-mcp/blob/main/src/pipeline/pipeline_delta.c"
click node_grammars "https://github.com/gurdeepsinghiet/codebase-memory-mcp/blob/main/internal/cbm/grammar_typescript.c"
click node_extraction "https://github.com/gurdeepsinghiet/codebase-memory-mcp/blob/main/internal/cbm/extract_unified.c"
click node_lsp "https://github.com/gurdeepsinghiet/codebase-memory-mcp/blob/main/internal/cbm/lsp_all.c"
click node_service_links "https://github.com/gurdeepsinghiet/codebase-memory-mcp/blob/main/internal/cbm/service_patterns.c"
click node_graph_store "https://github.com/gurdeepsinghiet/codebase-memory-mcp/blob/main/internal/cbm/sqlite_writer.c"
click node_mcp_tools "https://github.com/gurdeepsinghiet/codebase-memory-mcp/blob/main/src/main.c"
click node_ui "https://github.com/gurdeepsinghiet/codebase-memory-mcp/blob/main/graph-ui/src/App.tsx"
click node_ui_rpc "https://github.com/gurdeepsinghiet/codebase-memory-mcp/blob/main/graph-ui/src/api/rpc.ts"
click node_graph_view "https://github.com/gurdeepsinghiet/codebase-memory-mcp/blob/main/graph-ui/src/components/GraphScene.tsx"
click node_stats "https://github.com/gurdeepsinghiet/codebase-memory-mcp/blob/main/graph-ui/src/components/StatsTab.tsx"
click node_controls "https://github.com/gurdeepsinghiet/codebase-memory-mcp/blob/main/graph-ui/src/components/ControlTab.tsx"
click node_local_api "https://github.com/gurdeepsinghiet/codebase-memory-mcp/tree/main/src"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_mcp,node_agent_setup,node_daemon,node_local_api toneBlue
class node_pipeline,node_incremental,node_delta,node_grammars,node_extraction toneAmber
class node_lsp,node_service_links,node_graph_store,node_mcp_tools toneMint
class node_ui,node_ui_rpc,node_graph_view,node_stats,node_controls toneRose
class node_agent,node_repo toneIndigo
```

## Components

### Agent and UI

- [MCP server](https://github.com/gurdeepsinghiet/codebase-memory-mcp/blob/main/src/main.c): `src/main.c`
- [Client setup](https://github.com/gurdeepsinghiet/codebase-memory-mcp/blob/main/src/cli/agent_clients.c): `src/cli/agent_clients.c`
- [Session daemon](https://github.com/gurdeepsinghiet/codebase-memory-mcp/blob/main/src/daemon/application.c): `src/daemon/application.c`
- [Local UI API](https://github.com/gurdeepsinghiet/codebase-memory-mcp/tree/main/src): `src`

### Indexing pipeline

- [Index orchestrator](https://github.com/gurdeepsinghiet/codebase-memory-mcp/blob/main/src/pipeline/pipeline.c): `src/pipeline/pipeline.c`
- [Incremental indexing](https://github.com/gurdeepsinghiet/codebase-memory-mcp/blob/main/src/pipeline/pipeline_incremental.c): `src/pipeline/pipeline_incremental.c`
- [Delta repair](https://github.com/gurdeepsinghiet/codebase-memory-mcp/blob/main/src/pipeline/pipeline_delta.c): `src/pipeline/pipeline_delta.c`
- [Language grammars](https://github.com/gurdeepsinghiet/codebase-memory-mcp/blob/main/internal/cbm/grammar_typescript.c): `internal/cbm/grammar_typescript.c`
- [Fact extraction](https://github.com/gurdeepsinghiet/codebase-memory-mcp/blob/main/internal/cbm/extract_unified.c): `internal/cbm/extract_unified.c`

### Graph intelligence

- [Hybrid LSP](https://github.com/gurdeepsinghiet/codebase-memory-mcp/blob/main/internal/cbm/lsp_all.c): `internal/cbm/lsp_all.c`
- [Service linking](https://github.com/gurdeepsinghiet/codebase-memory-mcp/blob/main/internal/cbm/service_patterns.c): `internal/cbm/service_patterns.c`
- [Persistent graph](https://github.com/gurdeepsinghiet/codebase-memory-mcp/blob/main/internal/cbm/sqlite_writer.c): `internal/cbm/sqlite_writer.c`
- [Analysis tools](https://github.com/gurdeepsinghiet/codebase-memory-mcp/blob/main/src/main.c): `src/main.c`

### Graph exploration

- [Graph UI](https://github.com/gurdeepsinghiet/codebase-memory-mcp/blob/main/graph-ui/src/App.tsx): `graph-ui/src/App.tsx`
- [UI RPC client](https://github.com/gurdeepsinghiet/codebase-memory-mcp/blob/main/graph-ui/src/api/rpc.ts): `graph-ui/src/api/rpc.ts`
- [Graph visualization](https://github.com/gurdeepsinghiet/codebase-memory-mcp/blob/main/graph-ui/src/components/GraphScene.tsx): `graph-ui/src/components/GraphScene.tsx`
- [Project statistics](https://github.com/gurdeepsinghiet/codebase-memory-mcp/blob/main/graph-ui/src/components/StatsTab.tsx): `graph-ui/src/components/StatsTab.tsx`
- [Graph controls](https://github.com/gurdeepsinghiet/codebase-memory-mcp/blob/main/graph-ui/src/components/ControlTab.tsx): `graph-ui/src/components/ControlTab.tsx`

### Other components

- **Coding agent**
- **Local repository**

## Connections

- Coding agent → MCP server: sends requests
- Client setup → Coding agent: configures client
- MCP server → Session daemon: opens sessions
- Session daemon → Index orchestrator: starts index jobs
- Index orchestrator → Local repository: reads source
- Index orchestrator → Language grammars: parses languages
- Index orchestrator → Fact extraction: extracts facts
- Index orchestrator → Hybrid LSP: resolves symbols
- Index orchestrator → Service linking: classifies calls
- Index orchestrator → Persistent graph: writes graph
- Index orchestrator → Incremental indexing: uses stored hashes
- Incremental indexing → Delta repair: stages repairs
- Incremental indexing → Persistent graph: updates graph
- MCP server → Analysis tools: dispatches tools
- Analysis tools → Persistent graph: queries graph
- Coding agent → Graph UI: opens visualization
- Graph UI → UI RPC client: requests data
- UI RPC client → Local UI API: calls local API
- Graph UI → Graph visualization: renders graph
- Graph UI → Project statistics: shows statistics
- Graph UI → Graph controls: shows controls
