# james-chahwan/repo-graph architecture

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

- Interactive diagram: https://gitdiagram.com/james-chahwan/repo-graph
- Repository: https://github.com/james-chahwan/repo-graph

## Overview

repo-graph is an MCP server that gives AI coding assistants a structural map of a codebase. The main workflow is: an agent asks for orientation, search, impact, trace, source reading, or refresh; the server delegates graph operations to the glia engine through a thin graph wrapper and returns navigable results. The graph is cached and can be refreshed on edits. A separate installer wires the server into coding agents, with optional Git-hook support. The README documents the tool capabilities; unsampled server logic limits detail on individual tool-to-engine calls.

Main entry points: [`repo_graph/server.py`](https://github.com/james-chahwan/repo-graph/blob/main/repo_graph/server.py) (MCP tools), [`repo_graph/installer/core.py`](https://github.com/james-chahwan/repo-graph/blob/main/repo_graph/installer/core.py) (Install orchestration), [`repo_graph/installer/targets.py`](https://github.com/james-chahwan/repo-graph/blob/main/repo_graph/installer/targets.py) (Agent targets), [`repo_graph/installer/githook.py`](https://github.com/james-chahwan/repo-graph/blob/main/repo_graph/installer/githook.py) (Pre-commit hook)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_query["MCP navigation"]
  node_mcp["MCP tools<br/>[server.py]"]
  node_graph["Graph wrapper<br/>[graph.py]"]
end

subgraph group_engine["Graph engine"]
  node_engine_core["glia engine"]
  node_graph_cache[("Graph cache")]
end

subgraph group_freshness["Graph freshness"]
  node_watcher["File watcher<br/>[watcher.py]"]
  node_git_exclude["Cache exclusion<br/>[gitexclude.py]"]
  node_init_cli["Graph initializer<br/>[init.py]"]
end

subgraph group_install["Agent installation"]
  node_installer_cli["Install orchestration<br/>[core.py]"]
  node_agent_targets["Agent targets<br/>[targets.py]"]
  node_config_io["Config file I/O<br/>[fileio.py]"]
  node_instruction_markers["Instruction markers<br/>[markers.py]"]
  node_git_hook["Pre-commit hook<br/>[githook.py]"]
end

node_agent(("Coding assistant"))
node_codebase["Target codebase"]
node_git_metadata[("Git metadata")]

node_agent -->|"requests tools"| node_mcp
node_mcp -->|"delegates graph work"| node_graph
node_graph -->|"forwards lookups"| node_engine_core
node_codebase -->|"builds graph from"| node_engine_core
node_engine_core -->|"stores graph"| node_graph_cache
node_mcp -->|"starts watcher"| node_watcher
node_watcher -->|"triggers rebuild callback"| node_mcp
node_mcp -->|"excludes cache"| node_git_exclude
node_agent -->|"runs install"| node_installer_cli
node_installer_cli -->|"runs target actions"| node_agent_targets
node_agent_targets -->|"writes configuration"| node_config_io
node_agent_targets -->|"updates instructions"| node_instruction_markers
node_installer_cli -->|"installs optional hook"| node_git_hook
node_git_hook -->|"runs graph initializer"| node_init_cli
node_git_hook -->|"uses hook marker"| node_git_exclude
node_git_exclude -->|"updates local exclusion"| node_git_metadata

click node_mcp "https://github.com/james-chahwan/repo-graph/blob/main/repo_graph/server.py"
click node_graph "https://github.com/james-chahwan/repo-graph/blob/main/repo_graph/graph.py"
click node_watcher "https://github.com/james-chahwan/repo-graph/blob/main/repo_graph/watcher.py"
click node_git_exclude "https://github.com/james-chahwan/repo-graph/blob/main/repo_graph/gitexclude.py"
click node_installer_cli "https://github.com/james-chahwan/repo-graph/blob/main/repo_graph/installer/core.py"
click node_agent_targets "https://github.com/james-chahwan/repo-graph/blob/main/repo_graph/installer/targets.py"
click node_config_io "https://github.com/james-chahwan/repo-graph/blob/main/repo_graph/installer/fileio.py"
click node_instruction_markers "https://github.com/james-chahwan/repo-graph/blob/main/repo_graph/installer/markers.py"
click node_git_hook "https://github.com/james-chahwan/repo-graph/blob/main/repo_graph/installer/githook.py"
click node_init_cli "https://github.com/james-chahwan/repo-graph/blob/main/repo_graph/init.py"

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_graph toneBlue
class node_engine_core,node_graph_cache,node_git_metadata toneAmber
class node_watcher,node_git_exclude,node_init_cli toneMint
class node_installer_cli,node_agent_targets,node_config_io,node_instruction_markers,node_git_hook toneRose
class node_agent,node_codebase toneIndigo
```

## Components

### MCP navigation

- [MCP tools](https://github.com/james-chahwan/repo-graph/blob/main/repo_graph/server.py): `repo_graph/server.py`
- [Graph wrapper](https://github.com/james-chahwan/repo-graph/blob/main/repo_graph/graph.py): `repo_graph/graph.py`

### Graph engine

- **glia engine**
- **Graph cache**

### Graph freshness

- [File watcher](https://github.com/james-chahwan/repo-graph/blob/main/repo_graph/watcher.py): `repo_graph/watcher.py`
- [Cache exclusion](https://github.com/james-chahwan/repo-graph/blob/main/repo_graph/gitexclude.py): `repo_graph/gitexclude.py`
- [Graph initializer](https://github.com/james-chahwan/repo-graph/blob/main/repo_graph/init.py): `repo_graph/init.py`

### Agent installation

- [Install orchestration](https://github.com/james-chahwan/repo-graph/blob/main/repo_graph/installer/core.py): `repo_graph/installer/core.py`
- [Agent targets](https://github.com/james-chahwan/repo-graph/blob/main/repo_graph/installer/targets.py): `repo_graph/installer/targets.py`
- [Config file I/O](https://github.com/james-chahwan/repo-graph/blob/main/repo_graph/installer/fileio.py): `repo_graph/installer/fileio.py`
- [Instruction markers](https://github.com/james-chahwan/repo-graph/blob/main/repo_graph/installer/markers.py): `repo_graph/installer/markers.py`
- [Pre-commit hook](https://github.com/james-chahwan/repo-graph/blob/main/repo_graph/installer/githook.py): `repo_graph/installer/githook.py`

### Other components

- **Coding assistant**
- **Target codebase**
- **Git metadata**

## Connections

- Coding assistant → MCP tools: requests tools (evidence: `README.md`)
- MCP tools → Graph wrapper: delegates graph work (evidence: `repo_graph/server.py`)
- Graph wrapper → glia engine: forwards lookups (evidence: `repo_graph/graph.py`)
- Target codebase → glia engine: builds graph from (evidence: `README.md`)
- glia engine → Graph cache: stores graph (evidence: `README.md`)
- MCP tools → File watcher: starts watcher (evidence: `repo_graph/server.py`)
- File watcher → MCP tools: triggers rebuild callback (evidence: `repo_graph/watcher.py`)
- MCP tools → Cache exclusion: excludes cache (evidence: `repo_graph/server.py`)
- Coding assistant → Install orchestration: runs install (evidence: `README.md`)
- Install orchestration → Agent targets: runs target actions (evidence: `repo_graph/installer/core.py`)
- Agent targets → Config file I/O: writes configuration (evidence: `repo_graph/installer/targets.py`)
- Agent targets → Instruction markers: updates instructions (evidence: `repo_graph/installer/targets.py`)
- Install orchestration → Pre-commit hook: installs optional hook (evidence: `repo_graph/installer/core.py`)
- Pre-commit hook → Graph initializer: runs graph initializer (evidence: `repo_graph/installer/githook.py`)
- Pre-commit hook → Cache exclusion: uses hook marker (evidence: `repo_graph/installer/githook.py`)
- Cache exclusion → Git metadata: updates local exclusion (evidence: `repo_graph/gitexclude.py`)
