Problem
Insurance policy answers are often spread across clauses, exclusions, limits, waiting periods, and conditions. A simple answer without evidence is not enough.
AI/RAG Case Study
A practical RAG case study where users upload insurance policy PDFs, ask natural-language questions, and verify answers through citation-backed source excerpts.
Next.js App Router • TypeScript • PostgreSQL • pgvector • Drizzle • PDF Parsing • Hybrid Retrieval • LLM APIs • Vercel Serverless
Insurance policy answers are often spread across clauses, exclusions, limits, waiting periods, and conditions. A simple answer without evidence is not enough.
I built a RAG workflow where users upload a policy PDF, ask natural-language questions, and verify answers through citation-backed source excerpts.
The hard part in document AI is not only retrieval. It is retrieving enough evidence, grounding the answer, and helping users trust what the system says.
The product flow is intentionally guided. Users should know when the document is uploaded, processed, searchable, and ready for citation-backed questions.
I treated the system as a pipeline with clear responsibilities: ingestion, parsing, chunking, embedding storage, retrieval, answer generation, and citation rendering.

Handled policy PDF upload, text extraction, document processing states, and preparation for downstream retrieval.
Split document text into searchable chunks while trying to preserve clause-level meaning and enough surrounding context.
Stored embeddings and retrieval metadata in PostgreSQL with pgvector so policy content could be searched semantically.
Combined semantic retrieval with lexical/contextual signals so the system is not dependent on vector similarity alone.
Generated answers only from retrieved evidence, with source excerpts and citations shown back to the user.
Designed the UX so users can inspect the supporting clauses instead of blindly trusting a generated answer.
The goal was not to build a generic chatbot over a PDF. The goal was to make document intelligence useful in a domain where correctness, citations, and user trust matter.
Focused on showing source excerpts with answers because insurance is a trust-sensitive domain where users need to verify the reasoning.
Kept the answer generation layer dependent on retrieved evidence, instead of letting the LLM answer from general knowledge.
Treated chunking as a product and retrieval decision, not only a text-splitting task, because policy meaning often depends on nearby clauses.
Used retrieval thinking that combines semantic similarity with keyword and context matching to improve recall on clause-heavy documents.
Designed the demo around scoped workspaces/sessions and temporary document retention so user documents are not treated casually.
Kept ingestion, parsing, chunking, retrieval, answer generation, and citations as separate concerns so each layer can evolve independently.
In document AI, a relevant chunk is not always enough. The answer needs enough evidence, clear citations, and honest boundaries when the document does not contain enough information.
Users should be able to inspect the exact source excerpts used to generate an answer.
When retrieved evidence is weak or incomplete, the product should avoid pretending it knows the answer.
The upload → parse → ready-to-query flow helps users understand when the document is actually prepared for questions.
Policy questions often require comparing limits, waiting periods, exclusions, and conditions rather than reading one isolated line.
A serious RAG system needs evaluation beyond “the answer looks good.” These are the signals I would track as the product matures.
I’m open to meaningful conversations around document AI, RAG workflows, retrieval quality, citation-grounded answers, and trust-first AI product experiences.
Start a Conversation