AI-powered codebase intelligence. Drop any GitHub repo or upload project files β ask questions, debug, and understand the entire codebase instantly like a senior developer who has read every single file.
- What is CodeAtlas ?
- How It Works
- Features
- Tech Stack
- Project Structure
- Prerequisites
- Installation & Setup
- Configuration
- API Reference
- Free API Providers
- Usage Guide
- Troubleshooting
- Performance Tips
- Roadmap
Every developer knows the pain of:
- Joining a new project and spending days just understanding the codebase
- Searching
Ctrl+Facross 50 files to find where a feature is implemented - Debugging an issue that spans 5 different files across 3 modules
- Trying to understand why a function exists and what it connects to
CodeAtlas solves all of this.
You give it a GitHub repo URL or upload your project files. It reads, parses, and indexes the entire codebase using RAG (Retrieval-Augmented Generation). Then you can ask it anything in plain English β and it answers with full context, file references, and code snippets.
You: "Where is user authentication handled and how does JWT work here?"
DevBrain: Authentication is handled across 3 files:
β auth/middleware.py (lines 12β67): JWT verification logic
β routes/auth_routes.py (lines 23β89): login/logout endpoints
β models/user.py (lines 5β34): User model with password hashing
The JWT token is generated in login_user() using PyJWT with a
24-hour expiry. The middleware validates it on every protected route...
DevBrain AI uses a RAG (Retrieval-Augmented Generation) pipeline with code-aware chunking:
User Input (GitHub URL / Files)
β
Code Parsing
(Tree-sitter splits by functions, classes, modules)
β
Embedding Generation
(HuggingFace all-MiniLM-L6-v2 β vectors)
β
Vector Storage
(FAISS local index with metadata)
β
User Query
β
Multi-Query Expansion
("auth" β ["authentication", "login", "JWT", "middleware"])
β
Similarity Search
(Find top-K most relevant code chunks)
β
Context Stitching
(Merge chunks from multiple files)
β
LLM Response
(Groq/OpenAI generates grounded answer)
β
Answer + Source References
Normal RAG splits text by character count. This breaks functions in half and destroys context.
DevBrain uses Tree-sitter to split by actual code structure:
# β Normal chunking (bad)
"...def login_user(username, pas" β chunk boundary mid-function
"sword):\n user = db.query..."
# β
CodeAtlas chunking (good)
"def login_user(username, password): β entire function = one chunk
user = db.query(User).filter(...)
if not verify_password(...):
raise AuthError(...)
return generate_jwt(user.id)"This means every chunk is a complete, meaningful unit of code β which massively improves retrieval accuracy.
- π Smart Code Search β Finds code by meaning, not just keywords. "Where is rate limiting?" finds it even if the variable is named
throttle_requests - π§ Architecture Explainer β Ask "explain the project structure" and get a full breakdown of modules, dependencies, and data flow
- π Debugging Assistant β "Why is login failing?" traces through auth middleware, database queries, and error handling across all relevant files
- β‘ Code Optimizer β Ask to optimize a function and get suggestions with time complexity analysis
- π Multi-File Context β Answers span multiple files simultaneously, showing exactly how code connects
- Multi-Query Expansion β One query becomes 4 variants to maximize retrieval coverage
- Context Stitching β Intelligently merges relevant chunks from different files without duplication
- Metadata Filtering β Filter search to specific languages (
python) or modules (auth) - Cross-Encoder Reranker β Optional second-pass reranking for higher precision (enable with
USE_RERANKER=true) - Streaming Responses β Answers stream token-by-token like ChatGPT for instant feedback
- Background Indexing β Ingestion runs in a background thread with real-time progress polling
- Project Caching β Indexed projects are cached; re-asking questions is instant
- Source References β Every answer shows exactly which files and line numbers were used
- Language Detection β Automatically detects Python, JS, TS, Go, Rust, Java, C++, and more
- Smart File Filtering β Automatically ignores
node_modules,build,.git, binary files
| Technology | Version | Purpose |
|---|---|---|
| Python | 3.11+ | Core runtime |
| Flask | 3.0.3 | REST API + SSE streaming |
| LangChain | 0.2.6 | RAG orchestration |
| Tree-sitter | 0.21.3 | Code-aware AST parsing |
| GitPython | 3.1.43 | Clone GitHub repos |
| Technology | Purpose |
|---|---|
sentence-transformers/all-MiniLM-L6-v2 |
Free local embeddings (80MB, 384-dim) |
microsoft/codebert-base |
Alternative code-specific embeddings |
text-embedding-3-small (OpenAI) |
Cloud embeddings (paid) |
| FAISS | Local vector index (MVP) |
| pgvector | Production vector DB (PostgreSQL) |
| Provider | Models | Cost |
|---|---|---|
| Groq | llama3-70b, llama3-8b, mixtral-8x7b | Free tier |
| OpenAI | gpt-4o, gpt-3.5-turbo | Paid |
| Google Gemini | gemini-1.5-flash | Free tier |
| Technology | Version | Purpose |
|---|---|---|
| Next.js | 14.2.35 | React framework |
| TypeScript | 5+ | Type safety |
| Tailwind CSS | 3.4 | Styling |
| react-markdown | 9.0 | Render markdown answers |
| lucide-react | 0.400 | Icons |
devbrain-ai/
β
βββ π README.md
βββ π docker-compose.yml # Full stack: backend + frontend + postgres
βββ π .gitignore
β
βββ π backend/
β βββ app.py # Flask app factory, registers blueprints
β βββ config.py # All config loaded from .env
β βββ requirements.txt # Python dependencies
β βββ Dockerfile
β βββ .env.example # Template β copy to .env
β β
β βββ ingestion/ # Step 1-3: Input β Parse β Chunk
β β βββ github_loader.py # Clone repo, walk files, detect language
β β βββ file_loader.py # Handle zip uploads, extract safely
β β βββ file_filter.py # Ignore node_modules, binaries, etc.
β β βββ chunker.py # Tree-sitter AST chunking + fallback
β β
β βββ embeddings/ # Step 4: Text β Vectors
β β βββ __init__.py # Unified interface (picks provider)
β β βββ openai_embedder.py # OpenAI text-embedding-3-small
β β βββ hf_embedder.py # HuggingFace sentence-transformers
β β
β βββ vectorstore/ # Step 5: Store & Search Vectors
β β βββ __init__.py # Unified interface (faiss or pgvector)
β β βββ faiss_store.py # Local FAISS flat index + JSON metadata
β β βββ pgvector_store.py # PostgreSQL pgvector (production)
β β
β βββ retrieval/ # Step 6: Core RAG Logic
β β βββ retriever.py # Main pipeline: expandβsearchβrerankβstitch
β β βββ multi_query.py # Expand 1 query into N variants via LLM
β β βββ context_stitcher.py # Deduplicate & merge chunks into context
β β βββ reranker.py # Optional cross-encoder reranker
β β
β βββ llm/ # Step 7: Generate Response
β β βββ prompt_builder.py # System prompt + context template
β β βββ llm_chain.py # OpenAI/Groq, streaming + non-streaming
β β
β βββ api/ # Flask route handlers
β β βββ ingest_routes.py # POST /api/ingest, GET /api/ingest/status
β β βββ query_routes.py # POST /api/query (SSE streaming)
β β
β βββ utils/
β βββ language_detector.py # Map file extensions β language names
β βββ metadata_extractor.py # Extract file path, module, function name
β
βββ βοΈ frontend/
βββ package.json
βββ next.config.js # Rewrites /api/backend/* β Flask
βββ tailwind.config.ts
βββ tsconfig.json
βββ Dockerfile
βββ .env.local.example
β
βββ app/
β βββ layout.tsx # Root layout, fonts, metadata
β βββ globals.css # Tailwind base + custom styles
β βββ page.tsx # Landing page: GitHub URL + file upload
β βββ chat/
β βββ page.tsx # Chat interface page
β
βββ components/
β βββ ChatInterface.tsx # Full streaming chat UI with state mgmt
β βββ SourceFiles.tsx # Referenced files panel with scores
β
βββ lib/
βββ api.ts # Typed fetch helpers for all API calls
Before you start, install these on your machine:
Python 3.11+
python --version # should show 3.11 or higherDownload: https://python.org/downloads
β οΈ Windows: check "Add Python to PATH" during installation
Node.js 20+
node --version # should show v20 or higherDownload: https://nodejs.org (choose LTS)
Git
git --versionDownload: https://git-scm.com/downloads
| Provider | Free? | Get Key |
|---|---|---|
| Groq β Recommended | Yes, free tier | https://console.groq.com |
| OpenAI | Paid | https://platform.openai.com/api-keys |
| Google Gemini | Free tier | https://aistudio.google.com/app/apikey |
HuggingFace embeddings are completely free β no key needed, model downloads automatically.
- Python (Microsoft)
- Pylance
- ES7+ React/Redux Snippets
- Tailwind CSS IntelliSense
- TypeScript (built-in)
Best for development. Fastest to get started.
# If you have the zip:
unzip codeatlas.zip
cd codeatlas
# Or clone from GitHub:
git clone https://github.com/your-username/codeatlas.git
cd codeatlascd backend
# Create virtual environment
python -m venv venv
# Activate it
source venv/bin/activate # macOS / Linux
venv\Scripts\activate # Windows (Command Prompt)
.\venv\Scripts\Activate.ps1 # Windows (PowerShell)
# Install dependencies (takes 3-5 minutes)
pip install -r requirements.txtcp .env.example .envOpen backend/.env and configure:
# ββ Minimum config to get started ββββββββββββββββββββββββ
# Groq (free) β get key at https://console.groq.com
LLM_PROVIDER=groq
LLM_MODEL=llama3-8b-8192
GROQ_API_KEY=your_groq_api_key_here
# HuggingFace embeddings β FREE, no key needed
EMBEDDING_PROVIDER=huggingface
HF_EMBED_MODEL=sentence-transformers/all-MiniLM-L6-v2
SENTENCE_TRANSFORMERS_HOME=./model_cache
# FAISS β local vector store, no setup needed
VECTOR_STORE=faiss
FAISS_INDEX_DIR=./faiss_indexes
# Performance
TOP_K=5
MULTI_QUERY_COUNT=0
USE_RERANKER=false
# App
FLASK_DEBUG=true
SECRET_KEY=your_secret_key_here
UPLOAD_DIR=./uploadsOpen a new terminal (keep backend terminal open):
cd frontend
npm install
cp .env.local.example .env.localfrontend/.env.local should contain:
BACKEND_URL=http://localhost:5000Terminal 1 β Backend:
cd backend
venv\Scripts\activate # Windows
# source venv/bin/activate # macOS/Linux
python app.pyExpected output:
* Running on http://0.0.0.0:5000
* Debug mode: on
Terminal 2 β Frontend:
cd frontend
npm run devExpected output:
β² Next.js 14.2.35
- Local: http://localhost:3000
β Ready in 2.1s
Go to http://localhost:3000 in your browser.
To verify backend is healthy: http://127.0.0.1:5000/health
{ "status": "ok", "service": "devbrain-ai" }Best for production. Runs everything in one command including PostgreSQL.
Download: https://docker.com/products/docker-desktop
cd codeatlas
cp backend/.env.example .envEdit .env:
OPENAI_API_KEY=sk-... # or use Groq:
GROQ_API_KEY=gsk_...
LLM_PROVIDER=groq
LLM_MODEL=llama3-8b-8192
EMBEDDING_PROVIDER=huggingface
VECTOR_STORE=pgvector # use pgvector with Dockerdocker compose up --buildFirst run downloads images and builds containers (~5 minutes). Subsequent runs start in ~30 seconds.
- Frontend: http://localhost:3000
- Backend API: http://localhost:5000
- PostgreSQL: localhost:5432
docker compose down # stop containers
docker compose down -v # stop + wipe databaseAll backend config lives in backend/.env. Full reference:
| Variable | Default | Options | Description |
|---|---|---|---|
LLM_PROVIDER |
openai |
openai, groq |
Which LLM to use |
LLM_MODEL |
gpt-4o |
Any model name | Specific model |
OPENAI_API_KEY |
β | sk-... |
Required for OpenAI |
GROQ_API_KEY |
β | gsk_... |
Required for Groq |
Groq model options:
llama3-8b-8192β fastest, good qualityllama3-70b-8192β best quality, slowermixtral-8x7b-32768β best for long codebases (32k context)
| Variable | Default | Options | Description |
|---|---|---|---|
EMBEDDING_PROVIDER |
openai |
openai, huggingface |
Embedding source |
OPENAI_EMBED_MODEL |
text-embedding-3-small |
β | OpenAI model |
HF_EMBED_MODEL |
microsoft/codebert-base |
Any HF model | Local model |
SENTENCE_TRANSFORMERS_HOME |
β | ./model_cache |
Cache directory |
Recommended free HuggingFace models:
sentence-transformers/all-MiniLM-L6-v2β 80MB, fastest, great qualitymicrosoft/codebert-baseβ 500MB, code-specific
| Variable | Default | Options | Description |
|---|---|---|---|
VECTOR_STORE |
faiss |
faiss, pgvector |
Storage backend |
FAISS_INDEX_DIR |
./faiss_indexes |
Any path | FAISS save location |
PG_HOST |
localhost |
β | PostgreSQL host |
PG_PORT |
5432 |
β | PostgreSQL port |
PG_USER |
devbrain |
β | PostgreSQL user |
PG_PASSWORD |
devbrain |
β | PostgreSQL password |
PG_DB |
devbrain |
β | Database name |
| Variable | Default | Description |
|---|---|---|
TOP_K |
8 |
Number of chunks retrieved per query |
MULTI_QUERY_COUNT |
4 |
Query expansion variants (0 = disabled) |
USE_RERANKER |
false |
Enable cross-encoder reranking |
RERANKER_MODEL |
cross-encoder/ms-marco-MiniLM-L-6-v2 |
Reranker model |
MAX_CHUNK_TOKENS |
400 |
Max tokens per code chunk |
Index a GitHub repository or uploaded files.
GitHub URL:
curl -X POST http://localhost:5000/api/ingest \
-H "Content-Type: application/json" \
-d '{"github_url": "https://github.com/user/repo"}'File upload:
curl -X POST http://localhost:5000/api/ingest \
-F "files[]=@myproject.zip"Response:
{
"project_id": "user_repo",
"status": "processing"
}Poll ingestion progress.
curl http://localhost:5000/api/ingest/status/user_repoResponse (processing):
{
"project_id": "user_repo",
"status": "processing",
"message": "Embedding 342 chunks...",
"files": 47,
"chunks": 342
}Response (ready):
{
"project_id": "user_repo",
"status": "ready",
"message": "Indexing complete",
"files": 47,
"chunks": 342
}Query the indexed codebase.
curl -X POST http://localhost:5000/api/query \
-H "Content-Type: application/json" \
-d '{
"project_id": "user_repo",
"query": "Where is authentication handled?",
"stream": false,
"filter_language": "python",
"filter_module": "auth"
}'Parameters:
| Field | Type | Required | Description |
|---|---|---|---|
project_id |
string | β | From ingest response |
query |
string | β | Natural language question |
stream |
boolean | β | Enable SSE streaming (default: false) |
filter_language |
string | β | Only search this language |
filter_module |
string | β | Only search files containing this string |
Non-streaming response:
{
"answer": "Authentication is handled in auth/middleware.py...",
"sources": [
{
"file_path": "auth/middleware.py",
"language": "python",
"chunk_type": "function",
"name": "verify_jwt_token",
"start_line": 23,
"end_line": 67,
"score": 0.9241
}
]
}Streaming response (SSE):
data: {"type": "sources", "sources": [...]}
data: {"type": "token", "content": "Authentication"}
data: {"type": "token", "content": " is"}
data: {"type": "token", "content": " handled"}
...
data: [DONE]
Check if backend is running.
curl http://localhost:5000/health{ "status": "ok", "service": "devbrain-ai" }You can run DevBrain AI at zero cost with these free providers:
- Free tier: 14,400 requests/day, 30 req/min
- Get key: https://console.groq.com
- Best models:
llama3-8b-8192β fast everyday usellama3-70b-8192β complex analysismixtral-8x7b-32768β large codebases
- No API key needed
- Runs entirely on your machine
- Downloads once, cached forever
- Best model:
sentence-transformers/all-MiniLM-L6-v2
- Free tier: 15 req/min, 1500/day
- Get key: https://aistudio.google.com/app/apikey
- Runs locally, no server needed
- Persists to disk between restarts
- Handles codebases up to ~100k chunks easily
On the homepage, paste any public GitHub URL:
https://github.com/pallets/flask
https://github.com/tiangolo/fastapi
https://github.com/vercel/next.js
Or click "Upload project files" to upload a .zip of your local project.
Watch the progress bar β indexing takes:
- Small repo (< 50 files): ~30 seconds
- Medium repo (50β200 files): 1β3 minutes
- Large repo (200+ files): 3β10 minutes
Once indexed, you can ask anything in natural language:
Architecture questions:
Explain the overall project architecture
What are the main modules and how do they connect?
Draw the data flow from HTTP request to database
Finding code:
Where is authentication handled?
Where is the database connection configured?
How is error handling implemented?
Where are environment variables loaded?
Debugging:
Why would the login endpoint return a 401 error?
What could cause a database connection timeout?
Why is the API rate limiter not working?
Code understanding:
Explain what the middleware.py file does
How does the caching layer work?
What design patterns are used in this project?
Optimization:
How can I optimize the database queries in user_service.py?
What's the time complexity of the search function?
In the top-right filter menu, you can narrow search:
- Language filter:
python,javascript,typescript, etc. - Module filter:
auth,api,models, etc.
Every answer shows which files were used, with:
- File path
- Function/class name
- Line numbers
- Confidence score (0β100%)
ModuleNotFoundError on startup:
# Make sure venv is activated
venv\Scripts\activate # Windows
source venv/bin/activate # macOS/Linux
# Reinstall dependencies
pip install -r requirements.txttree-sitter build error on Windows:
pip install tree-sitter --no-build-isolationAlso install Visual C++ Build Tools: https://visualstudio.microsoft.com/visual-cpp-build-tools/
faiss-cpu installation fails:
pip install faiss-cpu --no-cache-dirHuggingFace model download stuck:
- First download is ~80MB, can take 2β5 minutes on slow internet
- Check internet connection
- Set
SENTENCE_TRANSFORMERS_HOME=./model_cacheto cache locally
Groq rate limit error:
Error: 429 Too Many Requests
Set MULTI_QUERY_COUNT=0 in .env to reduce API calls.
Flask not starting on port 5000 (macOS): macOS Monterey+ uses port 5000 for AirPlay. Change Flask port:
# In app.py, change last line to:
app.run(debug=DEBUG, host="0.0.0.0", port=5001)And update frontend/.env.local:
BACKEND_URL=http://localhost:5001
next.config.js TypeScript syntax error:
Replace next.config.js content with:
/** @type {import('next').NextConfig} */
const nextConfig = {
async rewrites() {
return [{
source: '/api/backend/:path*',
destination: `${process.env.BACKEND_URL || 'http://localhost:5000'}/api/:path*`,
}]
},
}
module.exports = nextConfignpm install fails:
node --version # must be 18+
npm --version # must be 9+Frontend can't reach backend (CORS error):
- Make sure Flask is running: http://127.0.0.1:5000/health
- Check
frontend/.env.localhasBACKEND_URL=http://localhost:5000 - Restart both servers after changing
.env
"Project not found" error: The project hasn't finished indexing or errored. Check:
curl http://localhost:5000/api/ingest/status/your_project_idFAISS indexes are cached. To force re-index:
# Delete the index files
rm backend/faiss_indexes/project_name.*Then ingest the project again from the UI.
LLM_PROVIDER=groq
LLM_MODEL=llama3-8b-8192 # 8b is 3-4x faster than 70b
GROQ_API_KEY=gsk_...
EMBEDDING_PROVIDER=huggingface
HF_EMBED_MODEL=sentence-transformers/all-MiniLM-L6-v2
SENTENCE_TRANSFORMERS_HOME=./model_cache
VECTOR_STORE=faiss
TOP_K=5 # fewer chunks = faster
MULTI_QUERY_COUNT=0 # disable for speed
USE_RERANKER=false| Operation | Fast config | Default config |
|---|---|---|
| First run (model download) | 1β2 min | 1β2 min |
| Subsequent starts | 3β5s | 3β5s |
| Index small repo (30 files) | ~20s | ~45s |
| Index medium repo (100 files) | ~1 min | ~3 min |
| Query response | 2β4s | 5β10s |
If indexing a very large repo (500+ files), increase chunking:
MAX_CHUNK_TOKENS=600
TOP_K=6Use mixtral-8x7b-32768 for its larger context window:
LLM_MODEL=mixtral-8x7b-32768- GitHub OAuth β index private repos
- Conversation memory β multi-turn chat that remembers context
- Code diff analysis β "What changed between these two commits?"
- Dependency graph β visual map of how files connect
- VS Code extension β query DevBrain directly from your editor
- Multiple repo support β ask questions across multiple projects
- Export answers β save conversations as markdown
- Webhook indexing β auto re-index on git push
MIT License β free to use, modify, and distribute.
Built with:
- LangChain β RAG framework
- Tree-sitter β Code parsing
- Groq β Fast LLM inference
- FAISS β Vector similarity search
- sentence-transformers β Local embeddings
- Next.js β Frontend framework
CodeAtlas β Because reading code shouldn't take weeks