# auzzton/recovery_razorpay architecture

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

- Interactive diagram: https://gitdiagram.com/auzzton/recovery_razorpay
- Repository: https://github.com/auzzton/recovery_razorpay

## Overview

RecoveryOS turns failed-payment webhooks into guarded, cost-weighted recovery workflows: AI triage chooses outreach or capture retry, replies and scheduled checks advance auditable FSM states, and a dashboard reports recovery and counterfactual ROI. The README documents the integrations and capabilities; sampled excerpts confirm key orchestration, client, database and UI paths, but not every scheduler, guard or dispatch implementation detail, so uncertain internal links are omitted.

Main entry points: [`backend/app/main.py`](https://github.com/auzzton/recovery_razorpay/blob/main/backend/app/main.py) (API orchestrator), [`frontend/src/App.jsx`](https://github.com/auzzton/recovery_razorpay/blob/main/frontend/src/App.jsx) (Dashboard app), [`backend/app/outreach_dispatcher.py`](https://github.com/auzzton/recovery_razorpay/blob/main/backend/app/outreach_dispatcher.py) (Outreach dispatcher), [`backend/app/llm_provider.py`](https://github.com/auzzton/recovery_razorpay/blob/main/backend/app/llm_provider.py) (AI decision engine)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_workflow["Recovery workflow"]
  node_main["API orchestrator<br/>[main.py]"]
  node_guards["Compliance guards<br/>[guards.py]"]
  node_fsm["Workflow FSM<br/>[fsm.py]"]
  node_date_parser["Promise date parser<br/>[date_parser.py]"]
  node_models["API models<br/>[models.py]"]
end

subgraph group_integrations["Decision and delivery"]
  node_llm["AI decision engine<br/>[llm_provider.py]"]
  node_outreach["Outreach dispatcher"]
  node_email["Email service"]
  node_twilio["Twilio"]
  node_razor_client["Capture client<br/>[razorpay_client.py]"]
  node_gemini["Gemini"]
end

subgraph group_state["State and persistence"]
  node_ledger[("Recovery database<br/>[database.py]")]
  node_schema["Ledger schema<br/>[schema.sql]"]
end

subgraph group_dashboard["Merchant dashboard"]
  node_frontend["Dashboard app<br/>[App.jsx]"]
  node_workflow_table["Workflow table<br/>[WorkflowTable.jsx]"]
  node_reply_sim["Reply simulator<br/>[ReplySimulator.jsx]"]
  node_audit["Audit drawer<br/>[AuditDrawer.jsx]"]
  node_metrics["ROI metrics"]
end

node_merchant(("Merchant"))
node_customer(("Customer"))
node_scheduler(("Scheduler"))
node_razorpay_webhook(("Razorpay webhook"))

node_razorpay_webhook -->|"posts failure"| node_main
node_main -->|"checks compliance"| node_guards
node_main -->|"requests triage"| node_llm
node_llm -.->|"optional inference"| node_gemini
node_main -->|"transitions state"| node_fsm
node_main -->|"dispatches reminders"| node_outreach
node_outreach -.->|"sends email"| node_email
node_outreach -.->|"sends messages"| node_twilio
node_customer -->|"replies by webhook"| node_main
node_main -->|"parses promises"| node_date_parser
node_scheduler -->|"runs recovery checks"| node_main
node_main -->|"retries capture"| node_razor_client
node_razor_client -.-> node_razorpay_webhook
node_main -->|"reads and writes"| node_ledger
node_ledger -->|"initializes from"| node_schema
node_merchant -->|"views recovery"| node_frontend
node_frontend -->|"requests dashboard data"| node_main
node_frontend -->|"renders workflows"| node_workflow_table
node_frontend -->|"renders reply tools"| node_reply_sim
node_frontend -->|"opens audit"| node_audit
node_frontend -->|"renders ROI"| node_metrics
node_reply_sim -->|"submits reply"| node_main

click node_main "https://github.com/auzzton/recovery_razorpay/blob/main/backend/app/main.py"
click node_guards "https://github.com/auzzton/recovery_razorpay/blob/main/backend/app/guards.py"
click node_fsm "https://github.com/auzzton/recovery_razorpay/blob/main/backend/app/fsm.py"
click node_date_parser "https://github.com/auzzton/recovery_razorpay/blob/main/backend/app/date_parser.py"
click node_models "https://github.com/auzzton/recovery_razorpay/blob/main/backend/app/models.py"
click node_llm "https://github.com/auzzton/recovery_razorpay/blob/main/backend/app/llm_provider.py"
click node_outreach "https://github.com/auzzton/recovery_razorpay/blob/main/backend/app/outreach_dispatcher.py"
click node_razor_client "https://github.com/auzzton/recovery_razorpay/blob/main/backend/app/razorpay_client.py"
click node_ledger "https://github.com/auzzton/recovery_razorpay/blob/main/backend/db/database.py"
click node_schema "https://github.com/auzzton/recovery_razorpay/blob/main/backend/db/schema.sql"
click node_frontend "https://github.com/auzzton/recovery_razorpay/blob/main/frontend/src/App.jsx"
click node_workflow_table "https://github.com/auzzton/recovery_razorpay/blob/main/frontend/src/components/WorkflowTable.jsx"
click node_reply_sim "https://github.com/auzzton/recovery_razorpay/blob/main/frontend/src/components/ReplySimulator.jsx"
click node_audit "https://github.com/auzzton/recovery_razorpay/blob/main/frontend/src/components/AuditDrawer.jsx"
click node_metrics "https://github.com/auzzton/recovery_razorpay/blob/main/frontend/src/components/CounterfactualPanel.jsx"

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_main,node_guards,node_fsm,node_date_parser,node_models toneBlue
class node_llm,node_outreach,node_email,node_twilio,node_razor_client,node_gemini toneAmber
class node_ledger,node_schema,node_razorpay_webhook toneMint
class node_frontend,node_workflow_table,node_reply_sim,node_audit,node_metrics,node_scheduler toneRose
class node_merchant,node_customer toneIndigo
```

## Components

### Recovery workflow

- [API orchestrator](https://github.com/auzzton/recovery_razorpay/blob/main/backend/app/main.py): `backend/app/main.py`
- [Compliance guards](https://github.com/auzzton/recovery_razorpay/blob/main/backend/app/guards.py): `backend/app/guards.py`
- [Workflow FSM](https://github.com/auzzton/recovery_razorpay/blob/main/backend/app/fsm.py): `backend/app/fsm.py`
- [Promise date parser](https://github.com/auzzton/recovery_razorpay/blob/main/backend/app/date_parser.py): `backend/app/date_parser.py`
- [API models](https://github.com/auzzton/recovery_razorpay/blob/main/backend/app/models.py): `backend/app/models.py`

### Decision and delivery

- [AI decision engine](https://github.com/auzzton/recovery_razorpay/blob/main/backend/app/llm_provider.py): `backend/app/llm_provider.py`
- [Outreach dispatcher](https://github.com/auzzton/recovery_razorpay/blob/main/backend/app/outreach_dispatcher.py): `backend/app/outreach_dispatcher.py`
- **Email service**
- **Twilio**
- [Capture client](https://github.com/auzzton/recovery_razorpay/blob/main/backend/app/razorpay_client.py): `backend/app/razorpay_client.py`
- **Gemini**

### State and persistence

- [Recovery database](https://github.com/auzzton/recovery_razorpay/blob/main/backend/db/database.py): `backend/db/database.py`
- [Ledger schema](https://github.com/auzzton/recovery_razorpay/blob/main/backend/db/schema.sql): `backend/db/schema.sql`

### Merchant dashboard

- [Dashboard app](https://github.com/auzzton/recovery_razorpay/blob/main/frontend/src/App.jsx): `frontend/src/App.jsx`
- [Workflow table](https://github.com/auzzton/recovery_razorpay/blob/main/frontend/src/components/WorkflowTable.jsx): `frontend/src/components/WorkflowTable.jsx`
- [Reply simulator](https://github.com/auzzton/recovery_razorpay/blob/main/frontend/src/components/ReplySimulator.jsx): `frontend/src/components/ReplySimulator.jsx`
- [Audit drawer](https://github.com/auzzton/recovery_razorpay/blob/main/frontend/src/components/AuditDrawer.jsx): `frontend/src/components/AuditDrawer.jsx`
- [ROI metrics](https://github.com/auzzton/recovery_razorpay/blob/main/frontend/src/components/CounterfactualPanel.jsx): `frontend/src/components/CounterfactualPanel.jsx`

### Other components

- **Merchant**
- **Customer**
- **Scheduler**
- **Razorpay webhook**

## Connections

- Razorpay webhook → API orchestrator: posts failure
- API orchestrator → Compliance guards: checks compliance
- API orchestrator → AI decision engine: requests triage
- AI decision engine → Gemini: optional inference
- API orchestrator → Workflow FSM: transitions state
- API orchestrator → Outreach dispatcher: dispatches reminders
- Outreach dispatcher → Email service: sends email
- Outreach dispatcher → Twilio: sends messages
- Customer → API orchestrator: replies by webhook
- API orchestrator → Promise date parser: parses promises
- Scheduler → API orchestrator: runs recovery checks
- API orchestrator → Capture client: retries capture
- Capture client → Razorpay webhook
- API orchestrator → Recovery database: reads and writes
- Recovery database → Ledger schema: initializes from
- Merchant → Dashboard app: views recovery
- Dashboard app → API orchestrator: requests dashboard data
- Dashboard app → Workflow table: renders workflows
- Dashboard app → Reply simulator: renders reply tools
- Dashboard app → Audit drawer: opens audit
- Dashboard app → ROI metrics: renders ROI
- Reply simulator → API orchestrator: submits reply
