Grounded
Retrieval-grounded answers that cite every claim
Stack
Frontend
- React 18 + Vite reader panel
- Angular 18 ingestion admin
- TypeScript
- Citation-aware answer rendering
Backend & Data
- Supabase
- PostgreSQL
- Similarity search over stored embeddings
- Deno Edge Functions
- Row-level security
- Server-held model credentials
Problem
Document Q&A that answers from a model's memory can't be trusted in a certification-learning business. Answers had to come only from curated source content, with citations a reader can check — and ingestion had to be manageable through an admin surface, not a deploy.
What I built
- A monorepo split by audience: a reader panel, a login-gated ingestion admin, and one backend serving both.
- An ingestion pipeline: text extraction, chunking with overlap, and embedding into a vector knowledge base through the admin panel.
- Retrieval through a single matching function, so the query path has one place to tune and one place to audit.
- Generation constrained to numbered retrieved passages, with every claim carrying its citation.
- Multimodal grounding end to end: image captions drive retrieval while the image itself travels as an inline part.
Technical decisions & trade-offs
- Embedding and retrieval sit behind the database layer rather than in the client, so the ingestion format and the query path can change without touching either frontend.
- The model key lives in Edge Function secrets, so no model call ever originates in a client bundle.
- Row-level security grants anonymous read and admin-only write, and the service-role decision lives in one auditable module rather than smeared across handlers.
- Grounding is enforced structurally: the model only ever sees retrieved passages, so ungrounded answers cannot happen rather than being discouraged.
- Two frontends over one backend instead of one app with role switches, so the reader surface stays anonymous and cacheable.
Challenges solved
- Chunk-boundary tuning: enough overlap to keep answers coherent across boundaries, without bloating the context sent to the model.
- Multimodal grounding — captions retrievable as text while the source image rides along inline, so citations stay meaningful for figures.
Outcome
In production. Every sentence traces to a cited passage and ungrounded output is structurally impossible. The pattern became the reference architecture for retrieval work on the team.