RAG Starter Kit
Citation-grounded document Q&A for SMBs, gated by an automated eval suite.
Architecture
How it works
- Next.js chat UI
- FastAPI
- LangGraph retrieval node
- pgvector similarity search
- LLM synthesis + citations
Ingest
Documents (PDFs, DOCX, email exports) go through the FastAPI backend, get chunked with LlamaIndex, embedded with OpenAI's text-embedding-3-small, and stored in Postgres — each chunk's embedding lives in a pgvector Vector(1536) column next to the source document and page number it came from.
Ask
The Next.js chat UI sends the question to FastAPI, which hands it to a LangGraph retrieval node — a small state graph rather than a single hard-coded function, so the retrieval logic can grow branches later without a rewrite.
Retrieve
The node embeds the incoming question and runs a similarity search against pgvector to pull back the chunks most relevant to it.
Synthesize
Those chunks go to the LLM with instructions to answer only from what was retrieved and attach a citation — source document and page — to every claim, so nothing in the answer is unsourced.
Trace
Every step of that call — retrieval, synthesis, latency, token counts — is logged to Langfuse, so any single run can be pulled up and inspected after the fact.
Gate
Before any change ships, a DeepEval golden set of 20-30 real question/answer pairs runs against the retrieval pipeline in CI. If precision drops below threshold, the build fails and the deploy is blocked — the eval isn't a report, it's a gate.
Information
SMBs (law firms, clinics, agencies) have policies, SOPs, and past client emails scattered across drives with no searchable interface.
- FastAPI
- Next.js
- Postgres + pgvector
- LangGraph
- LlamaIndex
- Langfuse
- DeepEval