DocuMind AI
Ask a PDF a question and see the page the answer came from — every claim is cited, and when the document doesn’t say, it says so.

The problem
A chat box over a document is only useful if you can check it. So the brief was strict: every claim cites its document and page, the passage is highlighted on the page itself, and a question the document doesn’t answer gets “it doesn’t say”, not a confident guess.
What I built
A retrieval-augmented Q&A app. A FastAPI backend reads each PDF page by page and indexes the passages; a Gemini model may answer only from the best matches, with citations, and every citation is checked against what it was actually given. A Next.js front end streams the answer and shows the cited page, highlighted.
What I learned
That “I don’t know” can’t be a similarity threshold: questions the document nearly answers score like ones it does, so declining needs the model’s grounding check plus citation validation.
Watch it work
Overview
DocuMind answers questions about PDFs and shows its working. Upload a text-based PDF (up to 20 MB), ask in plain language, and the answer streams in with citations; select one and the exact passage is highlighted on the rendered page. Tick several PDFs and one question is answered across all of them, each citation naming its document and page. If the documents don’t contain the answer, it says so.
Features
Citations you can check
Every claim carries a citation to its document and page. The backend renders the cited page and highlights the passage, so checking an answer takes one click.
Declines instead of guessing
Clearly off-topic questions are turned away before the model is called. For questions the documents come close to but don’t cover, a grounding check declines, and an answer without a valid citation is withheld.
Several PDFs at once
Passages are retrieved from each ticked document and merged by similarity, and every citation names the document it came from.
Streaming, then verified
Answers appear word by word. The final event is validated and authoritative, so a draft that fails the citation check is corrected rather than left on screen.
Honest about its limits
Scanned PDFs are detected and rejected with a pointer to OCR instead of being answered badly. Large files upload straight to storage to get past serverless request limits.
How it's put together
- 01Text is extracted page by page, repeated headers and footers are stripped, and chunks never cross a page boundary, so every citation’s page number is exact.
- 02Each passage is embedded locally with all-MiniLM-L6-v2 and kept in a per-document FAISS index; the question is embedded the same way and the closest passages are retrieved.
- 03Gemini sees only the retrieved passages, labelled S1 to Sn, and must answer in JSON with inline citations. Citation ids are checked against the passages actually sent, and unknown ones are removed.
- 04If the main model is overloaded or out of quota, the backend retries once and then falls back to the next configured model; each answer reports which model produced it. With no model configured it shows the best passages, labelled as such, and never invents an answer.
- 05A Next.js front end on Vercel calls the FastAPI backend directly, so answers stream without an extra hop. The model key lives only on the server.
- 06The backend has 110 tests: 103 run offline against a scripted model, on every push in CI, and 7 use the real embedding model and run locally. The front end has its own unit tests, with lint, type-check and build in CI too.
Challenges
Making “I don’t know” reliable
A similarity floor turns away off-topic questions, but ones the document nearly answers (“Who is the head librarian?”) score like real ones, so no threshold separates them. Declining relies on the model’s grounding check and on citation validation: it declined 7 of the 8 questions the handbook doesn’t answer.
Big uploads on serverless
A Vercel function takes at most 4.5 MB per request, so the browser sends the PDF straight to private storage with a short-lived token and the API ingests it from there. Verified live with an 8 MB, 30-page file.
Where it landed
A deployed, tested app with a public demo and a written evaluation. On 30 questions about one synthetic 7-page handbook (measured with Gemini 3.1 Flash-Lite), all 22 answerable questions were answered with citations to the expected page and judged correct by hand. That is a smoke test, not a benchmark, and the repo says so, along with what comes next: hybrid search, per-user sessions and OCR. The demo shares one document library between visitors, so try it with the sample documents rather than anything private.
Screens



Want something like this?
Get in touch →