# vivacity5x/rubberduck.ai architecture

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

- Interactive diagram: https://gitdiagram.com/vivacity5x/rubberduck.ai
- Repository: https://github.com/vivacity5x/rubberduck.ai

## Overview

RubberDuck.ai indexes Python repositories and answers code questions, drafts changes, or writes documentation with file-and-line citations. Users enter through the web UI, REST API, or CLI; requests retrieve relevant indexed chunks and send them to an LLM for a cited result. The ingestion workflow syncs GitHub files, parses them into semantic chunks, and updates vector, keyword, and call-graph indexes. The graph reflects documented capabilities and shown call relationships; unsampled CLI and UI details are limited to README-level links.

Main entry points: [`rubberduck/index.py`](https://github.com/vivacity5x/rubberduck.ai/blob/main/rubberduck/index.py) (Repository index), [`rubberduck/sync_api.py`](https://github.com/vivacity5x/rubberduck.ai/blob/main/rubberduck/sync_api.py) (GitHub sync), [`rubberduck/server.py`](https://github.com/vivacity5x/rubberduck.ai/blob/main/rubberduck/server.py) (REST API), [`rubberduck/retrieve.py`](https://github.com/vivacity5x/rubberduck.ai/blob/main/rubberduck/retrieve.py) (Hybrid retrieval)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_interfaces["User interfaces"]
  node_webui["Web UI<br/>[index.html]"]
  node_api["REST API<br/>[server.py]"]
  node_cli["CLI<br/>[__main__.py]"]
end

subgraph group_ingestion["Repository ingestion"]
  node_settings["Settings<br/>[config.py]"]
  node_sync["GitHub sync<br/>[sync_api.py]"]
  node_parser["AST parser<br/>[ast_parser.py]"]
end

subgraph group_indexing["Code indexing"]
  node_chunks["Code chunks<br/>[models.py]"]
  node_index[("Repository index<br/>[index.py]")]
  node_vectors[("Vector embeddings<br/>[index.py]")]
  node_keywords[("BM25 search<br/>[index.py]")]
  node_tokenizer["Code tokenizer<br/>[text.py]"]
  node_callgraph["Call graph<br/>[graph.py]"]
end

subgraph group_answering["Retrieval and answers"]
  node_result["Cited result<br/>[generate.py]"]
  node_retriever["Hybrid retrieval<br/>[retrieve.py]"]
  node_generator["Answer generation<br/>[generate.py]"]
end

node_developer(("Developer"))
node_github[("GitHub API")]
node_llm{{"OpenAI-compatible LLM"}}
node_webhook(("GitHub push"))

node_developer -->|"submits query"| node_webui
node_developer -->|"calls API"| node_api
node_developer -->|"runs command"| node_cli
node_webui -->|"sends requests"| node_api
node_api -->|"indexes repo"| node_sync
node_cli -->|"syncs repo"| node_sync
node_webhook -->|"notifies push"| node_api
node_api -->|"resyncs push"| node_sync
node_sync -->|"fetches files"| node_github
node_sync -->|"parses changes"| node_parser
node_parser -->|"creates chunks"| node_chunks
node_sync -->|"updates chunks"| node_index
node_index -->|"stores embeddings"| node_vectors
node_index -->|"builds rankings"| node_keywords
node_index -->|"tokenizes chunks"| node_tokenizer
node_index -->|"builds graph"| node_callgraph
node_api -->|"retrieves context"| node_retriever
node_retriever -->|"searches index"| node_index
node_retriever -->|"expands neighbors"| node_callgraph
node_retriever -->|"passes chunks"| node_generator
node_generator -->|"requests completion"| node_llm
node_generator -->|"returns cited answer"| node_result
node_settings -->|"configures sync"| node_sync
node_settings -->|"configures index"| node_index
node_settings -->|"configures model"| node_generator

click node_result "https://github.com/vivacity5x/rubberduck.ai/blob/main/rubberduck/generate.py"
click node_webui "https://github.com/vivacity5x/rubberduck.ai/blob/main/rubberduck/static/index.html"
click node_api "https://github.com/vivacity5x/rubberduck.ai/blob/main/rubberduck/server.py"
click node_cli "https://github.com/vivacity5x/rubberduck.ai/blob/main/rubberduck/__main__.py"
click node_settings "https://github.com/vivacity5x/rubberduck.ai/blob/main/rubberduck/config.py"
click node_sync "https://github.com/vivacity5x/rubberduck.ai/blob/main/rubberduck/sync_api.py"
click node_parser "https://github.com/vivacity5x/rubberduck.ai/blob/main/rubberduck/ast_parser.py"
click node_chunks "https://github.com/vivacity5x/rubberduck.ai/blob/main/rubberduck/models.py"
click node_index "https://github.com/vivacity5x/rubberduck.ai/blob/main/rubberduck/index.py"
click node_vectors "https://github.com/vivacity5x/rubberduck.ai/blob/main/rubberduck/index.py"
click node_keywords "https://github.com/vivacity5x/rubberduck.ai/blob/main/rubberduck/index.py"
click node_tokenizer "https://github.com/vivacity5x/rubberduck.ai/blob/main/rubberduck/text.py"
click node_callgraph "https://github.com/vivacity5x/rubberduck.ai/blob/main/rubberduck/graph.py"
click node_retriever "https://github.com/vivacity5x/rubberduck.ai/blob/main/rubberduck/retrieve.py"
click node_generator "https://github.com/vivacity5x/rubberduck.ai/blob/main/rubberduck/generate.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_webui,node_api,node_cli toneBlue
class node_settings,node_sync,node_parser,node_github toneAmber
class node_chunks,node_index,node_vectors,node_keywords,node_tokenizer,node_callgraph toneMint
class node_result,node_retriever,node_generator toneRose
class node_developer,node_llm,node_webhook toneIndigo
```

## Components

### User interfaces

- [Web UI](https://github.com/vivacity5x/rubberduck.ai/blob/main/rubberduck/static/index.html): `rubberduck/static/index.html`
- [REST API](https://github.com/vivacity5x/rubberduck.ai/blob/main/rubberduck/server.py): `rubberduck/server.py`
- [CLI](https://github.com/vivacity5x/rubberduck.ai/blob/main/rubberduck/__main__.py): `rubberduck/__main__.py`

### Repository ingestion

- [Settings](https://github.com/vivacity5x/rubberduck.ai/blob/main/rubberduck/config.py): `rubberduck/config.py`
- [GitHub sync](https://github.com/vivacity5x/rubberduck.ai/blob/main/rubberduck/sync_api.py): `rubberduck/sync_api.py`
- [AST parser](https://github.com/vivacity5x/rubberduck.ai/blob/main/rubberduck/ast_parser.py): `rubberduck/ast_parser.py`

### Code indexing

- [Code chunks](https://github.com/vivacity5x/rubberduck.ai/blob/main/rubberduck/models.py): `rubberduck/models.py`
- [Repository index](https://github.com/vivacity5x/rubberduck.ai/blob/main/rubberduck/index.py): `rubberduck/index.py`
- [Vector embeddings](https://github.com/vivacity5x/rubberduck.ai/blob/main/rubberduck/index.py): `rubberduck/index.py`
- [BM25 search](https://github.com/vivacity5x/rubberduck.ai/blob/main/rubberduck/index.py): `rubberduck/index.py`
- [Code tokenizer](https://github.com/vivacity5x/rubberduck.ai/blob/main/rubberduck/text.py): `rubberduck/text.py`
- [Call graph](https://github.com/vivacity5x/rubberduck.ai/blob/main/rubberduck/graph.py): `rubberduck/graph.py`

### Retrieval and answers

- [Cited result](https://github.com/vivacity5x/rubberduck.ai/blob/main/rubberduck/generate.py): `rubberduck/generate.py`
- [Hybrid retrieval](https://github.com/vivacity5x/rubberduck.ai/blob/main/rubberduck/retrieve.py): `rubberduck/retrieve.py`
- [Answer generation](https://github.com/vivacity5x/rubberduck.ai/blob/main/rubberduck/generate.py): `rubberduck/generate.py`

### Other components

- **Developer**
- **GitHub API**
- **OpenAI-compatible LLM**
- **GitHub push**

## Connections

- Developer → Web UI: submits query (evidence: `README.md`)
- Developer → REST API: calls API (evidence: `README.md`)
- Developer → CLI: runs command (evidence: `README.md`)
- Web UI → REST API: sends requests (evidence: `README.md`)
- REST API → GitHub sync: indexes repo (evidence: `rubberduck/server.py`)
- CLI → GitHub sync: syncs repo (evidence: `rubberduck/__main__.py`)
- GitHub push → REST API: notifies push (evidence: `README.md`)
- REST API → GitHub sync: resyncs push (evidence: `rubberduck/server.py`)
- GitHub sync → GitHub API: fetches files (evidence: `rubberduck/sync_api.py`)
- GitHub sync → AST parser: parses changes (evidence: `rubberduck/sync_api.py`)
- AST parser → Code chunks: creates chunks (evidence: `rubberduck/ast_parser.py`)
- GitHub sync → Repository index: updates chunks (evidence: `rubberduck/sync_api.py`)
- Repository index → Vector embeddings: stores embeddings (evidence: `rubberduck/index.py`)
- Repository index → BM25 search: builds rankings (evidence: `rubberduck/index.py`)
- Repository index → Code tokenizer: tokenizes chunks (evidence: `rubberduck/index.py`)
- Repository index → Call graph: builds graph (evidence: `rubberduck/index.py`)
- REST API → Hybrid retrieval: retrieves context (evidence: `rubberduck/server.py`)
- Hybrid retrieval → Repository index: searches index (evidence: `rubberduck/retrieve.py`)
- Hybrid retrieval → Call graph: expands neighbors (evidence: `rubberduck/retrieve.py`)
- Hybrid retrieval → Answer generation: passes chunks (evidence: `rubberduck/server.py`)
- Answer generation → OpenAI-compatible LLM: requests completion (evidence: `rubberduck/generate.py`)
- Answer generation → Cited result: returns cited answer (evidence: `rubberduck/generate.py`)
- Settings → GitHub sync: configures sync (evidence: `rubberduck/sync_api.py`)
- Settings → Repository index: configures index (evidence: `rubberduck/index.py`)
- Settings → Answer generation: configures model (evidence: `rubberduck/generate.py`)
