Build a document Q&A app that cites its work
A retrieval-first recipe for uploading documents, finding relevant passages, answering with citations, and refusing when the evidence is weak.
Built for: Builders creating a private knowledge assistant, policy finder, research workspace, or customer document portal.
Not for: A general chatbot, an unsupervised legal or medical decision system, or a product that promises perfect answers from poor source material.
The outcome
Know what “built” means.
A user can upload an allowed document, ask a question, inspect the supporting passages, and see an honest “not enough evidence” response.
01 · Upload & answer UI
Lovable
Build document management, ingestion status, questions, answers, and citation views.
02 · Documents & vectors
Supabase
Store files, document metadata, text chunks, embeddings, and row-level access rules.
03 · Extraction & answers
OpenAI API
Extract or normalize text, create embeddings, and compose an answer from retrieved evidence.
04 · Ingestion worker
Railway
Process uploads, split text, create embeddings, retry failures, and report progress.
05 · Web deployment
Vercel
Host the customer-facing application and fast question endpoints.
06 · Workspace access
Clerk
Manage organization membership and invitations when document libraries are shared.
Links marked Paid link may earn Angry Abes Apps, LLC a commission. Compensation never changes the selected stack or verdict. Full disclosure.
How the pieces move
Build order
Do the risky work first.
Start with an evaluation set
Collect 30 real questions: answerable, ambiguous, and impossible. Record the exact passages a careful human would use.
Build visible ingestion
Show uploaded, processing, ready, and failed states. Save the parser version and a content checksum so reprocessing is deliberate.
Retrieve before generating
Filter by owner and document, fetch a small set of passages, and score whether the evidence clears a useful threshold.
Make citations navigable
Attach document, page or section, and quoted passage references to each answer. Let users open the source around the cited text.
Tune refusal behavior
When evidence is missing or contradictory, say so and suggest the next useful question or document.
Change the stack when the constraint changes
Tiny document set and fastest prototype
Supabase pgvector pipeline Use hosted file search
A managed retrieval tool reduces ingestion code while you validate the experience.
Complex parsers or large files
Single Railway worker Split parsing and embedding jobs
Separate queues make retry cost and failure ownership clearer.
Single-user private prototype
Clerk organizations Use Supabase Auth only
Avoid team-account complexity until shared libraries are a real requirement.
Non-negotiable guardrails.
Authorize before retrieval
Filtering after vector search can leak the existence or content of another customer’s document.
Treat uploads as untrusted
Validate file type and size, isolate parsing, and never execute embedded content.
Separate evidence from prose
Store retrieved passages and generated answers independently so citations can be audited and answers can be regenerated.
Quick answers
Questions before you commit.
Do I need a separate vector database?+
Not for most first versions. If the rest of the product already fits Postgres, pgvector keeps permissions, metadata, and retrieval close together. Add specialized infrastructure only when measured scale or retrieval requirements demand it.
How large should document chunks be?+
There is no universal size. Start from the structure of your documents and evaluation questions, preserve headings and page references, and test whether each retrieved chunk contains enough context to support a citation.
Can citations still be wrong?+
Yes. A citation may be real but not support the claim. Evaluate whether the cited passage actually entails the answer, and make source inspection easy for the user.
Official sources checked
Feature, pricing, policy, and compatibility details can change. We link the primary sources used for the factual foundation; the sequence, tradeoffs, and verdict are original AbesBot analysis.