# vedant-muglikar/insurance_intelligence architecture

> Architecture diagram of the GitHub repository vedant-muglikar/insurance_intelligence, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-10-10). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/vedant-muglikar/insurance_intelligence
- Repository: https://github.com/vedant-muglikar/insurance_intelligence

## Overview

BimaSetu is a policy-to-patient insurance coverage and treatment-cost intelligence application. The primary workflow uploads a policy PDF, extracts and verifies its clauses, compiles deterministic rules, then uses those rules for pre-admission coverage and cost simulations. Separate product branches handle hospital quotations and bills, claim disputes, preparation checklists and reminders, hospital search, and translation. The README documents these capabilities; sampled source confirms key policy extraction and checklist/notification calls, but some branch internals were not sampled.

Main entry points: [`app/api/policy/analyze/route.ts`](https://github.com/vedant-muglikar/insurance_intelligence/blob/main/app/api/policy/analyze/route.ts) (Policy analysis API), [`lib/checklist/service.ts`](https://github.com/vedant-muglikar/insurance_intelligence/blob/main/lib/checklist/service.ts) (Checklist service), [`lib/notifications/service.ts`](https://github.com/vedant-muglikar/insurance_intelligence/blob/main/lib/notifications/service.ts) (Reminder service), [`lib/pdf/hybrid.ts`](https://github.com/vedant-muglikar/insurance_intelligence/blob/main/lib/pdf/hybrid.ts) (PDF extraction)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_experience["User experience"]
  node_app["Policy workspace<br/>[policy-lens.tsx]"]
  node_policy_upload["Policy upload<br/>[UploadScreen.tsx]"]
  node_policy_results["Policy results<br/>[PolicyResults.tsx]"]
end

subgraph group_policy["Policy intelligence"]
  node_pdf_extract["PDF extraction<br/>[hybrid.ts]"]
  node_ai_extract["Clause extraction<br/>[extractor.ts]"]
  node_rule_validation["Evidence validation<br/>[validation.ts]"]
  node_policy_compile["Rule compiler<br/>[compiler.ts]"]
  node_policy_api["Policy analysis API<br/>[route.ts]"]
end

subgraph group_preflight["Preflight and claims"]
  node_preflight["Coverage preflight"]
  node_cost_engine["Cost estimation<br/>[cost.ts]"]
  node_what_if["Scenario simulator<br/>[WhatIfPanel.tsx]"]
  node_quote_api["Quote analysis API<br/>[route.ts]"]
  node_bill_api["Bill analysis API<br/>[route.ts]"]
  node_claim_api["Claim dispute API<br/>[route.ts]"]
end

subgraph group_support["Patient support"]
  node_checklist_ui["Preparation checklist"]
  node_checklist_api["Checklist API<br/>[route.ts]"]
  node_checklist_service["Checklist service<br/>[service.ts]"]
  node_checklist_generation["Task generation<br/>[generator.ts]"]
  node_notification_service["Reminder service<br/>[service.ts]"]
  node_notification_api["Notification API<br/>[route.ts]"]
  node_hospital_search["Nearby hospitals<br/>[search.ts]"]
  node_translation["Page translation<br/>[pageTranslator.ts]"]
end

subgraph group_platform["Persistence and services"]
  node_policy_store[("Policy analysis store<br/>[store.ts]")]
  node_checklist_repo[("Checklist repository<br/>[repository.ts]")]
  node_notification_repo[("Notification repository<br/>[repository.ts]")]
  node_supabase[("Supabase")]
end

node_patient(("Patient"))

node_patient -->|"uses"| node_app
node_app -->|"starts upload"| node_policy_upload
node_policy_upload -->|"submits policy"| node_policy_api
node_policy_api -->|"extracts pages"| node_pdf_extract
node_pdf_extract -->|"provides page text"| node_ai_extract
node_policy_api -->|"requests extraction"| node_ai_extract
node_policy_api -->|"validates citations"| node_rule_validation
node_policy_api -->|"compiles rules"| node_policy_compile
node_policy_api -->|"loads and saves"| node_policy_store
node_policy_api -->|"authenticates"| node_supabase
node_policy_results -->|"presents analysis"| node_preflight
node_preflight -.->|"estimates costs"| node_cost_engine
node_preflight -->|"explores scenarios"| node_what_if
node_patient -->|"submits quotation"| node_quote_api
node_quote_api -->|"extracts pages"| node_pdf_extract
node_patient -->|"submits bill"| node_bill_api
node_bill_api -->|"extracts pages"| node_pdf_extract
node_patient -->|"disputes claim"| node_claim_api
node_policy_results -->|"opens checklist"| node_checklist_ui
node_checklist_ui -.->|"syncs checklist"| node_checklist_api
node_checklist_api -->|"delegates operations"| node_checklist_service
node_checklist_service -->|"generates tasks"| node_checklist_generation
node_checklist_service -->|"reads and writes"| node_checklist_repo
node_checklist_ui -->|"builds local tasks"| node_checklist_generation
node_checklist_api -->|"records checklist events"| node_notification_service
node_notification_api -->|"delegates requests"| node_notification_service
node_notification_service -->|"loads checklists"| node_checklist_service
node_notification_service -->|"reads and writes"| node_notification_repo
node_patient -->|"finds hospitals"| node_hospital_search
node_patient -->|"requests translation"| node_translation
node_checklist_repo -->|"persists checklist"| node_supabase
node_notification_repo -->|"persists reminders"| node_supabase

click node_app "https://github.com/vedant-muglikar/insurance_intelligence/blob/main/components/policy-lens.tsx"
click node_policy_upload "https://github.com/vedant-muglikar/insurance_intelligence/blob/main/components/policy/UploadScreen.tsx"
click node_policy_results "https://github.com/vedant-muglikar/insurance_intelligence/blob/main/components/policy/PolicyResults.tsx"
click node_pdf_extract "https://github.com/vedant-muglikar/insurance_intelligence/blob/main/lib/pdf/hybrid.ts"
click node_ai_extract "https://github.com/vedant-muglikar/insurance_intelligence/blob/main/lib/ai/extractor.ts"
click node_rule_validation "https://github.com/vedant-muglikar/insurance_intelligence/blob/main/lib/pdf/validation.ts"
click node_policy_compile "https://github.com/vedant-muglikar/insurance_intelligence/blob/main/lib/policy/compiler.ts"
click node_policy_api "https://github.com/vedant-muglikar/insurance_intelligence/blob/main/app/api/policy/analyze/route.ts"
click node_policy_store "https://github.com/vedant-muglikar/insurance_intelligence/blob/main/lib/policy/store.ts"
click node_preflight "https://github.com/vedant-muglikar/insurance_intelligence/blob/main/components/policy/CoverageRiskAnalyzer.tsx"
click node_cost_engine "https://github.com/vedant-muglikar/insurance_intelligence/blob/main/lib/estimate/cost.ts"
click node_what_if "https://github.com/vedant-muglikar/insurance_intelligence/blob/main/components/policy/WhatIfPanel.tsx"
click node_quote_api "https://github.com/vedant-muglikar/insurance_intelligence/blob/main/app/api/quote/analyze/route.ts"
click node_bill_api "https://github.com/vedant-muglikar/insurance_intelligence/blob/main/app/api/bill/analyze/route.ts"
click node_claim_api "https://github.com/vedant-muglikar/insurance_intelligence/blob/main/app/api/claim-dispute/route.ts"
click node_checklist_ui "https://github.com/vedant-muglikar/insurance_intelligence/blob/main/components/policy/checklist/PreparationChecklist.tsx"
click node_checklist_api "https://github.com/vedant-muglikar/insurance_intelligence/blob/main/app/api/checklist/route.ts"
click node_checklist_service "https://github.com/vedant-muglikar/insurance_intelligence/blob/main/lib/checklist/service.ts"
click node_checklist_generation "https://github.com/vedant-muglikar/insurance_intelligence/blob/main/lib/checklist/generator.ts"
click node_checklist_repo "https://github.com/vedant-muglikar/insurance_intelligence/blob/main/lib/checklist/repository.ts"
click node_notification_service "https://github.com/vedant-muglikar/insurance_intelligence/blob/main/lib/notifications/service.ts"
click node_notification_api "https://github.com/vedant-muglikar/insurance_intelligence/blob/main/app/api/notifications/route.ts"
click node_notification_repo "https://github.com/vedant-muglikar/insurance_intelligence/blob/main/lib/notifications/repository.ts"
click node_hospital_search "https://github.com/vedant-muglikar/insurance_intelligence/blob/main/lib/hospitals/search.ts"
click node_translation "https://github.com/vedant-muglikar/insurance_intelligence/blob/main/lib/translate/pageTranslator.ts"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_app,node_policy_upload,node_policy_results toneBlue
class node_pdf_extract,node_ai_extract,node_rule_validation,node_policy_compile,node_policy_api toneAmber
class node_preflight,node_cost_engine,node_what_if,node_quote_api,node_bill_api,node_claim_api toneMint
class node_checklist_ui,node_checklist_api,node_checklist_service,node_checklist_generation,node_notification_service,node_notification_api,node_hospital_search,node_translation toneRose
class node_policy_store,node_checklist_repo,node_notification_repo,node_supabase,node_patient toneIndigo
```

## Components

### User experience

- [Policy workspace](https://github.com/vedant-muglikar/insurance_intelligence/blob/main/components/policy-lens.tsx): `components/policy-lens.tsx`
- [Policy upload](https://github.com/vedant-muglikar/insurance_intelligence/blob/main/components/policy/UploadScreen.tsx): `components/policy/UploadScreen.tsx`
- [Policy results](https://github.com/vedant-muglikar/insurance_intelligence/blob/main/components/policy/PolicyResults.tsx): `components/policy/PolicyResults.tsx`

### Policy intelligence

- [PDF extraction](https://github.com/vedant-muglikar/insurance_intelligence/blob/main/lib/pdf/hybrid.ts): `lib/pdf/hybrid.ts`
- [Clause extraction](https://github.com/vedant-muglikar/insurance_intelligence/blob/main/lib/ai/extractor.ts): `lib/ai/extractor.ts`
- [Evidence validation](https://github.com/vedant-muglikar/insurance_intelligence/blob/main/lib/pdf/validation.ts): `lib/pdf/validation.ts`
- [Rule compiler](https://github.com/vedant-muglikar/insurance_intelligence/blob/main/lib/policy/compiler.ts): `lib/policy/compiler.ts`
- [Policy analysis API](https://github.com/vedant-muglikar/insurance_intelligence/blob/main/app/api/policy/analyze/route.ts): `app/api/policy/analyze/route.ts`

### Preflight and claims

- [Coverage preflight](https://github.com/vedant-muglikar/insurance_intelligence/blob/main/components/policy/CoverageRiskAnalyzer.tsx): `components/policy/CoverageRiskAnalyzer.tsx`
- [Cost estimation](https://github.com/vedant-muglikar/insurance_intelligence/blob/main/lib/estimate/cost.ts): `lib/estimate/cost.ts`
- [Scenario simulator](https://github.com/vedant-muglikar/insurance_intelligence/blob/main/components/policy/WhatIfPanel.tsx): `components/policy/WhatIfPanel.tsx`
- [Quote analysis API](https://github.com/vedant-muglikar/insurance_intelligence/blob/main/app/api/quote/analyze/route.ts): `app/api/quote/analyze/route.ts`
- [Bill analysis API](https://github.com/vedant-muglikar/insurance_intelligence/blob/main/app/api/bill/analyze/route.ts): `app/api/bill/analyze/route.ts`
- [Claim dispute API](https://github.com/vedant-muglikar/insurance_intelligence/blob/main/app/api/claim-dispute/route.ts): `app/api/claim-dispute/route.ts`

### Patient support

- [Preparation checklist](https://github.com/vedant-muglikar/insurance_intelligence/blob/main/components/policy/checklist/PreparationChecklist.tsx): `components/policy/checklist/PreparationChecklist.tsx`
- [Checklist API](https://github.com/vedant-muglikar/insurance_intelligence/blob/main/app/api/checklist/route.ts): `app/api/checklist/route.ts`
- [Checklist service](https://github.com/vedant-muglikar/insurance_intelligence/blob/main/lib/checklist/service.ts): `lib/checklist/service.ts`
- [Task generation](https://github.com/vedant-muglikar/insurance_intelligence/blob/main/lib/checklist/generator.ts): `lib/checklist/generator.ts`
- [Reminder service](https://github.com/vedant-muglikar/insurance_intelligence/blob/main/lib/notifications/service.ts): `lib/notifications/service.ts`
- [Notification API](https://github.com/vedant-muglikar/insurance_intelligence/blob/main/app/api/notifications/route.ts): `app/api/notifications/route.ts`
- [Nearby hospitals](https://github.com/vedant-muglikar/insurance_intelligence/blob/main/lib/hospitals/search.ts): `lib/hospitals/search.ts`
- [Page translation](https://github.com/vedant-muglikar/insurance_intelligence/blob/main/lib/translate/pageTranslator.ts): `lib/translate/pageTranslator.ts`

### Persistence and services

- [Policy analysis store](https://github.com/vedant-muglikar/insurance_intelligence/blob/main/lib/policy/store.ts): `lib/policy/store.ts`
- [Checklist repository](https://github.com/vedant-muglikar/insurance_intelligence/blob/main/lib/checklist/repository.ts): `lib/checklist/repository.ts`
- [Notification repository](https://github.com/vedant-muglikar/insurance_intelligence/blob/main/lib/notifications/repository.ts): `lib/notifications/repository.ts`
- **Supabase**

### Other components

- **Patient**

## Connections

- Patient → Policy workspace: uses (evidence: `README.md`)
- Policy workspace → Policy upload: starts upload (evidence: `README.md`)
- Policy upload → Policy analysis API: submits policy (evidence: `README.md`)
- Policy analysis API → PDF extraction: extracts pages (evidence: `app/api/policy/analyze/route.ts`)
- PDF extraction → Clause extraction: provides page text (evidence: `lib/ai/extractor.ts`)
- Policy analysis API → Clause extraction: requests extraction (evidence: `app/api/policy/analyze/route.ts`)
- Policy analysis API → Evidence validation: validates citations (evidence: `app/api/policy/analyze/route.ts`)
- Policy analysis API → Rule compiler: compiles rules (evidence: `app/api/policy/analyze/route.ts`)
- Policy analysis API → Policy analysis store: loads and saves (evidence: `app/api/policy/analyze/route.ts`)
- Policy analysis API → Supabase: authenticates
- Policy results → Coverage preflight: presents analysis (evidence: `README.md`)
- Coverage preflight → Cost estimation: estimates costs
- Coverage preflight → Scenario simulator: explores scenarios (evidence: `README.md`)
- Patient → Quote analysis API: submits quotation (evidence: `README.md`)
- Quote analysis API → PDF extraction: extracts pages (evidence: `app/api/quote/analyze/route.ts`)
- Patient → Bill analysis API: submits bill (evidence: `README.md`)
- Bill analysis API → PDF extraction: extracts pages (evidence: `app/api/bill/analyze/route.ts`)
- Patient → Claim dispute API: disputes claim (evidence: `README.md`)
- Policy results → Preparation checklist: opens checklist (evidence: `README.md`)
- Preparation checklist → Checklist API: syncs checklist
- Checklist API → Checklist service: delegates operations (evidence: `app/api/checklist/route.ts`)
- Checklist service → Task generation: generates tasks (evidence: `lib/checklist/service.ts`)
- Checklist service → Checklist repository: reads and writes (evidence: `lib/checklist/service.ts`)
- Preparation checklist → Task generation: builds local tasks
- Checklist API → Reminder service: records checklist events (evidence: `app/api/checklist/route.ts`)
- Notification API → Reminder service: delegates requests (evidence: `app/api/notifications/route.ts`)
- Reminder service → Checklist service: loads checklists (evidence: `lib/notifications/service.ts`)
- Reminder service → Notification repository: reads and writes (evidence: `lib/notifications/service.ts`)
- Patient → Nearby hospitals: finds hospitals (evidence: `README.md`)
- Patient → Page translation: requests translation (evidence: `README.md`)
- Checklist repository → Supabase: persists checklist (evidence: `lib/checklist/repository.ts`)
- Notification repository → Supabase: persists reminders (evidence: `lib/notifications/repository.ts`)
