# pooworld/phyzer2 architecture

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

- Interactive diagram: https://gitdiagram.com/pooworld/phyzer2
- Repository: https://github.com/pooworld/phyzer2

## Overview

Project Sankalp is a dashboard-backed decision-support pilot for pharmaceutical claims, demand planning, expiry risk, revenue scenarios, and monthly actions. Users choose a dashboard workflow; the FastAPI layer invokes a LangGraph branch, which combines CSV-backed Python calculations with limited model-assisted text parsing or explanation. Results include evidence and checks. The README documents several branches whose implementation details were not sampled; those documented capabilities are included, while uncertain internal links are omitted.

Main entry points: [`agent/graph.py`](https://github.com/pooworld/phyzer2/blob/main/agent/graph.py) (LangGraph router), [`agent/extract.py`](https://github.com/pooworld/phyzer2/blob/main/agent/extract.py) (Structured model calls), [`agent/plan_nodes.py`](https://github.com/pooworld/phyzer2/blob/main/agent/plan_nodes.py) (Planner workflow), [`agent/planning.py`](https://github.com/pooworld/phyzer2/blob/main/agent/planning.py) (Forecast and dispatch)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_interface["Dashboard and API"]
  node_dashboard["Dashboard<br/>[app.js]"]
  node_api["API routes<br/>[app.py]"]
end

subgraph group_workflow["Workflow orchestration"]
  node_graph["LangGraph router<br/>[graph.py]"]
end

subgraph group_claims["Claims decisions"]
  node_claim_email["Email claim review<br/>[nodes.py]"]
  node_submitted_claim["Submitted claim checks<br/>[claim_rules.py]"]
  node_claim_policy["Claim policy rules<br/>[rules.py]"]
end

subgraph group_planning["Planning and actions"]
  node_planner["Forecast and dispatch<br/>[planning.py]"]
  node_planner_nodes["Planner workflow<br/>[plan_nodes.py]"]
  node_monthly["Monthly action lists<br/>[monthly.py]"]
end

subgraph group_insights["Outlook and growth"]
  node_forward_nodes["Outlook workflow<br/>[branch_nodes.py]"]
  node_forward["Expiry and risk analysis<br/>[forward.py]"]
  node_scenarios["Revenue scenarios<br/>[scenarios.py]"]
end

subgraph group_foundation["Shared services"]
  node_data[("CSV data access<br/>[data.py]")]
  node_policy["Policy configuration<br/>[config.py]"]
  node_model_calls["Structured model calls<br/>[extract.py]"]
  node_llm["LLM client<br/>[llm.py]"]
  node_schemas["Structured schemas<br/>[schemas.py]"]
  node_prompts["Model prompts<br/>[prompts.py]"]
end

node_user(("Dashboard user"))
node_model_service["Model service"]

node_user -->|"uses"| node_dashboard
node_dashboard -->|"requests results"| node_api
node_api -->|"runs workflow"| node_graph
node_graph -->|"routes claims"| node_claim_email
node_graph -->|"routes claim"| node_submitted_claim
node_graph -->|"routes planning"| node_planner_nodes
node_graph -->|"routes monthly"| node_monthly
node_graph -->|"routes outlook"| node_forward_nodes
node_graph -->|"routes scenarios"| node_scenarios
node_claim_email -->|"extracts email fields"| node_model_calls
node_claim_email -->|"checks claim rules"| node_claim_policy
node_submitted_claim -->|"reads claim records"| node_data
node_planner_nodes -->|"runs forecast"| node_planner
node_planner_nodes -->|"builds scheme guard"| node_monthly
node_monthly -->|"uses plan data"| node_planner
node_forward_nodes -->|"calculates outlook"| node_forward
node_forward_nodes -->|"calculates revenue"| node_scenarios
node_forward_nodes -->|"checks register"| node_submitted_claim
node_forward -->|"uses forecast data"| node_planner
node_scenarios -->|"uses forecast data"| node_planner
node_planner -->|"reads extracts"| node_data
node_monthly -->|"reads extracts"| node_data
node_forward -->|"reads extracts"| node_data
node_claim_policy -->|"uses thresholds"| node_policy
node_submitted_claim -->|"uses controls"| node_policy
node_model_calls -->|"gets model"| node_llm
node_model_calls -->|"uses prompts"| node_prompts
node_model_calls -->|"fills schemas"| node_schemas
node_llm -.->|"calls model"| node_model_service
node_planner_nodes -.->|"parses questions"| node_model_calls
node_planner_nodes -.->|"explains checked facts"| node_model_calls

click node_dashboard "https://github.com/pooworld/phyzer2/blob/main/public/app.js"
click node_api "https://github.com/pooworld/phyzer2/blob/main/app.py"
click node_graph "https://github.com/pooworld/phyzer2/blob/main/agent/graph.py"
click node_claim_email "https://github.com/pooworld/phyzer2/blob/main/agent/nodes.py"
click node_submitted_claim "https://github.com/pooworld/phyzer2/blob/main/agent/claim_rules.py"
click node_claim_policy "https://github.com/pooworld/phyzer2/blob/main/agent/rules.py"
click node_planner "https://github.com/pooworld/phyzer2/blob/main/agent/planning.py"
click node_planner_nodes "https://github.com/pooworld/phyzer2/blob/main/agent/plan_nodes.py"
click node_monthly "https://github.com/pooworld/phyzer2/blob/main/agent/monthly.py"
click node_forward_nodes "https://github.com/pooworld/phyzer2/blob/main/agent/branch_nodes.py"
click node_forward "https://github.com/pooworld/phyzer2/blob/main/agent/forward.py"
click node_scenarios "https://github.com/pooworld/phyzer2/blob/main/agent/scenarios.py"
click node_data "https://github.com/pooworld/phyzer2/blob/main/agent/data.py"
click node_policy "https://github.com/pooworld/phyzer2/blob/main/agent/config.py"
click node_model_calls "https://github.com/pooworld/phyzer2/blob/main/agent/extract.py"
click node_llm "https://github.com/pooworld/phyzer2/blob/main/agent/llm.py"
click node_schemas "https://github.com/pooworld/phyzer2/blob/main/agent/schemas.py"
click node_prompts "https://github.com/pooworld/phyzer2/blob/main/agent/prompts.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_dashboard,node_api,node_user toneBlue
class node_graph toneAmber
class node_claim_email,node_submitted_claim,node_claim_policy toneMint
class node_planner,node_planner_nodes,node_monthly toneRose
class node_forward_nodes,node_forward,node_scenarios,node_model_service toneIndigo
class node_data,node_policy,node_model_calls,node_llm,node_schemas,node_prompts toneTeal
```

## Components

### Dashboard and API

- [Dashboard](https://github.com/pooworld/phyzer2/blob/main/public/app.js): `public/app.js`
- [API routes](https://github.com/pooworld/phyzer2/blob/main/app.py): `app.py`

### Workflow orchestration

- [LangGraph router](https://github.com/pooworld/phyzer2/blob/main/agent/graph.py): `agent/graph.py`

### Claims decisions

- [Email claim review](https://github.com/pooworld/phyzer2/blob/main/agent/nodes.py): `agent/nodes.py`
- [Submitted claim checks](https://github.com/pooworld/phyzer2/blob/main/agent/claim_rules.py): `agent/claim_rules.py`
- [Claim policy rules](https://github.com/pooworld/phyzer2/blob/main/agent/rules.py): `agent/rules.py`

### Planning and actions

- [Forecast and dispatch](https://github.com/pooworld/phyzer2/blob/main/agent/planning.py): `agent/planning.py`
- [Planner workflow](https://github.com/pooworld/phyzer2/blob/main/agent/plan_nodes.py): `agent/plan_nodes.py`
- [Monthly action lists](https://github.com/pooworld/phyzer2/blob/main/agent/monthly.py): `agent/monthly.py`

### Outlook and growth

- [Outlook workflow](https://github.com/pooworld/phyzer2/blob/main/agent/branch_nodes.py): `agent/branch_nodes.py`
- [Expiry and risk analysis](https://github.com/pooworld/phyzer2/blob/main/agent/forward.py): `agent/forward.py`
- [Revenue scenarios](https://github.com/pooworld/phyzer2/blob/main/agent/scenarios.py): `agent/scenarios.py`

### Shared services

- [CSV data access](https://github.com/pooworld/phyzer2/blob/main/agent/data.py): `agent/data.py`
- [Policy configuration](https://github.com/pooworld/phyzer2/blob/main/agent/config.py): `agent/config.py`
- [Structured model calls](https://github.com/pooworld/phyzer2/blob/main/agent/extract.py): `agent/extract.py`
- [LLM client](https://github.com/pooworld/phyzer2/blob/main/agent/llm.py): `agent/llm.py`
- [Structured schemas](https://github.com/pooworld/phyzer2/blob/main/agent/schemas.py): `agent/schemas.py`
- [Model prompts](https://github.com/pooworld/phyzer2/blob/main/agent/prompts.py): `agent/prompts.py`

### Other components

- **Dashboard user**
- **Model service**

## Connections

- Dashboard user → Dashboard: uses (evidence: `README.md`)
- Dashboard → API routes: requests results (evidence: `README.md`)
- API routes → LangGraph router: runs workflow (evidence: `README.md`)
- LangGraph router → Email claim review: routes claims (evidence: `agent/graph.py`)
- LangGraph router → Submitted claim checks: routes claim (evidence: `agent/graph.py`)
- LangGraph router → Planner workflow: routes planning (evidence: `agent/graph.py`)
- LangGraph router → Monthly action lists: routes monthly (evidence: `README.md`)
- LangGraph router → Outlook workflow: routes outlook (evidence: `agent/graph.py`)
- LangGraph router → Revenue scenarios: routes scenarios (evidence: `README.md`)
- Email claim review → Structured model calls: extracts email fields (evidence: `agent/nodes.py`)
- Email claim review → Claim policy rules: checks claim rules (evidence: `agent/nodes.py`)
- Submitted claim checks → CSV data access: reads claim records (evidence: `agent/claim_rules.py`)
- Planner workflow → Forecast and dispatch: runs forecast (evidence: `agent/plan_nodes.py`)
- Planner workflow → Monthly action lists: builds scheme guard (evidence: `agent/plan_nodes.py`)
- Monthly action lists → Forecast and dispatch: uses plan data (evidence: `agent/monthly.py`)
- Outlook workflow → Expiry and risk analysis: calculates outlook (evidence: `agent/branch_nodes.py`)
- Outlook workflow → Revenue scenarios: calculates revenue (evidence: `agent/branch_nodes.py`)
- Outlook workflow → Submitted claim checks: checks register (evidence: `agent/branch_nodes.py`)
- Expiry and risk analysis → Forecast and dispatch: uses forecast data (evidence: `agent/forward.py`)
- Revenue scenarios → Forecast and dispatch: uses forecast data (evidence: `agent/scenarios.py`)
- Forecast and dispatch → CSV data access: reads extracts (evidence: `agent/planning.py`)
- Monthly action lists → CSV data access: reads extracts (evidence: `agent/monthly.py`)
- Expiry and risk analysis → CSV data access: reads extracts (evidence: `agent/forward.py`)
- Claim policy rules → Policy configuration: uses thresholds (evidence: `agent/rules.py`)
- Submitted claim checks → Policy configuration: uses controls (evidence: `agent/claim_rules.py`)
- Structured model calls → LLM client: gets model (evidence: `agent/extract.py`)
- Structured model calls → Model prompts: uses prompts (evidence: `agent/extract.py`)
- Structured model calls → Structured schemas: fills schemas (evidence: `agent/extract.py`)
- LLM client → Model service: calls model
- Planner workflow → Structured model calls: parses questions (evidence: `README.md`)
- Planner workflow → Structured model calls: explains checked facts (evidence: `README.md`)
