AI-powered developer assistant that lets you ask natural language questions about any GitHub repository and get answers with exact file paths and line numbers.
DevLens is a backend API that enables developers to chat with any GitHub codebase using natural language. Instead of manually searching through hundreds of files, you paste a repository URL, wait for indexing, and start asking questions.
Example:
β "Where is the database connection handled in this project?"
β "The database connection is handled in
app/database.pyat lines 15β28. It uses SQLAlchemy'screate_engine()with a connection pool..."
The system retrieves the exact file, line numbers, and a code snippet β grounded in the real source code, not hallucinated.
- π Load any public GitHub repo β just paste the URL
- π§ RAG pipeline β answers are grounded in actual code, not guessed
- β‘ SSE streaming β Gemini responses stream token-by-token
- π Source attribution β every answer includes file path + line numbers
- ποΈ Namespace isolation β multiple repos indexed independently in Pinecone
- π©Ί Health check endpoint β live probes for Pinecone and Gemini
- π³ Dockerized β runs with a single
docker compose upcommand
User Question
β
βΌ
POST /api/v1/ask-question
β
βΌ
βββββββββββββββββββββββββββββββββββββββββββββββββββ
β RAG Pipeline β
β β
β Question β Embed (text-embedding-004) β
β β Search Pinecone (cosine similarity) β
β β Top-K code chunks retrieved β
β β Build grounded prompt β
β β Gemini 1.5 Pro generates answer β
β β SSE stream β client β
βββββββββββββββββββββββββββββββββββββββββββββββββββ
POST /api/v1/load-repo
β
βΌ
βββββββββββββββββββββββββββββββββββββββββββββββββββ
β Indexing Pipeline β
β β
β GitHub URL β GitPython shallow clone β
β β LangChain TextLoader β
β β RecursiveCharacterTextSplitter β
β β Google text-embedding-004 β
β β Pinecone upsert (namespaced) β
βββββββββββββββββββββββββββββββββββββββββββββββββββ
| Layer | Technology | Purpose |
|---|---|---|
| Web Framework | FastAPI 0.111 | Async API with auto OpenAPI docs |
| LLM | Google Gemini 1.5 Pro | Answer generation |
| Embeddings | text-embedding-004 | 768-dim semantic code vectors |
| Vector DB | Pinecone (Serverless) | Fast cosine similarity search |
| Orchestration | LangChain 0.2 | Chunking, loading, retrieval |
| Repo Loading | GitPython 3.1 | Shallow git clone at runtime |
| Streaming | SSE (sse-starlette) | Token-by-token streaming |
| Logging | structlog 24.2 | Structured JSON logs |
| Containerisation | Docker + Compose | One-command deployment |
devlens/
β
βββ backend/
β βββ .env # Environment variables (never commit)
β βββ Dockerfile # Multi-stage production image
β βββ requirements.txt # Pinned Python dependencies
β βββ app/
β βββ main.py # FastAPI app factory + startup
β βββ schema.py # All Pydantic request/response models
β βββ helpers.py # Pure utility functions
β βββ api/
β β βββ health.py # GET /health
β β βββ routes.py # POST /load-repo, /ask-question
β βββ core/
β β βββ config.py # Pydantic-settings env loader
β β βββ rag_pipeline.py # Central RAG orchestrator
β βββ services/
β βββ repo_loader.py # Clone + LangChain document loading
β βββ embeddings.py # Pinecone setup + Google embeddings
β βββ retriever.py # Semantic search over namespace
β
βββ docker-compose.yml
βββ Makefile
βββ README.md
- Python 3.11 (3.14 is not yet supported by all dependencies)
- Git installed on your system
- Google AI Studio API key (free tier works)
- Pinecone account + API key (free starter plan works)
git clone https://github.com/your-username/devlens.git
cd devlens/backend# Windows
py -3.11 -m venv .venv
.venv\Scripts\activate
# macOS / Linux
python3.11 -m venv .venv
source .venv/bin/activatepip install -r requirements.txtcp .env .env.local # or just edit .env directlyOpen .env and fill in your keys:
GOOGLE_API_KEY=your_google_api_key_here
PINECONE_API_KEY=your_pinecone_api_key_here
PINECONE_INDEX_NAME=devlens-codebase
PINECONE_CLOUD=aws
PINECONE_REGION=us-east-1uvicorn app.main:app --reload --host 0.0.0.0 --port 8000Open http://localhost:8000/docs to access the interactive Swagger UI.
# Build and start
docker compose up --build
# Backend β http://localhost:8000
# Swagger β http://localhost:8000/docs
# Tail logs
docker compose logs -f backend
# Stop
docker compose downCheck live connectivity status of Pinecone and Gemini.
{
"status": "ok",
"environment": "development",
"version": "1.0.0",
"services": {
"pinecone": "ok",
"gemini": "ok (47 models visible)"
}
}Clone, chunk, embed, and index a GitHub repository into Pinecone.
Request:
{
"repo_url": "https://github.com/tiangolo/fastapi",
"branch": "master"
}Response:
{
"status": "ready",
"namespace": "tiangolo_fastapi-a3f2c8d91b4e",
"repo_name": "tiangolo_fastapi",
"total_chunks": 842,
"message": "Repository 'tiangolo_fastapi' indexed successfully. 842 code chunks are ready for querying."
}
β οΈ Save thenamespacevalue β you need it for/ask-question.
Ask a natural language question about the indexed codebase.
Request:
{
"question": "Where is the database connection handled?",
"namespace": "tiangolo_fastapi-a3f2c8d91b4e"
}SSE Event Stream:
event: token
data: The database connection is handled in
event: token
data: app/db/session.py at lines 12β28...
event: sources
data: [{"file_path":"app/db/session.py","start_line":12,"end_line":28,"snippet":"..."}]
event: done
data: [DONE]
Same as above but returns a single JSON response. Useful for testing.
GET /api/v1/ask-question?question=Where is auth handled?&namespace=your_namespace
| Variable | Default | Description |
|---|---|---|
GOOGLE_API_KEY |
β | Google AI Studio key (required) |
PINECONE_API_KEY |
β | Pinecone API key (required) |
PINECONE_INDEX_NAME |
devlens-codebase |
Auto-created on first use |
PINECONE_CLOUD |
aws |
Cloud provider for serverless index |
PINECONE_REGION |
us-east-1 |
Must match your Pinecone project |
APP_ENV |
development |
development or production |
CHUNK_SIZE |
1000 |
Max characters per code chunk |
CHUNK_OVERLAP |
150 |
Overlap between consecutive chunks |
TOP_K_RESULTS |
6 |
Chunks retrieved per question |
EMBEDDING_DIMENSION |
768 |
text-embedding-004 output size |
REPO_CLONE_DIR |
/tmp/devlens_repos |
Temp dir for clones |
Once the server is running, test the full pipeline in order:
# 1. Health check
curl http://localhost:8000/health
# 2. Index a repo (takes 30β90s depending on repo size)
curl -X POST http://localhost:8000/api/v1/load-repo \
-H "Content-Type: application/json" \
-d '{"repo_url": "https://github.com/tiangolo/fastapi", "branch": "master"}'
# 3. Ask a question (copy namespace from step 2 response)
curl "http://localhost:8000/api/v1/ask-question?question=Where+is+routing+handled&namespace=YOUR_NAMESPACE"- GitHub repo loading with GitPython
- Code chunking with LangChain RecursiveCharacterTextSplitter
- Google text-embedding-004 vector embeddings
- Pinecone serverless vector store with namespace isolation
- Gemini 1.5 Pro grounded answer generation
- SSE streaming responses
- Source attribution (file path + line numbers)
- Health check with live service probes
- Docker + docker-compose setup
- Next.js frontend with chat UI
- File explorer sidebar with code preview pane
- API key authentication
- Namespace management (list / delete indexed repos)
- Rate limiting
Ali Sajid
AI Engineer | Deep Learning | Computer Vision | GEN AI
Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.
- Fork the repository
- Create your feature branch:
git checkout -b feature/my-feature - Commit your changes:
git commit -m 'Add some feature' - Push to the branch:
git push origin feature/my-feature - Open a Pull Request
This project is licensed under the MIT License β see the LICENSE file for details.
Built with β€οΈ using FastAPI Β· LangChain Β· Google Gemini Β· Pinecone