Upload PDF documents, ask questions in natural language, and get accurate, grounded answers with source citations — powered by Retrieval-Augmented Generation.
- Upload a PDF document via drag-and-drop
- Ask any natural language question about it
- Get a grounded AI answer with exact page references
No hallucinations — every answer is backed by retrieved text chunks from your documents.
graph TD
User["👤 User (Browser)"]
SL["Streamlit UI\n(streamlit_app.py)"]
API["FastAPI Backend\n(src/app.py)"]
EMB["Embedding Service\n(Gemini / sentence-transformers)"]
VS["Vector Store\n(Qdrant Cloud / FAISS)"]
LLM["LLM\n(Google Gemini 1.5 Flash)"]
User -->|Upload PDF / Ask question| SL
SL -->|REST API calls| API
API -->|Chunk + embed document| EMB
EMB -->|Store vectors| VS
API -->|Similarity search| VS
VS -->|Top-K chunks| API
API -->|Prompt + context| LLM
LLM -->|Grounded answer| API
API -->|Answer + sources| SL
SL -->|Display answer| User
| Choice | Rationale |
|---|---|
| FastAPI backend | Async, production-grade, auto-generates OpenAPI docs |
| Pluggable vector store | FAISS for local dev, Qdrant Cloud for production — same interface |
| Pluggable embeddings | sentence-transformers locally, Gemini API in cloud (no large model download) |
| RAG over fine-tuning | Documents can be updated without retraining; answers are always grounded |
| Streamlit frontend | Rapid UI, no JavaScript — lets the AI engineering shine |
| Feature | Details |
|---|---|
| 📄 PDF ingestion | Automatic text extraction, chunking with configurable overlap |
| 🔍 Semantic search | Vector similarity search over embedded document chunks |
| 💡 Grounded answers | Every answer cites source document + page number |
| 🎯 Document filtering | Query all documents or a specific one |
| 🔁 Duplicate detection | Smart re-upload with replace option |
| 💬 Conversation history | Full session tracking with confidence scores |
| 🔧 Health monitoring | Real-time component status in the UI sidebar |
| 🐳 Docker ready | Multi-stage Dockerfile, docker compose up for full local stack |
| ☁️ Cloud Run ready | Deploy to GCP with gcloud builds submit |
- Python 3.11+
- uv (
pip install uv) - A Google Gemini API key
git clone https://github.com/your-username/docqa.git
cd docqa
uv venv && .venv\Scripts\activate # Windows
uv pip install -e .cp .env.example .env
# Edit .env and set GEMINI_API_KEY=your_key_here# Terminal 1 — FastAPI backend
python -m uvicorn src.app:app --reload
# Terminal 2 — Streamlit UI
streamlit run streamlit_app.pyOpen http://localhost:8501 — upload a PDF and start asking questions.
# Copy and fill in your API key
cp .env.example .env
# Start Qdrant + FastAPI backend
docker compose up
# Then in a separate terminal:
API_BASE_URL=http://localhost:8080 streamlit run streamlit_app.pyDeploys a fully stateless backend using Gemini embeddings (no local model) and Qdrant Cloud (free tier).
Sign up at cloud.qdrant.io and create a free cluster. Copy the cluster URL and API key.
gcloud auth login
gcloud config set project YOUR_PROJECT_ID
gcloud services enable cloudbuild.googleapis.com run.googleapis.comgcloud builds submit --config cloudbuild.yaml .In the GCP console, add these env vars to your Cloud Run service:
GEMINI_API_KEYQDRANT_URLQDRANT_API_KEY
On Streamlit Community Cloud, set the secret:
API_BASE_URL = https://docqa-backend-xxxx-uc.a.run.app
docqa/
├── src/
│ ├── app.py # FastAPI endpoints
│ ├── config.py # Config (env-variable driven)
│ ├── ingestion.py # PDF → chunks pipeline
│ ├── embeddings.py # Embedding provider abstraction
│ ├── interfaces.py # VectorStore abstract interface
│ ├── vector_store.py # FAISS implementation
│ ├── qdrant_vector_store.py # Qdrant implementation
│ ├── query_engine.py # Retrieval + ranking
│ ├── answer_generator.py # LLM prompt + generation
│ └── ui_utils.py # Streamlit API client
├── tests/ # pytest test suite
├── demo/
│ └── DEMO_QUESTIONS.md # Sample questions for demos
├── streamlit_app.py # Streamlit frontend
├── Dockerfile # Multi-stage production image
├── docker-compose.yml # Local full-stack (Qdrant + backend)
├── cloudbuild.yaml # GCP Cloud Run CI/CD
└── .env.example # Config template (LOCAL + CLOUD sections)
pytest tests/ -vSee demo/DEMO_QUESTIONS.md for a tiered set of demo
questions (factual retrieval → synthesis → edge cases) with tips on what to
highlight for each.
- Python 3.11+
- Google Gemini API key
- (Cloud) Qdrant Cloud free tier account
- (CI/CD) Google Cloud project with Cloud Build + Cloud Run APIs enabled