# gandhismit06/insuremate architecture

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

- Interactive diagram: https://gitdiagram.com/gandhismit06/insuremate
- Repository: https://github.com/gandhismit06/insuremate

## Overview

InsureMate prepares health-insurance claims through document extraction, completeness validation, coverage and identity checks, and policy-driven missing-evidence detection; its agent can plan and execute these tools and synthesize a readiness result. The graph preserves the documented Phase 1–5 capabilities and the internal planning, decision, state, and tool-adapter layers. Several Phase 4/5 and PDF-rendering connections rely on source-index references or explicit documentation rather than fully shown call sites, so those links are marked unverified where appropriate.

Main entry points: [`agent/insuremate_agent.py`](https://github.com/gandhismit06/insuremate/blob/main/agent/insuremate_agent.py) (Claim orchestrator), [`agent/tools.py`](https://github.com/gandhismit06/insuremate/blob/main/agent/tools.py) (Tool adapters), [`services/missing_document/detector.py`](https://github.com/gandhismit06/insuremate/blob/main/services/missing_document/detector.py) (Requirement matching), [`services/missing_document/llm_gateway.py`](https://github.com/gandhismit06/insuremate/blob/main/services/missing_document/llm_gateway.py) (LLM reasoning gateway)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_agent["Agent orchestration"]
  node_orchestrator["Claim orchestrator"]
  node_planner["Plan creation<br/>[planner.py]"]
  node_decision["Action decisions<br/>[decision.py]"]
  node_state["Claim session state<br/>[state.py]"]
  node_adapters["Tool adapters<br/>[tools.py]"]
end

subgraph group_processing["Document processing"]
  node_extract_tool["Extraction tool<br/>[qwen_vl_tool.py]"]
  node_pdf["PDF page rendering<br/>[pdf_processor.py]"]
  node_extractor["Vision extraction<br/>[extractor.py]"]
end

subgraph group_verification["Claim verification"]
  node_validation_tool["Validation tool"]
  node_validator["Field completeness rules<br/>[validator.py]"]
  node_validity_tool["Validity tool"]
  node_checker["Coverage and identity checks<br/>[checker.py]"]
end

subgraph group_evidence["Evidence requirements"]
  node_missing_tool["Missing evidence tool"]
  node_detector["Requirement matching<br/>[detector.py]"]
  node_gateway["LLM reasoning gateway<br/>[llm_gateway.py]"]
  node_prompts["Requirement prompts<br/>[prompt_builder.py]"]
  node_schemas["Evidence schemas<br/>[schemas.py]"]
  node_ollama["Ollama client<br/>[ollama_client.py]"]
end

node_user(("Policyholder or adjudicator"))
node_cli["CLI entry<br/>[main.py]"]
node_ollama_service(("Ollama model service"))

node_user -->|"submits claim"| node_cli
node_cli -->|"starts agent"| node_orchestrator
node_orchestrator -->|"creates plan"| node_planner
node_orchestrator -->|"requests decisions"| node_decision
node_orchestrator -->|"tracks session"| node_state
node_orchestrator -->|"executes tools"| node_adapters
node_adapters -->|"invokes extraction"| node_extract_tool
node_adapters -->|"invokes validation"| node_validation_tool
node_adapters -->|"invokes validity"| node_validity_tool
node_adapters -->|"invokes detection"| node_missing_tool
node_extract_tool -->|"runs extraction"| node_extractor
node_extractor -.->|"renders pages"| node_pdf
node_validation_tool -->|"validates fields"| node_validator
node_validity_tool -->|"checks coverage"| node_checker
node_missing_tool -->|"detects missing evidence"| node_detector
node_detector -.->|"requests reasoning"| node_gateway
node_gateway -.->|"builds prompts"| node_prompts
node_gateway -.->|"validates output"| node_schemas
node_gateway -.->|"sends requests"| node_ollama
node_ollama -->|"calls model"| node_ollama_service
node_detector -.->|"uses extracted output"| node_extractor
node_detector -.->|"uses validation output"| node_validator
node_detector -.->|"uses validity output"| node_checker

click node_cli "https://github.com/gandhismit06/insuremate/blob/main/main.py"
click node_orchestrator "https://github.com/gandhismit06/insuremate/blob/main/agent/insuremate_agent.py"
click node_planner "https://github.com/gandhismit06/insuremate/blob/main/agent/planner.py"
click node_decision "https://github.com/gandhismit06/insuremate/blob/main/agent/decision.py"
click node_state "https://github.com/gandhismit06/insuremate/blob/main/agent/state.py"
click node_adapters "https://github.com/gandhismit06/insuremate/blob/main/agent/tools.py"
click node_extract_tool "https://github.com/gandhismit06/insuremate/blob/main/tools/qwen_vl_tool.py"
click node_pdf "https://github.com/gandhismit06/insuremate/blob/main/services/qwen_vl/pdf_processor.py"
click node_extractor "https://github.com/gandhismit06/insuremate/blob/main/services/qwen_vl/extractor.py"
click node_validation_tool "https://github.com/gandhismit06/insuremate/blob/main/tools/document_validation_tool.py"
click node_validator "https://github.com/gandhismit06/insuremate/blob/main/services/document_validation/validator.py"
click node_validity_tool "https://github.com/gandhismit06/insuremate/blob/main/tools/validity_checker_tool.py"
click node_checker "https://github.com/gandhismit06/insuremate/blob/main/services/validity_checker/checker.py"
click node_missing_tool "https://github.com/gandhismit06/insuremate/blob/main/tools/missing_document_tool.py"
click node_detector "https://github.com/gandhismit06/insuremate/blob/main/services/missing_document/detector.py"
click node_gateway "https://github.com/gandhismit06/insuremate/blob/main/services/missing_document/llm_gateway.py"
click node_prompts "https://github.com/gandhismit06/insuremate/blob/main/services/missing_document/prompt_builder.py"
click node_schemas "https://github.com/gandhismit06/insuremate/blob/main/services/missing_document/schemas.py"
click node_ollama "https://github.com/gandhismit06/insuremate/blob/main/services/missing_document/ollama_client.py"

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_orchestrator,node_planner,node_decision,node_state,node_adapters toneBlue
class node_extract_tool,node_pdf,node_extractor toneAmber
class node_validation_tool,node_validator,node_validity_tool,node_checker toneMint
class node_missing_tool,node_detector,node_gateway,node_prompts,node_schemas,node_ollama toneRose
class node_user,node_ollama_service toneIndigo
class node_cli toneTeal
```

## Components

### Agent orchestration

- [Claim orchestrator](https://github.com/gandhismit06/insuremate/blob/main/agent/insuremate_agent.py): `agent/insuremate_agent.py`
- [Plan creation](https://github.com/gandhismit06/insuremate/blob/main/agent/planner.py): `agent/planner.py`
- [Action decisions](https://github.com/gandhismit06/insuremate/blob/main/agent/decision.py): `agent/decision.py`
- [Claim session state](https://github.com/gandhismit06/insuremate/blob/main/agent/state.py): `agent/state.py`
- [Tool adapters](https://github.com/gandhismit06/insuremate/blob/main/agent/tools.py): `agent/tools.py`

### Document processing

- [Extraction tool](https://github.com/gandhismit06/insuremate/blob/main/tools/qwen_vl_tool.py): `tools/qwen_vl_tool.py`
- [PDF page rendering](https://github.com/gandhismit06/insuremate/blob/main/services/qwen_vl/pdf_processor.py): `services/qwen_vl/pdf_processor.py`
- [Vision extraction](https://github.com/gandhismit06/insuremate/blob/main/services/qwen_vl/extractor.py): `services/qwen_vl/extractor.py`

### Claim verification

- [Validation tool](https://github.com/gandhismit06/insuremate/blob/main/tools/document_validation_tool.py): `tools/document_validation_tool.py`
- [Field completeness rules](https://github.com/gandhismit06/insuremate/blob/main/services/document_validation/validator.py): `services/document_validation/validator.py`
- [Validity tool](https://github.com/gandhismit06/insuremate/blob/main/tools/validity_checker_tool.py): `tools/validity_checker_tool.py`
- [Coverage and identity checks](https://github.com/gandhismit06/insuremate/blob/main/services/validity_checker/checker.py): `services/validity_checker/checker.py`

### Evidence requirements

- [Missing evidence tool](https://github.com/gandhismit06/insuremate/blob/main/tools/missing_document_tool.py): `tools/missing_document_tool.py`
- [Requirement matching](https://github.com/gandhismit06/insuremate/blob/main/services/missing_document/detector.py): `services/missing_document/detector.py`
- [LLM reasoning gateway](https://github.com/gandhismit06/insuremate/blob/main/services/missing_document/llm_gateway.py): `services/missing_document/llm_gateway.py`
- [Requirement prompts](https://github.com/gandhismit06/insuremate/blob/main/services/missing_document/prompt_builder.py): `services/missing_document/prompt_builder.py`
- [Evidence schemas](https://github.com/gandhismit06/insuremate/blob/main/services/missing_document/schemas.py): `services/missing_document/schemas.py`
- [Ollama client](https://github.com/gandhismit06/insuremate/blob/main/services/missing_document/ollama_client.py): `services/missing_document/ollama_client.py`

### Other components

- **Policyholder or adjudicator**
- [CLI entry](https://github.com/gandhismit06/insuremate/blob/main/main.py): `main.py`
- **Ollama model service**

## Connections

- Policyholder or adjudicator → CLI entry: submits claim (evidence: `README.md`)
- CLI entry → Claim orchestrator: starts agent (evidence: `main.py`)
- Claim orchestrator → Plan creation: creates plan (evidence: `agent/insuremate_agent.py`)
- Claim orchestrator → Action decisions: requests decisions (evidence: `agent/insuremate_agent.py`)
- Claim orchestrator → Claim session state: tracks session (evidence: `agent/insuremate_agent.py`)
- Claim orchestrator → Tool adapters: executes tools (evidence: `agent/insuremate_agent.py`)
- Tool adapters → Extraction tool: invokes extraction (evidence: `agent/tools.py`)
- Tool adapters → Validation tool: invokes validation (evidence: `agent/tools.py`)
- Tool adapters → Validity tool: invokes validity (evidence: `agent/tools.py`)
- Tool adapters → Missing evidence tool: invokes detection (evidence: `agent/tools.py`)
- Extraction tool → Vision extraction: runs extraction (evidence: `tools/qwen_vl_tool.py`)
- Vision extraction → PDF page rendering: renders pages (evidence: `services/qwen_vl/extractor.py`)
- Validation tool → Field completeness rules: validates fields (evidence: `tools/document_validation_tool.py`)
- Validity tool → Coverage and identity checks: checks coverage (evidence: `tools/validity_checker_tool.py`)
- Missing evidence tool → Requirement matching: detects missing evidence (evidence: `tools/missing_document_tool.py`)
- Requirement matching → LLM reasoning gateway: requests reasoning (evidence: `services/missing_document/detector.py`)
- LLM reasoning gateway → Requirement prompts: builds prompts (evidence: `services/missing_document/llm_gateway.py`)
- LLM reasoning gateway → Evidence schemas: validates output (evidence: `services/missing_document/llm_gateway.py`)
- LLM reasoning gateway → Ollama client: sends requests (evidence: `services/missing_document/llm_gateway.py`)
- Ollama client → Ollama model service: calls model (evidence: `services/missing_document/ollama_client.py`)
- Requirement matching → Vision extraction: uses extracted output
- Requirement matching → Field completeness rules: uses validation output
- Requirement matching → Coverage and identity checks: uses validity output
