The challenge
Users don't want to read a 60-page PDF to find one answer. But naive LLM approaches hallucinate, and dumping the whole PDF into a prompt is expensive and slow. The product needed reliable retrieval, low-latency chat, and answers grounded in the source — not made up.
The approach
FastAPI ingestion pipeline chunks PDFs and stores OpenAI embeddings in PostgreSQL for semantic search. On query, the closest chunks are retrieved and passed as context to the model, so answers stay grounded in the actual document. Next.js frontend handles upload, streaming chat, and multi-document sessions.