| title | GitRAG API |
|---|---|
| emoji | π |
| colorFrom | indigo |
| colorTo | purple |
| sdk | docker |
| pinned | false |
| license | mit |
| app_port | 7860 |
Ask natural-language questions about any public GitHub repository β and get answers grounded in actual source code, with exact file paths and line numbers.
Live demo: gitrag.vercel.app Β Β·Β API: yanou16-gitgub-rag.hf.space
GitHub repo
β
βΌ
AST-aware chunking β splits files into semantic units (functions, classes)
β
βΌ
Embeddings (text-embedding-3-small) + BM25 index
β
βΌ
Hybrid retrieval (semantic + BM25 β Reciprocal Rank Fusion)
β
βΌ
Cohere reranking β cross-encoder rescores top 20 β keeps best 5
β
βΌ
Groq llama-3.3-70b β generates a grounded answer with file citations
Supported languages: Python, JavaScript/TypeScript, C#, Java, C/C++, Go, Rust, Ruby, PHP, Swift, Kotlin, Dart, Vue, Svelte, Shell, SQL, HTML, CSS, JSON, YAML, TOML, XML
gitrag/
βββ app/ # FastAPI backend
β βββ main.py # App entry point, middleware, CORS
β βββ config.py # Settings via environment variables
β βββ routes/
β β βββ ingest.py # POST /ingest β clone, chunk, embed, store
β β βββ query.py # POST /query β hybrid search + rerank + LLM
β β βββ health.py # GET /health β liveness check
β βββ services/
β β βββ github.py # GitHub API client (file listing + content fetch)
β β βββ chunker.py # AST-aware code chunking
β β βββ embedder.py # OpenAI-compatible embedding service
β β βββ vector_store.py # ChromaDB wrapper (upsert, similarity search)
β β βββ hybrid_search.py # BM25 + semantic β RRF fusion
β β βββ reranker.py # Cohere reranking
β β βββ llm.py # Groq LLM answer generation
β βββ models/
β β βββ schemas.py # Pydantic request/response models
β βββ utils/
β βββ hashing.py # URL β stable repo_id
β βββ retry.py # Async retry decorator
βββ frontend/ # React + Vite frontend (deployed on Vercel)
β βββ src/
β β βββ components/ # Navbar, Hero, HowItWorks, Tool, Footer
β β βββ api.js # API client (ingestRepo, queryRepo)
β β βββ App.jsx
β βββ tailwind.config.cjs
β βββ vite.config.js
βββ tests/ # pytest integration tests (40 tests)
βββ Dockerfile # Production image for HuggingFace Spaces
βββ docker-compose.yml # Local dev with Docker
βββ requirements.txt
- Python 3.13+
- API keys: OpenAI-compatible embeddings, Groq, Cohere (optional)
git clone https://github.com/yanou16/Git_RAG.git
cd Git_RAG
# Backend
cp .env.example .env # fill in your API keys
pip install -r requirements.txt
uvicorn app.main:app --reload --port 8000
# Frontend (separate terminal)
cd frontend
npm install
npm run dev # http://localhost:3000docker compose up --buildIndex a public GitHub repository.
{
"repo_url": "https://github.com/tiangolo/fastapi",
"branch": "master",
"force_reindex": false
}Response:
{
"repo_id": "abc123",
"files_indexed": 87,
"chunks_stored": 1243,
"duration_ms": 18420,
"was_cached": false
}Ask a question about an indexed repository.
{
"repo_url": "https://github.com/tiangolo/fastapi",
"question": "How does dependency injection work?",
"use_hybrid": true,
"use_reranking": true
}Response:
{
"answer": "Dependency injection in FastAPI works via...",
"sources": [
{
"file_path": "fastapi/dependencies/utils.py",
"start_line": 145,
"excerpt": "...",
"rerank_score": 0.92
}
],
"pipeline": "hybrid+rerank",
"tokens_used": 1247,
"latency_ms": 1834
}{ "status": "ok", "version": "1.0.0" }- Fork this repo
- Create a Space at huggingface.co/spaces with Docker SDK
- Add your HF Space as a git remote:
git remote add hf https://huggingface.co/spaces/<user>/<space> - Set secrets in Space Settings:
| Secret | Description |
|---|---|
ANIMUSAI_API_KEY |
OpenAI-compatible key for text-embedding-3-small |
ANIMUSAI_BASE_URL |
e.g. https://api.openai.com/v1 |
GROQ_API_KEY |
console.groq.com |
COHERE_API_KEY |
Optional β enables reranking |
GITHUB_TOKEN |
Optional β raises rate limit from 60 to 5000 req/h |
- Push:
git push hf main
- Import the repo on vercel.com
- Set Root Directory to
frontend - Add env var:
VITE_API_URL=https://<your-space>.hf.space - Deploy
pip install -r requirements-dev.txt
pytest tests/ -v40 integration tests covering ingest, query, chunking, hybrid search, and health endpoints.
| Layer | Technology |
|---|---|
| API | FastAPI + Uvicorn |
| Embeddings | OpenAI text-embedding-3-small |
| Vector store | ChromaDB (persistent) |
| Keyword search | BM25 (rank-bm25) |
| Fusion | Reciprocal Rank Fusion |
| Reranking | Cohere rerank-v3.5 |
| LLM | Groq llama-3.3-70b-versatile |
| Frontend | React + Vite + Tailwind CSS |
| Hosting | HuggingFace Spaces (backend) + Vercel (frontend) |
Rayane Louzazna β LinkedIn Β· GitHub
MIT License