<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Bharat Bhandari</title>
    <description>The latest articles on DEV Community by Bharat Bhandari (@cookncode).</description>
    <link>https://dev.to/cookncode</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F2818071%2F007eeb5d-6057-4019-9770-60e5e1194bdf.jpeg</url>
      <title>DEV Community: Bharat Bhandari</title>
      <link>https://dev.to/cookncode</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/cookncode"/>
    <language>en</language>
    <item>
      <title>InsurIQ - Policy Intelligence Engine</title>
      <dc:creator>Bharat Bhandari</dc:creator>
      <pubDate>Fri, 22 May 2026 08:12:09 +0000</pubDate>
      <link>https://dev.to/cookncode/insuriq-policy-intelligence-engine-2119</link>
      <guid>https://dev.to/cookncode/insuriq-policy-intelligence-engine-2119</guid>
      <description>&lt;p&gt;&lt;em&gt;This is a submission for the &lt;a href="https://dev.to/challenges/github-2026-05-21"&gt;GitHub Finish-Up-A-Thon Challenge&lt;/a&gt;&lt;/em&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  What I Built
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;InsurIQ&lt;/strong&gt; is an agentic platform that acts as an independent insurance expert&lt;br&gt;
for Indian health insurance consumers — helping people &lt;em&gt;actually understand&lt;/em&gt; the&lt;br&gt;
policy they own, without depending on a commission-driven salesperson.&lt;/p&gt;

&lt;p&gt;India's health insurance documents are brutal. A real Policybazaar kit (I tested&lt;br&gt;
with a Niva Bupa ReAssure 2.0 PDF) is 58 pages of dense legal language: policy&lt;br&gt;
wordings, a personalised schedule, an IRDAI-mandated Customer Info Sheet,&lt;br&gt;
marketing filler, and a hospital blacklist — all concatenated into one file,&lt;br&gt;
internally inconsistent, and designed by lawyers, not people.&lt;/p&gt;

&lt;p&gt;The question "Is my mother's knee replacement covered, and when?" requires&lt;br&gt;
assembling:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;The specific-disease 24-month waiting clause (joint replacement is explicitly listed)&lt;/li&gt;
&lt;li&gt;The pre-existing disease (PED) waiting clause&lt;/li&gt;
&lt;li&gt;The &lt;em&gt;meta-rule&lt;/em&gt; that the longer of the two waiting periods shall apply&lt;/li&gt;
&lt;li&gt;AND the room-rent proportionate-deduction interaction&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;...across four different pages, with one clause being a rule about which other&lt;br&gt;
clause wins. This is not a retrieval problem. It's a reasoning problem over&lt;br&gt;
structured legal structure — and getting it wrong causes real financial harm.&lt;/p&gt;

&lt;p&gt;The product has three phases deliberately sequenced:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Post-purchase understanding&lt;/strong&gt; — "What did I actually buy?" ← &lt;em&gt;building this first&lt;/em&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Pre-purchase advisory&lt;/strong&gt; — "Which policy is right for me?"&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Claim assistance&lt;/strong&gt; — "Help me actually get paid."&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Phase 1 is self-contained, has no regulatory exposure (explaining a document the&lt;br&gt;
user already owns), and produces the structured-extraction engine that phases 2&lt;br&gt;
and 3 both depend on.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Tech stack:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Backend: FastAPI + LangGraph 1.1 + LangChain-Groq (&lt;code&gt;uv&lt;/code&gt;-managed monorepo)&lt;/li&gt;
&lt;li&gt;Frontend: Next.js + TypeScript&lt;/li&gt;
&lt;li&gt;DB: PostgreSQL (relational + JSONB)&lt;/li&gt;
&lt;li&gt;Deployed: &lt;a href="https://insuriq.himalayandev.tech" rel="noopener noreferrer"&gt;insuriq.himalayandev.tech&lt;/a&gt;
&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  Demo
&lt;/h2&gt;

&lt;blockquote&gt;
&lt;p&gt;🔗 Live: &lt;a href="https://insuriq.himalayandev.tech" rel="noopener noreferrer"&gt;insuriq.himalayandev.tech&lt;/a&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F4shb9acpgrz5jjl9jkdi.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F4shb9acpgrz5jjl9jkdi.png" alt=" " width="800" height="483"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Upload a health insurance PDF → InsurIQ segments it by document type, runs a&lt;br&gt;
structured extraction pass with full clause-level citations, flags anything&lt;br&gt;
unverifiable, and presents a queryable, grounded policy object — no hallucinated&lt;br&gt;
facts, every answer traceable to the exact source clause.&lt;/p&gt;




&lt;h2&gt;
  
  
  The Comeback Story
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Before — the placeholder that should never have existed
&lt;/h3&gt;

&lt;p&gt;The project started as an exploration into agentic AI with a real use case. The&lt;br&gt;
first node I wrote — &lt;code&gt;src/nodes/insurance_node.py&lt;/code&gt; — took a &lt;code&gt;policy_name&lt;/code&gt; string&lt;br&gt;
and asked the LLM to summarise the policy &lt;em&gt;from its training knowledge&lt;/em&gt;.&lt;/p&gt;

&lt;p&gt;Let that sink in. A health insurance assistant confidently generating policy&lt;br&gt;
facts from LLM memory, with zero grounding in the actual document. Wrong waiting&lt;br&gt;
periods. Hallucinated exclusions. Fabricated sub-limits. This is the exact&lt;br&gt;
failure mode that could cause real harm — someone skips a hospital network check&lt;br&gt;
because the AI said they were covered.&lt;/p&gt;

&lt;p&gt;It was a prototype placeholder, and it was wrong by design.&lt;/p&gt;

&lt;h3&gt;
  
  
  After — grounded, structured, citation-first
&lt;/h3&gt;

&lt;p&gt;The entire extraction architecture was rebuilt from scratch during this&lt;br&gt;
challenge. Key shifts:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;1. Structured extraction over RAG&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;RAG (retrieval-augmented generation) is the obvious first instinct — chunk the&lt;br&gt;
PDF, embed it, retrieve relevant sections. I deliberately rejected it.&lt;/p&gt;

&lt;p&gt;Decision-relevant insurance questions are &lt;em&gt;non-local&lt;/em&gt;. They require assembling&lt;br&gt;
clauses from different pages where one clause controls the interpretation of&lt;br&gt;
another. Top-k chunk retrieval cannot do that reliably. It will confidently&lt;br&gt;
answer wrong.&lt;/p&gt;

&lt;p&gt;Instead: at upload time, run a schema-driven extraction pass &lt;em&gt;once&lt;/em&gt; that&lt;br&gt;
produces a complete, fully-cited policy object. All user questions are answered&lt;br&gt;
by reasoning over that structured object.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;2. Three-layer document model&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;After analysing a real 58-page full policy kit, I identified that a single&lt;br&gt;
uploaded "policy" is actually multiple document types with different trust levels:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Layer&lt;/th&gt;
&lt;th&gt;Source&lt;/th&gt;
&lt;th&gt;Trust&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Wording&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Policy Wordings (legal contract)&lt;/td&gt;
&lt;td&gt;Authoritative for rules&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Schedule&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Insurance Certificate&lt;/td&gt;
&lt;td&gt;Authoritative for &lt;em&gt;this user's&lt;/em&gt; values&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;CIS&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;IRDAI-mandated Customer Info Sheet&lt;/td&gt;
&lt;td&gt;Pre-structured scaffold with clause cross-refs&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Marketing&lt;/td&gt;
&lt;td&gt;Policybazaar cover, simplified sidebars&lt;/td&gt;
&lt;td&gt;Ignore for facts&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;This matters because wording alone misleads. The wording says PED wait is "36&lt;br&gt;
months (48 for Bronze/Silver/Gold)" — but this user's schedule says variant is&lt;br&gt;
&lt;strong&gt;Platinum+&lt;/strong&gt; and PED is &lt;strong&gt;None declared&lt;/strong&gt;. Wording + Schedule together give the&lt;br&gt;
real answer. Schedule says &lt;strong&gt;Co-payment: Not Opted&lt;/strong&gt; — the co-pay % literally&lt;br&gt;
doesn't exist without the schedule.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;3. Grounding is non-negotiable&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Every extracted fact carries: source page, verbatim clause span, confidence&lt;br&gt;
score, and verification status. Anything the system cannot verify against a&lt;br&gt;
source clause is flagged as &lt;code&gt;unknown — confirm with insurer&lt;/code&gt;. Never fabricated.&lt;br&gt;
Never guessed.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;4. The LangGraph graph now has real conditional branching&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;The old code was a chain. The new extraction graph has genuine branches:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Scanned PDF vs clean text layer → different OCR path&lt;/li&gt;
&lt;li&gt;Verification pass: fail → human review loop&lt;/li&gt;
&lt;li&gt;User correction → re-verify → update structured record&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;This is the pattern I first used in &lt;code&gt;reelwright&lt;/code&gt; (human-in-the-loop regenerate&lt;br&gt;
loop for AI video generation) — now applied to policy document understanding.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;5. PostgreSQL schema designed for auditability&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;code&gt;policy_provisions&lt;/code&gt; table: one row per extracted fact, with &lt;code&gt;source_page&lt;/code&gt;,&lt;br&gt;
&lt;code&gt;source_text&lt;/code&gt;, &lt;code&gt;confidence&lt;/code&gt;, &lt;code&gt;verification_status&lt;/code&gt;, &lt;code&gt;user_corrected&lt;/code&gt;. Every&lt;br&gt;
update is auditable. Cross-policy comparison is possible. JSONB for the&lt;br&gt;
genuinely variable benefit tables that don't fit a fixed schema.&lt;/p&gt;




&lt;h2&gt;
  
  
  My Experience with GitHub Copilot
&lt;/h2&gt;

&lt;p&gt;The two places where Copilot had the biggest impact:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Schema design velocity.&lt;/strong&gt; The Pydantic models for a three-layer policy object&lt;br&gt;
are dense — nested types, optional fields for schedule-derived values, IRDAI&lt;br&gt;
standard exclusion codes (Excl01–Excl18), linked wording↔schedule joins. Copilot&lt;br&gt;
kept up with the domain context within a session and suggested field names,&lt;br&gt;
Optional wrapping, and validator patterns that matched the structure I was&lt;br&gt;
building toward. What would have been 2–3 hours of boilerplate was maybe 40&lt;br&gt;
minutes.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;LangGraph node stubs.&lt;/strong&gt; Once I described the graph shape — segmentation node,&lt;br&gt;
section-targeted extraction node, verification node, HITL correction node —&lt;br&gt;
Copilot generated solid first-draft stubs with the right &lt;code&gt;StateGraph&lt;/code&gt; wiring and&lt;br&gt;
&lt;code&gt;TypedDict&lt;/code&gt; state shapes. I rewrote the logic inside each node (that's where the&lt;br&gt;
real reasoning work lives), but the scaffolding was accurate enough to build on&lt;br&gt;
immediately.&lt;/p&gt;

&lt;p&gt;Where Copilot &lt;em&gt;didn't&lt;/em&gt; help — and I stopped leaning on it: the actual extraction&lt;br&gt;
prompt engineering. The prompts that tell the LLM exactly how to extract a&lt;br&gt;
&lt;code&gt;waiting_period&lt;/code&gt; object with a cited clause span from adversarial legal text are&lt;br&gt;
things I had to derive by reading real policy documents, testing, and iterating.&lt;br&gt;
No autocomplete shortcut for that. That was the good, slow, deliberate work.&lt;/p&gt;




&lt;p&gt;One honest note: I'm building this to learn agentic AI properly, with a real&lt;br&gt;
use-case that has real stakes. The Finish-Up-A-Thon deadline was the push I&lt;br&gt;
needed to stop designing and start shipping. The placeholder is gone. The&lt;br&gt;
grounding architecture is in. Next: get one full policy end-to-end through the&lt;br&gt;
pipeline into queryable Postgres tables.&lt;/p&gt;

&lt;p&gt;If you're navigating Indian health insurance and want to try it:&lt;br&gt;
&lt;a href="https://insuriq.himalayandev.tech" rel="noopener noreferrer"&gt;insuriq.himalayandev.tech&lt;/a&gt;&lt;/p&gt;

</description>
      <category>devchallenge</category>
      <category>githubchallenge</category>
    </item>
  </channel>
</rss>
