A production-ready RAG (Retrieval-Augmented Generation) platform for technical documentation, specializing in API documentation discovery and code example generation. Built with FastAPI (Async), Google Gemini, and ChromaDB.
Note: This project has been migrated from Flask/OpenAI to a high-performance FastAPI/Gemini architecture.
- ⚡ High-Performance Architecture: Fully async implementation using FastAPI,
httpx, andasyncpg. - 🧠 Advanced RAG Engine: Hybrid search using Google Gemini Embeddings and ChromaDB.
- 🤖 Intelligent Discovery: Automatically crawls and indexes documentation (Sitemaps, OpenAPI/Swagger, HTML).
- 📝 Code Generation: Uses Gemini 1.5 Flash to generate accurate code examples in 8+ languages (Python, Node.js, cURL, etc.).
- 🛡️ Production Ready: Features rate limiting, security headers, JSON logging, and Docker/Railway compatibility.
- Backend: Python 3.11+, FastAPI (Async)
- AI/LLM: Google Gemini (
gemini-1.5-flash),google-genaiSDK - Vector DB: ChromaDB (Persistent)
- Database: PostgreSQL (Metadata & History) via
SQLAlchemy 2.0(Async) - Processing:
BeautifulSoup4,Trafilatura(Content Extraction)
.
├── app/
│ ├── api/ # FastAPI Routes & Dependencies
│ ├── core/ # RAG Engine & Logging
│ ├── db/ # Database Models & Connections
│ ├── services/ # Document Processor & Crawler
│ └── utils/ # Validators & Helpers
├── scripts/
│ ├── ingest.py # Document Ingestion Script
│ ├── reset_chroma.py # Utility to clear Vector DB
│ └── fix_collation.sql # Maintenance scripts
├── config.py # Central Configuration
├── fastapi_app.py # Application Entrypoint
├── Procfile # Railway Deployment Config
└── pyproject.toml # Dependencies
- Python 3.11+
- Google Gemini API Key
- PostgreSQL (Optional, defaults to SQLite for local)
# Clone and enter directory
git clone <repo-url>
cd rag-documentation-assistant
# Create virtual environment
python -m venv .venv
# Windows:
.venv\Scripts\Activate.ps1
# Linux/Mac:
source .venv/bin/activate
# Install dependencies
pip install -r requirements.txtCreate a .env file based on .env.example:
# AI Provider
AI_PROVIDER=gemini
GEMINI_API_KEY=your_gemini_key_here
# Database (Default: SQLite)
DATABASE_URL=sqlite:///docrag.db
# Vector DB
CHROMA_DB_PATH=./chroma_db# Initialize DB (Automatic on startup) and Start Server
uvicorn fastapi_app:app --reloadApp will be ready at http://localhost:8000.
To populate the vector database with documentation:
# Discover APIs automatically
API_DISCOVERY_ENABLED=true python scripts/ingest.py --discover-apis
# OR Ingest a specific URL
python scripts/ingest.py --url https://fastapi.tiangolo.com/If you face "dimension mismatch" errors or want to re-index:
- Stop the running server (Ctrl+C).
- Run the reset script:
python scripts/reset_chroma.py
- Restart server and re-ingest.
We use Alembic for schema migrations (if using Postgres):
alembic upgrade headThe project is configured for Railway out of the box using Procfile.
- Push to GitHub.
- Connect repository to Railway.
- Add
GEMINI_API_KEYand other variables in Railway Service Settings. - Attach a PostgreSQL plugin (optional but recommended for production).
- Deploy!
MIT