RepoBeacon: Codebase Indexing & RAG
Designing an end-to-end repository ingestion and retrieval pipeline that grounds LLM responses using Spring Boot and PostgreSQL pgvector.
Navigating Large Codebases
Providing developers with an AI assistant grounded in their actual repository context.
When onboarding to a new project or debugging complex issues, developers spend significant time searching through files to understand repository structure and logic.
General-purpose LLMs lack knowledge of private or recent codebase changes. To provide accurate, context-aware answers, the system needs to ingest the repository source code and retrieve relevant context based on user queries.
Relies on pre-training data. Hallucinates answers when asked about specific, unseen repository implementations.
Indexes the actual repository code into semantic vectors, retrieving the most relevant files to ground the LLM's response in reality.
Token-Based Chunking & Semantic Retrieval
Indexing repository content and grounding queries using vector similarity search.
RepoBeacon fetches repository files via the GitHub API, processes them using token-based chunking, and generates vector embeddings.
By storing these embeddings in PostgreSQL via pgvector, RepoBeacon can quickly retrieve the most semantically relevant code chunks to answer developer questions accurately.
// Standard RAG Pipeline
1. Fetch repository tree and files
2. Filter out binaries and irrelevant files
3. Split source code using token-based chunker
4. Generate embeddings for each chunk
5. Store embeddings and metadata in pgvector
6. Query: embed user question -> retrieve top-k chunks -> generate answerIndex-Retrieve-Generate Pipeline
Architecture flow from repository ingest to chat interface.
Repository Fetch
Downloading and filtering source files via the GitHub API.
Token Chunking
Splitting files into manageable token chunks for embedding.
Embedding Generation
Transforming text chunks into semantic vector embeddings.
Vector Storage
Storing chunks and embeddings for similarity search.
Context-Aware Generation
Retrieving relevant chunks and streaming the LLM response.
Architectural Choices
Practical choices for building a robust RAG application.
Spring Boot for Pipeline Orchestration
PostgreSQL with pgvector
Key Takeaways
Engineering lessons learned from building RepoBeacon.
Unified Storage
Keeping vector embeddings and relational metadata inside PostgreSQL greatly simplified operations and local development.
Chunking Strategies
Tuning the chunk size and overlap is critical to ensuring the LLM receives enough context without exceeding its context window.