# deusdata/codebase-memory-mcp architecture

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

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

## Overview

codebase-memory-mcp is a local code-intelligence service: an agent or CLI client requests repository context, the native server indexes source and surrounding configuration into a persistent graph, and MCP tools return focused search, relationship, and impact results. CBM Lens is the visual companion for reading source and exploring that graph. The main flow is documented in the README and supported by the source index; finer wiring for unsampled server and UI modules is left out or identified as documented rather than inferred.

Main entry points: [`graph-ui/src/App.tsx`](https://github.com/deusdata/codebase-memory-mcp/blob/main/graph-ui/src/App.tsx) (Lens Workspace), [`src/pipeline/pipeline.c`](https://github.com/deusdata/codebase-memory-mcp/blob/main/src/pipeline/pipeline.c) (Index Pipeline), [`src/main.c`](https://github.com/deusdata/codebase-memory-mcp/blob/main/src/main.c) (Native Entry), [`src/mcp/mcp.h`](https://github.com/deusdata/codebase-memory-mcp/blob/main/src/mcp/mcp.h) (MCP Tools)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_access["Agent Access"]
  node_main["Native Entry<br/>[main.c]"]
  node_daemon["Daemon Sessions<br/>[application.c]"]
  node_mcp["MCP Tools<br/>[mcp.h]"]
end

subgraph group_indexing["Repository Indexing"]
  node_discover["File Discovery<br/>[discover.h]"]
  node_pipeline["Index Pipeline<br/>[pipeline.c]"]
  node_incremental["Incremental Indexing"]
  node_language_analysis["Language Analysis"]
end

subgraph group_graph["Graph and Queries"]
  node_graph_store[("Persistent Graph<br/>[store.c]")]
  node_graph_queries["Graph Queries<br/>[cypher.c]"]
end

subgraph group_lens["CBM Lens"]
  node_lens_app["Lens Workspace<br/>[App.tsx]"]
  node_source_reader["Source Reader<br/>[MonacoReader.tsx]"]
  node_architecture_maps["Architecture Maps"]
  node_galaxy["Galaxy Explorer<br/>[GalaxyPanel.tsx]"]
  node_impact["Change Impact"]
  node_local_chat["Local Code Chat"]
  node_decisions["Architecture Decisions<br/>[AdrWorkspace.tsx]"]
end

subgraph group_setup["Client Setup"]
  node_client_setup["Client Integration<br/>[agent_clients.c]"]
end

node_agent(("Coding Agent"))
node_cli(("CLI Client"))
node_browser_model["On-device Model"]

node_agent -->|"starts server"| node_main
node_cli -->|"runs tools"| node_main
node_main -->|"starts sessions"| node_daemon
node_daemon -->|"serves requests"| node_mcp
node_mcp -.->|"requests indexing"| node_pipeline
node_pipeline -->|"discovers files"| node_discover
node_pipeline -.->|"extracts structure"| node_language_analysis
node_pipeline -->|"writes graph"| node_graph_store
node_incremental -->|"merges updates"| node_graph_store
node_agent -->|"installs integrations"| node_client_setup
node_main -->|"opens store"| node_graph_store
node_mcp -.->|"exposes queries"| node_graph_queries
node_agent -->|"explores repository"| node_lens_app
node_lens_app -->|"reads source"| node_source_reader
node_lens_app -->|"opens maps"| node_architecture_maps
node_lens_app -->|"opens graph"| node_galaxy
node_lens_app -->|"inspects changes"| node_impact
node_lens_app -->|"manages decisions"| node_decisions
node_lens_app -->|"asks about code"| node_local_chat
node_local_chat -.->|"optionally infers"| node_browser_model

click node_client_setup "https://github.com/deusdata/codebase-memory-mcp/blob/main/src/cli/agent_clients.c"
click node_main "https://github.com/deusdata/codebase-memory-mcp/blob/main/src/main.c"
click node_daemon "https://github.com/deusdata/codebase-memory-mcp/blob/main/src/daemon/application.c"
click node_mcp "https://github.com/deusdata/codebase-memory-mcp/blob/main/src/mcp/mcp.h"
click node_discover "https://github.com/deusdata/codebase-memory-mcp/blob/main/src/discover/discover.h"
click node_pipeline "https://github.com/deusdata/codebase-memory-mcp/blob/main/src/pipeline/pipeline.c"
click node_incremental "https://github.com/deusdata/codebase-memory-mcp/blob/main/src/pipeline/pipeline_incremental.c"
click node_language_analysis "https://github.com/deusdata/codebase-memory-mcp/tree/main/internal/cbm"
click node_graph_store "https://github.com/deusdata/codebase-memory-mcp/blob/main/src/store/store.c"
click node_graph_queries "https://github.com/deusdata/codebase-memory-mcp/blob/main/src/cypher/cypher.c"
click node_lens_app "https://github.com/deusdata/codebase-memory-mcp/blob/main/graph-ui/src/App.tsx"
click node_source_reader "https://github.com/deusdata/codebase-memory-mcp/blob/main/graph-ui/src/reader/MonacoReader.tsx"
click node_architecture_maps "https://github.com/deusdata/codebase-memory-mcp/blob/main/graph-ui/src/architecture/ArchitecturePanel.tsx"
click node_galaxy "https://github.com/deusdata/codebase-memory-mcp/blob/main/graph-ui/src/galaxy/GalaxyPanel.tsx"
click node_impact "https://github.com/deusdata/codebase-memory-mcp/blob/main/graph-ui/src/impact/ChangeAnalysisWorkspace.tsx"
click node_local_chat "https://github.com/deusdata/codebase-memory-mcp/blob/main/graph-ui/src/browser-ai/BrowserChatDock.tsx"
click node_decisions "https://github.com/deusdata/codebase-memory-mcp/blob/main/graph-ui/src/adr/AdrWorkspace.tsx"

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_main,node_daemon,node_mcp,node_cli toneBlue
class node_discover,node_pipeline,node_incremental,node_language_analysis toneAmber
class node_graph_store,node_graph_queries toneMint
class node_lens_app,node_source_reader,node_architecture_maps,node_galaxy,node_impact,node_local_chat,node_decisions toneRose
class node_client_setup,node_agent,node_browser_model toneIndigo
```

## Components

### Agent Access

- [Native Entry](https://github.com/deusdata/codebase-memory-mcp/blob/main/src/main.c): `src/main.c`
- [Daemon Sessions](https://github.com/deusdata/codebase-memory-mcp/blob/main/src/daemon/application.c): `src/daemon/application.c`
- [MCP Tools](https://github.com/deusdata/codebase-memory-mcp/blob/main/src/mcp/mcp.h): `src/mcp/mcp.h`

### Repository Indexing

- [File Discovery](https://github.com/deusdata/codebase-memory-mcp/blob/main/src/discover/discover.h): `src/discover/discover.h`
- [Index Pipeline](https://github.com/deusdata/codebase-memory-mcp/blob/main/src/pipeline/pipeline.c): `src/pipeline/pipeline.c`
- [Incremental Indexing](https://github.com/deusdata/codebase-memory-mcp/blob/main/src/pipeline/pipeline_incremental.c): `src/pipeline/pipeline_incremental.c`
- [Language Analysis](https://github.com/deusdata/codebase-memory-mcp/tree/main/internal/cbm): `internal/cbm`

### Graph and Queries

- [Persistent Graph](https://github.com/deusdata/codebase-memory-mcp/blob/main/src/store/store.c): `src/store/store.c`
- [Graph Queries](https://github.com/deusdata/codebase-memory-mcp/blob/main/src/cypher/cypher.c): `src/cypher/cypher.c`

### CBM Lens

- [Lens Workspace](https://github.com/deusdata/codebase-memory-mcp/blob/main/graph-ui/src/App.tsx): `graph-ui/src/App.tsx`
- [Source Reader](https://github.com/deusdata/codebase-memory-mcp/blob/main/graph-ui/src/reader/MonacoReader.tsx): `graph-ui/src/reader/MonacoReader.tsx`
- [Architecture Maps](https://github.com/deusdata/codebase-memory-mcp/blob/main/graph-ui/src/architecture/ArchitecturePanel.tsx): `graph-ui/src/architecture/ArchitecturePanel.tsx`
- [Galaxy Explorer](https://github.com/deusdata/codebase-memory-mcp/blob/main/graph-ui/src/galaxy/GalaxyPanel.tsx): `graph-ui/src/galaxy/GalaxyPanel.tsx`
- [Change Impact](https://github.com/deusdata/codebase-memory-mcp/blob/main/graph-ui/src/impact/ChangeAnalysisWorkspace.tsx): `graph-ui/src/impact/ChangeAnalysisWorkspace.tsx`
- [Local Code Chat](https://github.com/deusdata/codebase-memory-mcp/blob/main/graph-ui/src/browser-ai/BrowserChatDock.tsx): `graph-ui/src/browser-ai/BrowserChatDock.tsx`
- [Architecture Decisions](https://github.com/deusdata/codebase-memory-mcp/blob/main/graph-ui/src/adr/AdrWorkspace.tsx): `graph-ui/src/adr/AdrWorkspace.tsx`

### Client Setup

- [Client Integration](https://github.com/deusdata/codebase-memory-mcp/blob/main/src/cli/agent_clients.c): `src/cli/agent_clients.c`

### Other components

- **Coding Agent**
- **CLI Client**
- **On-device Model**

## Connections

- Coding Agent → Native Entry: starts server
- CLI Client → Native Entry: runs tools (evidence: `src/main.c`)
- Native Entry → Daemon Sessions: starts sessions (evidence: `src/main.c`)
- Daemon Sessions → MCP Tools: serves requests (evidence: `src/daemon/application.c`)
- MCP Tools → Index Pipeline: requests indexing
- Index Pipeline → File Discovery: discovers files (evidence: `src/pipeline/pipeline.c`)
- Index Pipeline → Language Analysis: extracts structure (evidence: `src/pipeline/pipeline.c`)
- Index Pipeline → Persistent Graph: writes graph (evidence: `src/pipeline/pipeline.c`)
- Incremental Indexing → Persistent Graph: merges updates (evidence: `src/pipeline/pipeline_incremental.c`)
- Coding Agent → Client Integration: installs integrations
- Native Entry → Persistent Graph: opens store (evidence: `src/main.c`)
- MCP Tools → Graph Queries: exposes queries
- Coding Agent → Lens Workspace: explores repository
- Lens Workspace → Source Reader: reads source (evidence: `graph-ui/src/App.tsx`)
- Lens Workspace → Architecture Maps: opens maps (evidence: `graph-ui/src/App.tsx`)
- Lens Workspace → Galaxy Explorer: opens graph
- Lens Workspace → Change Impact: inspects changes (evidence: `graph-ui/src/App.tsx`)
- Lens Workspace → Architecture Decisions: manages decisions (evidence: `graph-ui/src/App.tsx`)
- Lens Workspace → Local Code Chat: asks about code (evidence: `graph-ui/src/App.tsx`)
- Local Code Chat → On-device Model: optionally infers
