Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

15 Commits
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

๐Ÿง‘โ€๐Ÿ’ป Codebase Chat Assistant

Chat with any GitHub repository using AI.
Upload a repo, ask questions in plain English, and get context-aware answers with direct file references โ€” powered by RAG.

Node.js React Python FastAPI Docker


โœจ Features

Feature Description
๐Ÿ”— Repo Indexing Paste any public GitHub URL โ€” the codebase is cloned, chunked, and embedded
๐Ÿ’ฌ Conversational Chat Multi-turn chat with full history, per repository
๐Ÿ“‚ File-Level Sources Every answer links back to the exact source file and code snippet
๐Ÿง  RAG Pipeline Semantic retrieval via ChromaDB + Gemini LLM for grounded answers
๐Ÿ” Auth JWT-based register/login with protected routes
๐Ÿณ Docker Ready One command to spin up all three services

๐Ÿ—๏ธ Architecture

โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚                        Browser                          โ”‚
โ”‚              http://localhost:3000                      โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
                         โ”‚
                โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ–ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
                โ”‚  client (Nginx)  โ”‚  :3000 โ†’ :80
                โ”‚   React + Vite   โ”‚
                โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
                         โ”‚  /api/*  (proxied)
                โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ–ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
                โ”‚  server (Express)โ”‚  :5000
                โ”‚  Node.js + JWT   โ”‚
                โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”˜
                       โ”‚      โ”‚
          โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ–ผโ”€โ”€โ”  โ”Œโ–ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
          โ”‚  MongoDB Atlasโ”‚  โ”‚ ai-service (FastAPI)โ”‚  :8400
          โ”‚  Users, Repos โ”‚  โ”‚ LangChain + ChromaDBโ”‚
          โ”‚  Chat History โ”‚  โ”‚ Gemini Embeddings  โ”‚
          โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜  โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜

How a query flows

  1. User pastes a GitHub URL โ†’ POST /api/repo/upload
  2. Server calls ai-service POST /load-repo
  3. ai-service clones repo โ†’ chunks code โ†’ creates ChromaDB vector store
  4. User asks a question โ†’ POST /api/chat/ask
  5. Server forwards to ai-service POST /ask
  6. ai-service retrieves top-k relevant chunks โ†’ Gemini generates answer
  7. Answer + source file references returned to the UI

๐Ÿ“ Project Structure

Codebase Chat Assistant/
โ”‚
โ”œโ”€โ”€ docker-compose.yml          # Orchestrates all services
โ”œโ”€โ”€ .env                        # Root secrets (gitignored)
โ”œโ”€โ”€ .env.example                # Template โ€” safe to commit
โ”‚
โ”œโ”€โ”€ client/                     # React 19 + Vite + Tailwind CSS
โ”‚   โ”œโ”€โ”€ src/
โ”‚   โ”‚   โ”œโ”€โ”€ pages/
โ”‚   โ”‚   โ”‚   โ”œโ”€โ”€ Home.jsx        # Landing page
โ”‚   โ”‚   โ”‚   โ”œโ”€โ”€ Login.jsx       # Register / Login
โ”‚   โ”‚   โ”‚   โ””โ”€โ”€ Dashboard.jsx   # Main app layout
โ”‚   โ”‚   โ”œโ”€โ”€ components/
โ”‚   โ”‚   โ”‚   โ”œโ”€โ”€ Sidebar.jsx     # Repo list + upload
โ”‚   โ”‚   โ”‚   โ”œโ”€โ”€ ChatWindow.jsx  # Multi-turn chat UI
โ”‚   โ”‚   โ”‚   โ””โ”€โ”€ SourceViewer.jsx# Side-panel file viewer
โ”‚   โ”‚   โ”œโ”€โ”€ services/
โ”‚   โ”‚   โ”‚   โ””โ”€โ”€ api.js          # Axios client (auth, repo, chat)
โ”‚   โ”‚   โ””โ”€โ”€ context/
โ”‚   โ”‚       โ””โ”€โ”€ AuthContext.jsx # JWT auth state
โ”‚   โ”œโ”€โ”€ Dockerfile
โ”‚   โ”œโ”€โ”€ nginx.conf              # SPA routing + /api proxy
โ”‚   โ””โ”€โ”€ vite.config.js
โ”‚
โ”œโ”€โ”€ server/                     # Express.js REST API
โ”‚   โ”œโ”€โ”€ routes/
โ”‚   โ”‚   โ”œโ”€โ”€ authRoutes.js       # POST /register, /login, GET /me
โ”‚   โ”‚   โ”œโ”€โ”€ repoRoutes.js       # POST /upload, GET /list
โ”‚   โ”‚   โ””โ”€โ”€ chatRoutes.js       # POST /ask, GET /history/:repoId
โ”‚   โ”œโ”€โ”€ controllers/
โ”‚   โ”œโ”€โ”€ models/
โ”‚   โ”‚   โ”œโ”€โ”€ User.js
โ”‚   โ”‚   โ”œโ”€โ”€ Repo.js
โ”‚   โ”‚   โ””โ”€โ”€ Chat.js
โ”‚   โ”œโ”€โ”€ middleware/
โ”‚   โ”‚   โ””โ”€โ”€ auth.js             # JWT verification
โ”‚   โ”œโ”€โ”€ config/
โ”‚   โ”‚   โ””โ”€โ”€ db.js               # MongoDB connection
โ”‚   โ”œโ”€โ”€ index.js
โ”‚   โ””โ”€โ”€ Dockerfile
โ”‚
โ””โ”€โ”€ ai-service/                 # Python FastAPI service
    โ”œโ”€โ”€ main.py                 # POST /load-repo, POST /ask
    โ”œโ”€โ”€ repo_loader.py          # Clone + read repo files
    โ”œโ”€โ”€ chunker.py              # Code chunking strategy
    โ”œโ”€โ”€ vector_store.py         # ChromaDB read/write
    โ”œโ”€โ”€ rag_pipeline.py         # LangChain LCEL RAG chain
    โ”œโ”€โ”€ requirements.txt
    โ””โ”€โ”€ Dockerfile

๐Ÿš€ Quick Start โ€” Docker (Recommended)

Prerequisites: Docker Desktop installed and running.

1. Clone the repository

git clone https://github.com/omkarbg100/codebase-chat-assistant.git
cd "codebase-chat-assistant"

2. Configure secrets

# Copy the template
cp .env.example .env

Edit .env and fill in your values:

MONGODB_URI=mongodb+srv://user:[email protected]/db
JWT_SECRET=your_super_secret_jwt_key
GOOGLE_API_KEY=your_gemini_api_key_here   # โ† only this is required

Get a free Gemini API key at aistudio.google.com

3. Build and run

docker compose up --build
Service URL
Frontend http://localhost:3000
Backend API http://localhost:5000
AI Service http://localhost:8400
API Docs (FastAPI) http://localhost:8400/docs

Useful Docker commands

# Run in background
docker compose up --build -d

# View logs for a specific service
docker compose logs -f ai-service

# Stop all services
docker compose down

# Stop and wipe vector DB volumes
docker compose down -v

# Rebuild a single service
docker compose up --build server

๐Ÿ’ป Local Development (No Docker)

Open three terminals:

Terminal 1 โ€” AI Service

cd ai-service
python -m venv venv
venv\Scripts\activate          # Windows
# source venv/bin/activate     # Mac/Linux
pip install -r requirements.txt

# Create ai-service/.env
echo GOOGLE_API_KEY=your_key > .env

uvicorn main:app --reload --port 8400
# โ†’ http://localhost:8400

Terminal 2 โ€” Server

cd server
npm install
# Ensure server/.env has PORT, MONGODB_URI, JWT_SECRET, AI_SERVICE_URL
npm run dev
# โ†’ http://localhost:5000

Terminal 3 โ€” Client

cd client
npm install
# client/.env.local already sets VITE_API_BASE_URL=http://localhost:5000/api
npm run dev
# โ†’ http://localhost:5173

In local dev, vite.config.js proxies /api/* โ†’ localhost:5000
so the frontend URL is http://localhost:5173.


๐Ÿ”‘ Environment Variables

Root .env (docker-compose)

Variable Description
MONGODB_URI MongoDB Atlas connection string
JWT_SECRET Secret key for signing JWTs
GOOGLE_API_KEY Gemini API key (used by ai-service)

server/.env (local dev only)

Variable Default Description
PORT 5000 Express server port
MONGODB_URI โ€” MongoDB connection string
JWT_SECRET โ€” JWT signing secret
AI_SERVICE_URL http://localhost:8400 ai-service base URL
GOOGLE_API_KEY โ€” Gemini API key

ai-service/.env (local dev only)

Variable Description
GOOGLE_API_KEY Gemini API key

client/.env.local (local dev only)

Variable Default Description
VITE_API_BASE_URL /api API base URL for axios

๐ŸŒ API Reference

Auth โ€” /api/auth

Method Endpoint Auth Description
POST /register โŒ Register a new user
POST /login โŒ Login, receive JWT
GET /me โœ… Get current user

Repositories โ€” /api/repo

Method Endpoint Auth Description
POST /upload โœ… Index a GitHub repo
GET /list โœ… List user's repos

Chat โ€” /api/chat

Method Endpoint Auth Description
POST /ask โœ… Ask a question about a repo
GET /history/:repoId โœ… Get chat history for a repo

AI Service โ€” localhost:8400 (internal)

Method Endpoint Description
POST /load-repo Clone repo, create vector store
POST /ask Query RAG chain, return answer + sources

๐Ÿง  Tech Stack

Layer Technology
Frontend React 19, Vite, Tailwind CSS v4, Framer Motion, react-markdown
Backend Node.js, Express 5, Mongoose, JWT, bcryptjs
Database MongoDB Atlas
AI Service Python 3.11, FastAPI, LangChain (LCEL), ChromaDB
Embeddings all-MiniLM-L6-v2 via HuggingFace (local, no API cost)
LLM Google Gemini (gemini-2.0-flash via langchain-google-genai)
Containerization Docker, Docker Compose, Nginx

๐Ÿ—‚๏ธ Docker Volume Persistence

Volume Mount Purpose
ai_chroma_db /app/chroma_db Vector embeddings (persisted across restarts)
ai_temp_repos /app/temp_repos Temp repo clones during indexing

๐Ÿ“Œ Use Cases

  • ๐Ÿ” Understand a large unfamiliar codebase quickly
  • ๐ŸŽ“ Developer onboarding โ€” ask "how does auth work?"
  • ๐Ÿ› Debugging โ€” "where is the payment logic handled?"
  • ๐Ÿ“ Auto-documentation and code explanation
  • ๐Ÿ”„ Code review assistance

๐Ÿ”ฎ Roadmap

  • Private GitHub repo support (OAuth token)
  • Streaming responses (SSE)
  • Multi-repo comparison chat
  • Bug detection mode
  • Auto-generate documentation from codebase
  • VS Code extension

๐Ÿค Contributing

  1. Fork the repository
  2. Create your feature branch: git checkout -b feature/amazing-feature
  3. Commit your changes: git commit -m 'Add amazing feature'
  4. Push to the branch: git push origin feature/amazing-feature
  5. Open a Pull Request

About

A full-stack GenAI application that enables developers to chat with any GitHub repository. Uses Retrieval-Augmented Generation (RAG) with LangChain, Gemini API, and ChromaDB to provide context-aware code explanations.

Resources

Stars

Watchers

Forks

Releases

Packages

Contributors

Languages