Skip to content

Repository files navigation

🧠 Codebase RAG Assistant

License Python React FastAPI LangChain Pinecone

A production-ready, full-stack RAG assistant that ingests, searches, and reasons over any GitHub repository on demand.


πŸ“Έ Platform Previews

Dynamic Ingestion & Real-Time Pipeline Logs

Paste any public GitHub URL directly into the sidebar, hit "Trigger Ingestion", and watch the live pipeline logs stream in real-time as the backend clones, chunks, embeds, and indexes the codebase into Pinecone.

Dynamic Ingestion & Real-Time Logs

Expert-Level Codebase Q&A

Ask complex architectural questions about any indexed repository. The assistant generates precise, markdown-formatted answers and cites the exact source files it referenced.

Expert Codebase Q&A


✨ Key Features

Feature Description
πŸ”— Dynamic Repository Ingestion Paste any public GitHub URL in the UI β€” no .env edits required. The backend handles cloning, chunking, embedding, and indexing.
πŸ” Multi-Query Retrieval The LLM generates multiple query variants to cast a wider semantic net, improving recall from the vector store.
πŸ† Cohere Reranking Retrieved chunks are reranked by Cohere's cross-encoder for maximum relevance before being sent to the LLM.
πŸ“„ Parent-Document Retrieval Searches on small, semantic child chunks but feeds the full parent document to the LLM β€” preventing context loss.
☁️ Cloud & GPU Ready Run the backend on a free Google Colab T4 GPU and expose it via Ngrok. The notebook is included.
πŸŒ‘ Modern Dark UI Sleek React dashboard with real-time log streaming, markdown rendering, and source citations.

πŸ—οΈ System Architecture

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚                       React Frontend                         β”‚
β”‚   (Vite + React, dynamic URL input, real-time log polling)   β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                      β”‚  HTTP / REST
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β–Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚                  FastAPI Backend (api.py)                     β”‚
β”‚    Async background ingestion β”‚ LCEL chain assembly           β”‚
β””β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
       β”‚                                    β”‚
β”Œβ”€β”€β”€β”€β”€β”€β–Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”               β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β–Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚  ingest.py       β”‚               β”‚     rag_pipeline.py       β”‚
β”‚                  β”‚               β”‚                           β”‚
β”‚ β€’ git clone/pull β”‚               β”‚ β€’ HuggingFace Embeddings   β”‚
β”‚ β€’ File splitter  β”‚               β”‚ β€’ Pinecone VectorStore     β”‚
β”‚ β€’ Commit history β”‚               β”‚ β€’ MultiQueryRetriever      β”‚
β”‚ β€’ Pinecone upsertβ”‚               β”‚ β€’ Cohere Reranker         β”‚
β”‚ β€’ Docstore pkl   β”‚               β”‚ β€’ Groq LLM (Llama 3.3)    β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜               β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

πŸš€ Getting Started

Prerequisites

Step 1 β€” Clone & Configure

git clone https://github.com/hamzasaqib80/codebase-rag-assistant.git
cd codebase-rag-assistant

# Copy the example env and fill in your API keys
cp .env.example .env

Edit .env with your API keys:

PINECONE_API_KEY=your_pinecone_api_key_here
GROQ_API_KEY=your_groq_api_key_here
COHERE_API_KEY=your_cohere_api_key_here
GITHUB_REPO_URL=https://github.com/any/repo.git   # Default repo to pre-index

Step 2 β€” Backend Setup

Option A: Local (CPU)

pip install -r requirements-api.txt
uvicorn api:app --host 0.0.0.0 --port 8000

Option B: Google Colab (Free T4 GPU) β€” Recommended

πŸ’‘ Open RAG_Ingestion_Colab.ipynb in Google Colab, fill in your API keys, and run all cells. The notebook will start the FastAPI server and expose it via Ngrok automatically.

Step 3 β€” Frontend Setup

cd frontend

# Install dependencies
npm install

# Create frontend environment file
echo "VITE_API_URL=http://localhost:8000" > .env
# (Replace with your Ngrok URL if using Colab)

# Start the dev server
npm run dev

Open http://localhost:5173 in your browser.

Step 4 β€” Index a Repository

  1. Paste a GitHub URL in the sidebar input field (e.g. https://github.com/psf/requests.git).
  2. Click "Trigger Ingestion".
  3. Watch the live pipeline logs as the repository is indexed.
  4. Once complete, start asking questions in the chat!

πŸ› οΈ Tech Stack

Layer Technology
LLM Groq β€” Llama 3.3 70B (ultra-fast inference)
Vector DB Pinecone (serverless)
Embeddings sentence-transformers/all-mpnet-base-v2 (local, no API cost)
Reranker Cohere Rerank v3
Framework LangChain LCEL
Backend FastAPI + Uvicorn
Frontend React 18, Vite
Cloud Hosting Google Colab + Ngrok

πŸ“ Project Structure

codebase-rag-assistant/
β”œβ”€β”€ api.py                     # FastAPI backend β€” ingestion & query endpoints
β”œβ”€β”€ ingest.py                  # Full ingestion pipeline (clone β†’ chunk β†’ embed β†’ upsert)
β”œβ”€β”€ rag_pipeline.py            # LangChain LCEL chain assembly
β”œβ”€β”€ retrievers.py              # Custom ParentFetchingRetriever implementation
β”œβ”€β”€ utils.py                   # Shared logging utilities
β”œβ”€β”€ query.py                   # Standalone CLI query script
β”œβ”€β”€ requirements-api.txt       # Backend Python dependencies
β”œβ”€β”€ RAG_Ingestion_Colab.ipynb  # Google Colab notebook for cloud deployment
β”œβ”€β”€ .env.example               # Environment variable template
└── frontend/                  # React + Vite frontend
    β”œβ”€β”€ src/
    β”‚   └── App.jsx            # Main UI component
    └── package.json

πŸ“„ License

This project is licensed under the MIT License.

About

🧠 Codebase RAG Assistant β€” Index any GitHub repo with Pinecone + Cohere, query with Llama 3.3 70B via Groq. Full-stack: FastAPI + React, deployable 100% free.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages