# mr1823/gitcontext architecture

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

- Interactive diagram: https://gitdiagram.com/mr1823/gitcontext
- Repository: https://github.com/mr1823/gitcontext

## Overview

GitContext indexes a local repository’s source, documentation, Git history, and optional GitHub discussions, then retrieves cited evidence and optionally synthesizes an answer. The principal workflow is scan and parse → chunk and enrich → persist → retrieve/rerank → answer, exposed through CLI and browser/API entry points. Evaluation is a separate product capability. Edges follow shown calls or README-documented behavior; unsampled modules are represented only where their role is documented or their relationship appears in the source index.

Main entry points: [`src/gitcontext/indexer.py`](https://github.com/mr1823/gitcontext/blob/main/src/gitcontext/indexer.py) (Index workflow), [`src/gitcontext/cli.py`](https://github.com/mr1823/gitcontext/blob/main/src/gitcontext/cli.py) (CLI commands), [`src/gitcontext/web.py`](https://github.com/mr1823/gitcontext/blob/main/src/gitcontext/web.py) (FastAPI service), [`src/gitcontext/retrieval.py`](https://github.com/mr1823/gitcontext/blob/main/src/gitcontext/retrieval.py) (Hybrid retrieval)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_entry["User interfaces"]
  node_cli["CLI commands<br/>[cli.py]"]
  node_webui["Browser UI<br/>[app.js]"]
  node_webapi["FastAPI service<br/>[web.py]"]
end

subgraph group_ingest["Repository ingestion"]
  node_scanner["Repository scanner<br/>[repository.py]"]
  node_parser["Source parser<br/>[parser.py]"]
  node_chunking["Content chunking<br/>[chunking.py]"]
  node_history["Git history<br/>[history.py]"]
  node_github["GitHub ingestion<br/>[github.py]"]
end

subgraph group_index["Index and retrieval"]
  node_settings["Runtime settings<br/>[config.py]"]
  node_indexer["Index workflow<br/>[indexer.py]"]
  node_embeddings["Local embeddings<br/>[embeddings.py]"]
  node_store["Persistent index<br/>[vector_store.py]"]
  node_sqlite[("SQLite index")]
  node_qdrant[("Qdrant vectors")]
end

subgraph group_answer["Answer and evaluation"]
  node_retrieval["Hybrid retrieval<br/>[retrieval.py]"]
  node_answerer["Cited answer<br/>[answer.py]"]
  node_evaluation["Retrieval evaluation<br/>[evaluation.py]"]
end

node_developer(("Developer"))
node_github_service["GitHub API"]
node_llm["Chat endpoint"]

node_developer -->|"runs commands"| node_cli
node_developer -->|"uses browser"| node_webui
node_webui -->|"sends requests"| node_webapi
node_cli -->|"scans repository"| node_scanner
node_cli -->|"indexes repository"| node_indexer
node_webapi -->|"scans repository"| node_scanner
node_webapi -->|"indexes repository"| node_indexer
node_indexer -->|"loads settings"| node_settings
node_indexer -->|"finds source files"| node_scanner
node_indexer -->|"parses files"| node_parser
node_indexer -->|"chunks content"| node_chunking
node_indexer -->|"collects commits"| node_history
node_indexer -->|"fetches discussions"| node_github
node_github -->|"requests records"| node_github_service
node_indexer -->|"embeds chunks"| node_embeddings
node_indexer -->|"writes index"| node_store
node_store -->|"persists metadata"| node_sqlite
node_store -->|"syncs vectors"| node_qdrant
node_cli -->|"retrieves evidence"| node_retrieval
node_webapi -->|"retrieves evidence"| node_retrieval
node_retrieval -->|"reads chunks"| node_store
node_retrieval -->|"encodes query"| node_embeddings
node_cli -->|"answers question"| node_answerer
node_webapi -->|"answers question"| node_answerer
node_answerer -->|"uses endpoint settings"| node_settings
node_answerer -->|"synthesizes answer"| node_llm
node_cli -->|"scores retrieval"| node_evaluation
node_evaluation -->|"evaluates results"| node_retrieval

click node_cli "https://github.com/mr1823/gitcontext/blob/main/src/gitcontext/cli.py"
click node_webui "https://github.com/mr1823/gitcontext/blob/main/src/gitcontext/static/app.js"
click node_webapi "https://github.com/mr1823/gitcontext/blob/main/src/gitcontext/web.py"
click node_settings "https://github.com/mr1823/gitcontext/blob/main/src/gitcontext/config.py"
click node_scanner "https://github.com/mr1823/gitcontext/blob/main/src/gitcontext/ingest/repository.py"
click node_parser "https://github.com/mr1823/gitcontext/blob/main/src/gitcontext/ingest/parser.py"
click node_chunking "https://github.com/mr1823/gitcontext/blob/main/src/gitcontext/chunking.py"
click node_history "https://github.com/mr1823/gitcontext/blob/main/src/gitcontext/ingest/history.py"
click node_github "https://github.com/mr1823/gitcontext/blob/main/src/gitcontext/ingest/github.py"
click node_indexer "https://github.com/mr1823/gitcontext/blob/main/src/gitcontext/indexer.py"
click node_embeddings "https://github.com/mr1823/gitcontext/blob/main/src/gitcontext/embeddings.py"
click node_store "https://github.com/mr1823/gitcontext/blob/main/src/gitcontext/vector_store.py"
click node_retrieval "https://github.com/mr1823/gitcontext/blob/main/src/gitcontext/retrieval.py"
click node_answerer "https://github.com/mr1823/gitcontext/blob/main/src/gitcontext/answer.py"
click node_evaluation "https://github.com/mr1823/gitcontext/blob/main/src/gitcontext/evaluation.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_cli,node_webui,node_webapi toneBlue
class node_scanner,node_parser,node_chunking,node_history,node_github toneAmber
class node_settings,node_indexer,node_embeddings,node_store,node_sqlite,node_qdrant,node_github_service toneMint
class node_retrieval,node_answerer,node_evaluation toneRose
class node_developer,node_llm toneIndigo
```

## Components

### User interfaces

- [CLI commands](https://github.com/mr1823/gitcontext/blob/main/src/gitcontext/cli.py): `src/gitcontext/cli.py`
- [Browser UI](https://github.com/mr1823/gitcontext/blob/main/src/gitcontext/static/app.js): `src/gitcontext/static/app.js`
- [FastAPI service](https://github.com/mr1823/gitcontext/blob/main/src/gitcontext/web.py): `src/gitcontext/web.py`

### Repository ingestion

- [Repository scanner](https://github.com/mr1823/gitcontext/blob/main/src/gitcontext/ingest/repository.py): `src/gitcontext/ingest/repository.py`
- [Source parser](https://github.com/mr1823/gitcontext/blob/main/src/gitcontext/ingest/parser.py): `src/gitcontext/ingest/parser.py`
- [Content chunking](https://github.com/mr1823/gitcontext/blob/main/src/gitcontext/chunking.py): `src/gitcontext/chunking.py`
- [Git history](https://github.com/mr1823/gitcontext/blob/main/src/gitcontext/ingest/history.py): `src/gitcontext/ingest/history.py`
- [GitHub ingestion](https://github.com/mr1823/gitcontext/blob/main/src/gitcontext/ingest/github.py): `src/gitcontext/ingest/github.py`

### Index and retrieval

- [Runtime settings](https://github.com/mr1823/gitcontext/blob/main/src/gitcontext/config.py): `src/gitcontext/config.py`
- [Index workflow](https://github.com/mr1823/gitcontext/blob/main/src/gitcontext/indexer.py): `src/gitcontext/indexer.py`
- [Local embeddings](https://github.com/mr1823/gitcontext/blob/main/src/gitcontext/embeddings.py): `src/gitcontext/embeddings.py`
- [Persistent index](https://github.com/mr1823/gitcontext/blob/main/src/gitcontext/vector_store.py): `src/gitcontext/vector_store.py`
- **SQLite index**
- **Qdrant vectors**

### Answer and evaluation

- [Hybrid retrieval](https://github.com/mr1823/gitcontext/blob/main/src/gitcontext/retrieval.py): `src/gitcontext/retrieval.py`
- [Cited answer](https://github.com/mr1823/gitcontext/blob/main/src/gitcontext/answer.py): `src/gitcontext/answer.py`
- [Retrieval evaluation](https://github.com/mr1823/gitcontext/blob/main/src/gitcontext/evaluation.py): `src/gitcontext/evaluation.py`

### Other components

- **Developer**
- **GitHub API**
- **Chat endpoint**

## Connections

- Developer → CLI commands: runs commands (evidence: `README.md`)
- Developer → Browser UI: uses browser (evidence: `README.md`)
- Browser UI → FastAPI service: sends requests (evidence: `README.md`)
- CLI commands → Repository scanner: scans repository (evidence: `src/gitcontext/cli.py`)
- CLI commands → Index workflow: indexes repository (evidence: `src/gitcontext/cli.py`)
- FastAPI service → Repository scanner: scans repository (evidence: `src/gitcontext/web.py`)
- FastAPI service → Index workflow: indexes repository (evidence: `src/gitcontext/web.py`)
- Index workflow → Runtime settings: loads settings (evidence: `src/gitcontext/indexer.py`)
- Index workflow → Repository scanner: finds source files (evidence: `src/gitcontext/indexer.py`)
- Index workflow → Source parser: parses files (evidence: `src/gitcontext/indexer.py`)
- Index workflow → Content chunking: chunks content (evidence: `src/gitcontext/indexer.py`)
- Index workflow → Git history: collects commits (evidence: `src/gitcontext/indexer.py`)
- Index workflow → GitHub ingestion: fetches discussions (evidence: `src/gitcontext/indexer.py`)
- GitHub ingestion → GitHub API: requests records (evidence: `src/gitcontext/ingest/github.py`)
- Index workflow → Local embeddings: embeds chunks (evidence: `src/gitcontext/indexer.py`)
- Index workflow → Persistent index: writes index (evidence: `src/gitcontext/indexer.py`)
- Persistent index → SQLite index: persists metadata (evidence: `src/gitcontext/vector_store.py`)
- Persistent index → Qdrant vectors: syncs vectors (evidence: `src/gitcontext/vector_store.py`)
- CLI commands → Hybrid retrieval: retrieves evidence (evidence: `src/gitcontext/cli.py`)
- FastAPI service → Hybrid retrieval: retrieves evidence (evidence: `src/gitcontext/web.py`)
- Hybrid retrieval → Persistent index: reads chunks (evidence: `src/gitcontext/retrieval.py`)
- Hybrid retrieval → Local embeddings: encodes query (evidence: `src/gitcontext/retrieval.py`)
- CLI commands → Cited answer: answers question (evidence: `src/gitcontext/cli.py`)
- FastAPI service → Cited answer: answers question (evidence: `src/gitcontext/web.py`)
- Cited answer → Runtime settings: uses endpoint settings (evidence: `src/gitcontext/answer.py`)
- Cited answer → Chat endpoint: synthesizes answer (evidence: `src/gitcontext/answer.py`)
- CLI commands → Retrieval evaluation: scores retrieval (evidence: `src/gitcontext/cli.py`)
- Retrieval evaluation → Hybrid retrieval: evaluates results (evidence: `src/gitcontext/cli.py`)
