How aravind00006/codebase-rag works
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 FastAPI backend · embedder.py Embed and index · file_parser.py File parser · hybrid_retriever.py Hybrid retrieval
Components 20
Repository indexing
- Repository loader
ingestion/repo_loader.py - File parser
ingestion/file_parser.py - Fixed chunker
ingestion/chunkers/fixed_size.py - Recursive chunker
ingestion/chunkers/recursive.py - AST chunker
ingestion/chunkers/ast_based.py - Semantic chunker
ingestion/chunkers/semantic.py - Embed and index
ingestion/embedder.py - Chroma vectors
- BM25 index
Search and ranking
- Hybrid retrieval
retrieval/hybrid_retriever.py - Dense retrieval
retrieval/dense_retriever.py - Sparse retrieval
retrieval/sparse_retriever.py - Cross-encoder reranker
retrieval/reranker.py
Answer generation
- Prompt builder
generation/prompt_builder.py - Answer generator
generation/answer_generator.py
User interfaces
- FastAPI backend
main.py - Streamlit UI
frontend/app.py
Other components
- Questioner
- GitHub repository
- OpenAI models
Connections 31
- Questioner → Streamlit UI: asks through
README.md - Streamlit UI → FastAPI backend: submits requests
- Questioner → FastAPI backend: calls API
README.md - FastAPI backend → Repository loader: loads repository
main.py - GitHub repository → Repository loader: provides source
ingestion/repo_loader.py - Repository loader → File parser: returns documents
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
main.py - FastAPI backend → Recursive chunker: selects strategy
main.py - FastAPI backend → AST chunker: selects strategy
main.py - FastAPI backend → Semantic chunker: selects strategy
main.py - Fixed chunker → Embed and index: chunks documents
README.md - Recursive chunker → Embed and index: chunks documents
README.md - AST chunker → Embed and index: chunks documents
README.md - Semantic chunker → Embed and index: chunks documents
README.md - Embed and index → Chroma vectors: writes vectors
ingestion/embedder.py - Embed and index → BM25 index: writes sparse index
ingestion/embedder.py - FastAPI backend → Hybrid retrieval: retrieves candidates
README.md - Hybrid retrieval → Dense retrieval: requests candidates
retrieval/hybrid_retriever.py - Hybrid retrieval → Sparse retrieval: requests candidates
retrieval/hybrid_retriever.py - Dense retrieval → Chroma vectors: queries vectors
README.md - Sparse retrieval → BM25 index: searches index
README.md - FastAPI backend → Cross-encoder reranker: reranks candidates
README.md - FastAPI backend → Prompt builder: builds grounded prompt
README.md - FastAPI backend → Answer generator: generates response
README.md - Prompt builder → Answer generator: supplies prompts
evaluation/ragas_eval.py - Answer generator → OpenAI models: invokes model
generation/answer_generator.py - FastAPI backend → Questioner: returns cited answer
main.py