PDF Chat
RAG - Document AI - Authenticated SaaS
A production-grade RAG system where authenticated users upload PDFs and get grounded, citation-backed answers, built with hybrid retrieval, reranking, and persistent memory.
Problem
Generic RAG returns answers that sound plausible but cannot be checked. For document Q&A that is the whole problem: if a reader cannot trace a claim back to a page, the answer is not usable.
Approach
Hybrid retrieval rather than vector-only: BM25 for exact and rare terms, multilingual-E5 dense embeddings for meaning, fused with reciprocal rank fusion, then reranked with a BGE cross-encoder. Chunking preserves page provenance so every answer carries a citation, with neighbour chunk expansion for surrounding context and acronym-aware query expansion for domain shorthand.
Trade-off
I built the retrieval orchestration myself instead of using LangChain end to end, using it only for text splitting and LangSmith for tracing. That is more code to own, but chunking strategy, fusion weighting and rerank depth are exactly the parts worth controlling directly.
Architecture
Full-stack pipeline: FastAPI + Supabase (auth/storage/postgres), ChromaDB vector store, multilingual-E5 embeddings, PyMuPDF + Tesseract OCR ingestion, LangChain text splitters with page-provenance preservation, hybrid BM25 + dense retrieval fused with RRF, BGE cross-encoder reranking, neighbour chunk expansion, acronym-aware query expansion, persisted multi-turn memory, comparative document analysis, auto-generated summaries, LangSmith observability, and OpenRouter LLM routing, all surfaced through a React/TypeScript citation-aware chat UI.
Results
Grounded answers with page-level citations, cross-document comparison and auto-summaries. LangSmith tracing earned its place in production: responses were silently coming back empty, and the trace showed the model’s thinking mode consuming the entire completion token budget before it could answer.
Highlights
- Page-level citations with provenance-preserving chunking
- Persistent multi-turn chat memory
- Authenticated upload and session management
Technologies
- React
- TypeScript
- FastAPI
- Supabase
- ChromaDB
- Sentence Transformers
- LangSmith
- OpenRouter
Screenshots


