# aravind00006/codebase-rag architecture

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

- Interactive diagram: https://gitdiagram.com/aravind00006/codebase-rag
- Repository: https://github.com/aravind00006/codebase-rag

## Overview

Codebase RAG indexes a GitHub repository, then answers user questions with retrieved code and source citations. Its two principal workflows meet at the FastAPI backend: indexing loads and parses files, chunks them using a selectable strategy, and stores embeddings and a sparse index; querying retrieves candidates, fuses rankings, reranks results, builds a grounded prompt, and generates an answer. The README documents these stages and the UI/API capabilities. Some backend call sites and UI wiring were not sampled, so those links are omitted or marked unverified.

Main entry points: [`main.py`](https://github.com/aravind00006/codebase-rag/blob/main/main.py) (FastAPI backend), [`ingestion/embedder.py`](https://github.com/aravind00006/codebase-rag/blob/main/ingestion/embedder.py) (Embed and index), [`ingestion/file_parser.py`](https://github.com/aravind00006/codebase-rag/blob/main/ingestion/file_parser.py) (File parser), [`retrieval/hybrid_retriever.py`](https://github.com/aravind00006/codebase-rag/blob/main/retrieval/hybrid_retriever.py) (Hybrid retrieval)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_ingest["Repository indexing"]
  node_loader["Repository loader<br/>[repo_loader.py]"]
  node_parser["File parser<br/>[file_parser.py]"]
  node_fixed["Fixed chunker<br/>[fixed_size.py]"]
  node_recursive["Recursive chunker<br/>[recursive.py]"]
  node_ast["AST chunker<br/>[ast_based.py]"]
  node_semantic["Semantic chunker<br/>[semantic.py]"]
  node_embedder["Embed and index<br/>[embedder.py]"]
  node_vectors[("Chroma vectors")]
  node_bm25store[("BM25 index")]
end

subgraph group_retrieve["Search and ranking"]
  node_hybrid["Hybrid retrieval"]
  node_dense["Dense retrieval<br/>[dense_retriever.py]"]
  node_sparse["Sparse retrieval"]
  node_reranker["Cross-encoder reranker<br/>[reranker.py]"]
end

subgraph group_generate["Answer generation"]
  node_prompt["Prompt builder<br/>[prompt_builder.py]"]
  node_answer["Answer generator"]
end

subgraph group_access["User interfaces"]
  node_backend["FastAPI backend<br/>[main.py]"]
  node_frontend["Streamlit UI<br/>[app.py]"]
end

node_user(("Questioner"))
node_github(("GitHub repository"))
node_openai{{"OpenAI models"}}

node_user -.->|"asks through"| node_frontend
node_frontend -.->|"submits requests"| node_backend
node_user -.->|"calls API"| node_backend
node_backend -->|"loads repository"| node_loader
node_github -->|"provides source"| node_loader
node_loader -->|"returns documents"| node_parser
node_parser -.->|"parsed documents"| node_fixed
node_parser -.->|"parsed documents"| node_recursive
node_parser -.->|"parsed documents"| node_ast
node_parser -.->|"parsed documents"| node_semantic
node_backend -->|"selects strategy"| node_fixed
node_backend -->|"selects strategy"| node_recursive
node_backend -->|"selects strategy"| node_ast
node_backend -->|"selects strategy"| node_semantic
node_fixed -.->|"chunks documents"| node_embedder
node_recursive -.->|"chunks documents"| node_embedder
node_ast -.->|"chunks documents"| node_embedder
node_semantic -.->|"chunks documents"| node_embedder
node_embedder -->|"writes vectors"| node_vectors
node_embedder -->|"writes sparse index"| node_bm25store
node_backend -->|"retrieves candidates"| node_hybrid
node_hybrid -->|"requests candidates"| node_dense
node_hybrid -->|"requests candidates"| node_sparse
node_dense -.->|"queries vectors"| node_vectors
node_sparse -.->|"searches index"| node_bm25store
node_backend -.->|"reranks candidates"| node_reranker
node_backend -.->|"builds grounded prompt"| node_prompt
node_backend -.->|"generates response"| node_answer
node_prompt -->|"supplies prompts"| node_answer
node_answer -->|"invokes model"| node_openai
node_backend -->|"returns cited answer"| node_user

click node_backend "https://github.com/aravind00006/codebase-rag/blob/main/main.py"
click node_frontend "https://github.com/aravind00006/codebase-rag/blob/main/frontend/app.py"
click node_loader "https://github.com/aravind00006/codebase-rag/blob/main/ingestion/repo_loader.py"
click node_parser "https://github.com/aravind00006/codebase-rag/blob/main/ingestion/file_parser.py"
click node_fixed "https://github.com/aravind00006/codebase-rag/blob/main/ingestion/chunkers/fixed_size.py"
click node_recursive "https://github.com/aravind00006/codebase-rag/blob/main/ingestion/chunkers/recursive.py"
click node_ast "https://github.com/aravind00006/codebase-rag/blob/main/ingestion/chunkers/ast_based.py"
click node_semantic "https://github.com/aravind00006/codebase-rag/blob/main/ingestion/chunkers/semantic.py"
click node_embedder "https://github.com/aravind00006/codebase-rag/blob/main/ingestion/embedder.py"
click node_hybrid "https://github.com/aravind00006/codebase-rag/blob/main/retrieval/hybrid_retriever.py"
click node_dense "https://github.com/aravind00006/codebase-rag/blob/main/retrieval/dense_retriever.py"
click node_sparse "https://github.com/aravind00006/codebase-rag/blob/main/retrieval/sparse_retriever.py"
click node_reranker "https://github.com/aravind00006/codebase-rag/blob/main/retrieval/reranker.py"
click node_prompt "https://github.com/aravind00006/codebase-rag/blob/main/generation/prompt_builder.py"
click node_answer "https://github.com/aravind00006/codebase-rag/blob/main/generation/answer_generator.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_loader,node_parser,node_fixed,node_recursive,node_ast,node_semantic,node_embedder,node_vectors,node_bm25store toneBlue
class node_hybrid,node_dense,node_sparse,node_reranker toneAmber
class node_prompt,node_answer toneMint
class node_backend,node_frontend toneRose
class node_user,node_github,node_openai toneIndigo
```

## Components

### Repository indexing

- [Repository loader](https://github.com/aravind00006/codebase-rag/blob/main/ingestion/repo_loader.py): `ingestion/repo_loader.py`
- [File parser](https://github.com/aravind00006/codebase-rag/blob/main/ingestion/file_parser.py): `ingestion/file_parser.py`
- [Fixed chunker](https://github.com/aravind00006/codebase-rag/blob/main/ingestion/chunkers/fixed_size.py): `ingestion/chunkers/fixed_size.py`
- [Recursive chunker](https://github.com/aravind00006/codebase-rag/blob/main/ingestion/chunkers/recursive.py): `ingestion/chunkers/recursive.py`
- [AST chunker](https://github.com/aravind00006/codebase-rag/blob/main/ingestion/chunkers/ast_based.py): `ingestion/chunkers/ast_based.py`
- [Semantic chunker](https://github.com/aravind00006/codebase-rag/blob/main/ingestion/chunkers/semantic.py): `ingestion/chunkers/semantic.py`
- [Embed and index](https://github.com/aravind00006/codebase-rag/blob/main/ingestion/embedder.py): `ingestion/embedder.py`
- **Chroma vectors**
- **BM25 index**

### Search and ranking

- [Hybrid retrieval](https://github.com/aravind00006/codebase-rag/blob/main/retrieval/hybrid_retriever.py): `retrieval/hybrid_retriever.py`
- [Dense retrieval](https://github.com/aravind00006/codebase-rag/blob/main/retrieval/dense_retriever.py): `retrieval/dense_retriever.py`
- [Sparse retrieval](https://github.com/aravind00006/codebase-rag/blob/main/retrieval/sparse_retriever.py): `retrieval/sparse_retriever.py`
- [Cross-encoder reranker](https://github.com/aravind00006/codebase-rag/blob/main/retrieval/reranker.py): `retrieval/reranker.py`

### Answer generation

- [Prompt builder](https://github.com/aravind00006/codebase-rag/blob/main/generation/prompt_builder.py): `generation/prompt_builder.py`
- [Answer generator](https://github.com/aravind00006/codebase-rag/blob/main/generation/answer_generator.py): `generation/answer_generator.py`

### User interfaces

- [FastAPI backend](https://github.com/aravind00006/codebase-rag/blob/main/main.py): `main.py`
- [Streamlit UI](https://github.com/aravind00006/codebase-rag/blob/main/frontend/app.py): `frontend/app.py`

### Other components

- **Questioner**
- **GitHub repository**
- **OpenAI models**

## Connections

- Questioner → Streamlit UI: asks through (evidence: `README.md`)
- Streamlit UI → FastAPI backend: submits requests
- Questioner → FastAPI backend: calls API (evidence: `README.md`)
- FastAPI backend → Repository loader: loads repository (evidence: `main.py`)
- GitHub repository → Repository loader: provides source (evidence: `ingestion/repo_loader.py`)
- Repository loader → File parser: returns documents (evidence: `README.md`)
- File parser → Fixed chunker: parsed documents
- File parser → Recursive chunker: parsed documents
- File parser → AST chunker: parsed documents
- File parser → Semantic chunker: parsed documents
- FastAPI backend → Fixed chunker: selects strategy (evidence: `main.py`)
- FastAPI backend → Recursive chunker: selects strategy (evidence: `main.py`)
- FastAPI backend → AST chunker: selects strategy (evidence: `main.py`)
- FastAPI backend → Semantic chunker: selects strategy (evidence: `main.py`)
- Fixed chunker → Embed and index: chunks documents (evidence: `README.md`)
- Recursive chunker → Embed and index: chunks documents (evidence: `README.md`)
- AST chunker → Embed and index: chunks documents (evidence: `README.md`)
- Semantic chunker → Embed and index: chunks documents (evidence: `README.md`)
- Embed and index → Chroma vectors: writes vectors (evidence: `ingestion/embedder.py`)
- Embed and index → BM25 index: writes sparse index (evidence: `ingestion/embedder.py`)
- FastAPI backend → Hybrid retrieval: retrieves candidates (evidence: `README.md`)
- Hybrid retrieval → Dense retrieval: requests candidates (evidence: `retrieval/hybrid_retriever.py`)
- Hybrid retrieval → Sparse retrieval: requests candidates (evidence: `retrieval/hybrid_retriever.py`)
- Dense retrieval → Chroma vectors: queries vectors (evidence: `README.md`)
- Sparse retrieval → BM25 index: searches index (evidence: `README.md`)
- FastAPI backend → Cross-encoder reranker: reranks candidates (evidence: `README.md`)
- FastAPI backend → Prompt builder: builds grounded prompt (evidence: `README.md`)
- FastAPI backend → Answer generator: generates response (evidence: `README.md`)
- Prompt builder → Answer generator: supplies prompts (evidence: `evaluation/ragas_eval.py`)
- Answer generator → OpenAI models: invokes model (evidence: `generation/answer_generator.py`)
- FastAPI backend → Questioner: returns cited answer (evidence: `main.py`)
