# ganesh-marathe/ai-revenue-recovery-agent architecture

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

- Interactive diagram: https://gitdiagram.com/ganesh-marathe/ai-revenue-recovery-agent
- Repository: https://github.com/ganesh-marathe/ai-revenue-recovery-agent

## Overview

ReviveAI is a revenue-recovery application for monitoring invoices and payments, identifying risk, recommending and executing recovery actions, and tracking outcomes. The principal workflow runs from invoice/payment data through risk assessment and AI diagnosis/intervention to a recovery case and audit record; users access these capabilities through an authenticated dashboard. Analytics and authentication are distinct supporting branches. The recovery flow and frontend API calls are visible in excerpts; other API wiring is supported by the README and source index, so unsampled implementation details are not inferred.

Main entry points: [`frontend/src/App.jsx`](https://github.com/ganesh-marathe/ai-revenue-recovery-agent/blob/main/frontend/src/App.jsx) (React application), [`backend/app/api/recovery.py`](https://github.com/ganesh-marathe/ai-revenue-recovery-agent/blob/main/backend/app/api/recovery.py) (Recovery API), [`backend/app/main.py`](https://github.com/ganesh-marathe/ai-revenue-recovery-agent/blob/main/backend/app/main.py) (FastAPI application), [`frontend/src/services/api.js`](https://github.com/ganesh-marathe/ai-revenue-recovery-agent/blob/main/frontend/src/services/api.js) (REST API client)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_frontend["Dashboard UI"]
  node_app["React application<br/>[App.jsx]"]
  node_login["Login page<br/>[Login.jsx]"]
  node_invoice_page["Invoice monitoring<br/>[Invoices.jsx]"]
  node_recovery_page["Recovery cases<br/>[RecoveryCases.jsx]"]
  node_dashboard["Dashboard<br/>[Dashboard.jsx]"]
  node_insights["AI insights<br/>[AIInsights.jsx]"]
  node_analytics_page["Analytics<br/>[Analytics.jsx]"]
  node_audit_page["Audit trail<br/>[AuditTrail.jsx]"]
  node_client["REST API client<br/>[api.js]"]
end

subgraph group_api["Backend APIs"]
  node_fastapi["FastAPI application<br/>[main.py]"]
  node_auth_api["Authentication API<br/>[auth.py]"]
  node_invoice_api["Invoice API<br/>[invoices.py]"]
  node_payment_api["Payment API<br/>[payments.py]"]
  node_customer_api["Customer API<br/>[customers.py]"]
  node_recovery_api["Recovery API<br/>[recovery.py]"]
  node_analytics_api["Analytics API<br/>[analytics.py]"]
end

subgraph group_recovery["Recovery Intelligence"]
  node_risk["Revenue risk<br/>[risk_service.py]"]
  node_diagnosis["Problem diagnosis<br/>[diagnosis_agent.py]"]
  node_intervention["Action selection"]
end

subgraph group_data["Domain Data"]
  node_customers["Customers<br/>[customer.py]"]
  node_invoices["Invoices<br/>[invoice.py]"]
  node_payments["Payments<br/>[payment.py]"]
  node_cases["Recovery cases<br/>[recovery_case.py]"]
  node_audit["Audit records<br/>[audit_log.py]"]
  node_users["User accounts<br/>[user.py]"]
  node_db[("SQLite database<br/>[database.py]")]
end

node_operator(("Business user"))

node_operator -->|"uses"| node_app
node_app -->|"shows when signed out"| node_login
node_app -->|"routes to"| node_invoice_page
node_app -->|"routes to"| node_recovery_page
node_app -->|"routes to"| node_dashboard
node_app -->|"routes to"| node_insights
node_app -->|"routes to"| node_analytics_page
node_app -->|"routes to"| node_audit_page
node_invoice_page -->|"requests data"| node_client
node_recovery_page -->|"uses"| node_client
node_dashboard -->|"uses"| node_client
node_insights -->|"uses"| node_client
node_analytics_page -->|"uses"| node_client
node_audit_page -->|"uses"| node_client
node_client -->|"sends REST requests"| node_fastapi
node_fastapi -->|"registers router"| node_auth_api
node_fastapi -->|"registers router"| node_recovery_api
node_fastapi -->|"registers router"| node_invoice_api
node_fastapi -->|"registers router"| node_payment_api
node_fastapi -->|"registers router"| node_customer_api
node_fastapi -->|"registers router"| node_analytics_api
node_auth_api -->|"queries and writes"| node_users
node_recovery_api -->|"reads"| node_invoices
node_recovery_api -->|"reads"| node_payments
node_recovery_api -->|"calculates risk"| node_risk
node_recovery_api -->|"diagnoses issue"| node_diagnosis
node_recovery_api -->|"chooses action"| node_intervention
node_recovery_api -->|"creates and updates"| node_cases
node_recovery_api -->|"records execution"| node_audit
node_analytics_api -->|"uses risk calculation"| node_risk
node_invoice_api -->|"uses invoice records"| node_invoices
node_payment_api -->|"uses payment records"| node_payments
node_customer_api -->|"uses customer records"| node_customers
node_customers -->|"maps to"| node_db
node_invoices -->|"maps to"| node_db
node_payments -->|"maps to"| node_db
node_cases -->|"maps to"| node_db
node_audit -->|"maps to"| node_db
node_users -->|"maps to"| node_db

click node_app "https://github.com/ganesh-marathe/ai-revenue-recovery-agent/blob/main/frontend/src/App.jsx"
click node_login "https://github.com/ganesh-marathe/ai-revenue-recovery-agent/blob/main/frontend/src/pages/Login.jsx"
click node_invoice_page "https://github.com/ganesh-marathe/ai-revenue-recovery-agent/blob/main/frontend/src/pages/Invoices.jsx"
click node_recovery_page "https://github.com/ganesh-marathe/ai-revenue-recovery-agent/blob/main/frontend/src/pages/RecoveryCases.jsx"
click node_dashboard "https://github.com/ganesh-marathe/ai-revenue-recovery-agent/blob/main/frontend/src/pages/Dashboard.jsx"
click node_insights "https://github.com/ganesh-marathe/ai-revenue-recovery-agent/blob/main/frontend/src/pages/AIInsights.jsx"
click node_analytics_page "https://github.com/ganesh-marathe/ai-revenue-recovery-agent/blob/main/frontend/src/pages/Analytics.jsx"
click node_audit_page "https://github.com/ganesh-marathe/ai-revenue-recovery-agent/blob/main/frontend/src/pages/AuditTrail.jsx"
click node_client "https://github.com/ganesh-marathe/ai-revenue-recovery-agent/blob/main/frontend/src/services/api.js"
click node_fastapi "https://github.com/ganesh-marathe/ai-revenue-recovery-agent/blob/main/backend/app/main.py"
click node_auth_api "https://github.com/ganesh-marathe/ai-revenue-recovery-agent/blob/main/backend/app/api/auth.py"
click node_invoice_api "https://github.com/ganesh-marathe/ai-revenue-recovery-agent/blob/main/backend/app/api/invoices.py"
click node_payment_api "https://github.com/ganesh-marathe/ai-revenue-recovery-agent/blob/main/backend/app/api/payments.py"
click node_customer_api "https://github.com/ganesh-marathe/ai-revenue-recovery-agent/blob/main/backend/app/api/customers.py"
click node_recovery_api "https://github.com/ganesh-marathe/ai-revenue-recovery-agent/blob/main/backend/app/api/recovery.py"
click node_analytics_api "https://github.com/ganesh-marathe/ai-revenue-recovery-agent/blob/main/backend/app/api/analytics.py"
click node_risk "https://github.com/ganesh-marathe/ai-revenue-recovery-agent/blob/main/backend/app/services/risk_service.py"
click node_diagnosis "https://github.com/ganesh-marathe/ai-revenue-recovery-agent/blob/main/backend/app/agents/diagnosis_agent.py"
click node_intervention "https://github.com/ganesh-marathe/ai-revenue-recovery-agent/blob/main/backend/app/agents/intervention_agent.py"
click node_customers "https://github.com/ganesh-marathe/ai-revenue-recovery-agent/blob/main/backend/app/models/customer.py"
click node_invoices "https://github.com/ganesh-marathe/ai-revenue-recovery-agent/blob/main/backend/app/models/invoice.py"
click node_payments "https://github.com/ganesh-marathe/ai-revenue-recovery-agent/blob/main/backend/app/models/payment.py"
click node_cases "https://github.com/ganesh-marathe/ai-revenue-recovery-agent/blob/main/backend/app/models/recovery_case.py"
click node_audit "https://github.com/ganesh-marathe/ai-revenue-recovery-agent/blob/main/backend/app/models/audit_log.py"
click node_users "https://github.com/ganesh-marathe/ai-revenue-recovery-agent/blob/main/backend/app/models/user.py"
click node_db "https://github.com/ganesh-marathe/ai-revenue-recovery-agent/blob/main/backend/app/database/database.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_app,node_login,node_invoice_page,node_recovery_page,node_dashboard,node_insights,node_analytics_page,node_audit_page,node_client,node_operator toneBlue
class node_fastapi,node_auth_api,node_invoice_api,node_payment_api,node_customer_api,node_recovery_api,node_analytics_api toneAmber
class node_risk,node_diagnosis,node_intervention toneMint
class node_customers,node_invoices,node_payments,node_cases,node_audit,node_users,node_db toneRose
```

## Components

### Dashboard UI

- [React application](https://github.com/ganesh-marathe/ai-revenue-recovery-agent/blob/main/frontend/src/App.jsx): `frontend/src/App.jsx`
- [Login page](https://github.com/ganesh-marathe/ai-revenue-recovery-agent/blob/main/frontend/src/pages/Login.jsx): `frontend/src/pages/Login.jsx`
- [Invoice monitoring](https://github.com/ganesh-marathe/ai-revenue-recovery-agent/blob/main/frontend/src/pages/Invoices.jsx): `frontend/src/pages/Invoices.jsx`
- [Recovery cases](https://github.com/ganesh-marathe/ai-revenue-recovery-agent/blob/main/frontend/src/pages/RecoveryCases.jsx): `frontend/src/pages/RecoveryCases.jsx`
- [Dashboard](https://github.com/ganesh-marathe/ai-revenue-recovery-agent/blob/main/frontend/src/pages/Dashboard.jsx): `frontend/src/pages/Dashboard.jsx`
- [AI insights](https://github.com/ganesh-marathe/ai-revenue-recovery-agent/blob/main/frontend/src/pages/AIInsights.jsx): `frontend/src/pages/AIInsights.jsx`
- [Analytics](https://github.com/ganesh-marathe/ai-revenue-recovery-agent/blob/main/frontend/src/pages/Analytics.jsx): `frontend/src/pages/Analytics.jsx`
- [Audit trail](https://github.com/ganesh-marathe/ai-revenue-recovery-agent/blob/main/frontend/src/pages/AuditTrail.jsx): `frontend/src/pages/AuditTrail.jsx`
- [REST API client](https://github.com/ganesh-marathe/ai-revenue-recovery-agent/blob/main/frontend/src/services/api.js): `frontend/src/services/api.js`

### Backend APIs

- [FastAPI application](https://github.com/ganesh-marathe/ai-revenue-recovery-agent/blob/main/backend/app/main.py): `backend/app/main.py`
- [Authentication API](https://github.com/ganesh-marathe/ai-revenue-recovery-agent/blob/main/backend/app/api/auth.py): `backend/app/api/auth.py`
- [Invoice API](https://github.com/ganesh-marathe/ai-revenue-recovery-agent/blob/main/backend/app/api/invoices.py): `backend/app/api/invoices.py`
- [Payment API](https://github.com/ganesh-marathe/ai-revenue-recovery-agent/blob/main/backend/app/api/payments.py): `backend/app/api/payments.py`
- [Customer API](https://github.com/ganesh-marathe/ai-revenue-recovery-agent/blob/main/backend/app/api/customers.py): `backend/app/api/customers.py`
- [Recovery API](https://github.com/ganesh-marathe/ai-revenue-recovery-agent/blob/main/backend/app/api/recovery.py): `backend/app/api/recovery.py`
- [Analytics API](https://github.com/ganesh-marathe/ai-revenue-recovery-agent/blob/main/backend/app/api/analytics.py): `backend/app/api/analytics.py`

### Recovery Intelligence

- [Revenue risk](https://github.com/ganesh-marathe/ai-revenue-recovery-agent/blob/main/backend/app/services/risk_service.py): `backend/app/services/risk_service.py`
- [Problem diagnosis](https://github.com/ganesh-marathe/ai-revenue-recovery-agent/blob/main/backend/app/agents/diagnosis_agent.py): `backend/app/agents/diagnosis_agent.py`
- [Action selection](https://github.com/ganesh-marathe/ai-revenue-recovery-agent/blob/main/backend/app/agents/intervention_agent.py): `backend/app/agents/intervention_agent.py`

### Domain Data

- [Customers](https://github.com/ganesh-marathe/ai-revenue-recovery-agent/blob/main/backend/app/models/customer.py): `backend/app/models/customer.py`
- [Invoices](https://github.com/ganesh-marathe/ai-revenue-recovery-agent/blob/main/backend/app/models/invoice.py): `backend/app/models/invoice.py`
- [Payments](https://github.com/ganesh-marathe/ai-revenue-recovery-agent/blob/main/backend/app/models/payment.py): `backend/app/models/payment.py`
- [Recovery cases](https://github.com/ganesh-marathe/ai-revenue-recovery-agent/blob/main/backend/app/models/recovery_case.py): `backend/app/models/recovery_case.py`
- [Audit records](https://github.com/ganesh-marathe/ai-revenue-recovery-agent/blob/main/backend/app/models/audit_log.py): `backend/app/models/audit_log.py`
- [User accounts](https://github.com/ganesh-marathe/ai-revenue-recovery-agent/blob/main/backend/app/models/user.py): `backend/app/models/user.py`
- [SQLite database](https://github.com/ganesh-marathe/ai-revenue-recovery-agent/blob/main/backend/app/database/database.py): `backend/app/database/database.py`

### Other components

- **Business user**

## Connections

- Business user → React application: uses (evidence: `frontend/src/App.jsx`)
- React application → Login page: shows when signed out (evidence: `frontend/src/App.jsx`)
- React application → Invoice monitoring: routes to (evidence: `frontend/src/App.jsx`)
- React application → Recovery cases: routes to (evidence: `frontend/src/App.jsx`)
- React application → Dashboard: routes to (evidence: `frontend/src/App.jsx`)
- React application → AI insights: routes to (evidence: `frontend/src/App.jsx`)
- React application → Analytics: routes to (evidence: `frontend/src/App.jsx`)
- React application → Audit trail: routes to (evidence: `frontend/src/App.jsx`)
- Invoice monitoring → REST API client: requests data (evidence: `frontend/src/pages/Invoices.jsx`)
- Recovery cases → REST API client: uses (evidence: `frontend/src/pages/RecoveryCases.jsx`)
- Dashboard → REST API client: uses (evidence: `frontend/src/pages/Dashboard.jsx`)
- AI insights → REST API client: uses (evidence: `frontend/src/pages/AIInsights.jsx`)
- Analytics → REST API client: uses (evidence: `frontend/src/pages/Analytics.jsx`)
- Audit trail → REST API client: uses (evidence: `frontend/src/pages/AuditTrail.jsx`)
- REST API client → FastAPI application: sends REST requests (evidence: `README.md`)
- FastAPI application → Authentication API: registers router (evidence: `backend/app/main.py`)
- FastAPI application → Recovery API: registers router (evidence: `backend/app/main.py`)
- FastAPI application → Invoice API: registers router (evidence: `backend/app/main.py`)
- FastAPI application → Payment API: registers router (evidence: `backend/app/main.py`)
- FastAPI application → Customer API: registers router (evidence: `backend/app/main.py`)
- FastAPI application → Analytics API: registers router (evidence: `backend/app/main.py`)
- Authentication API → User accounts: queries and writes (evidence: `backend/app/api/auth.py`)
- Recovery API → Invoices: reads (evidence: `backend/app/api/recovery.py`)
- Recovery API → Payments: reads (evidence: `backend/app/api/recovery.py`)
- Recovery API → Revenue risk: calculates risk (evidence: `backend/app/api/recovery.py`)
- Recovery API → Problem diagnosis: diagnoses issue (evidence: `backend/app/api/recovery.py`)
- Recovery API → Action selection: chooses action (evidence: `backend/app/api/recovery.py`)
- Recovery API → Recovery cases: creates and updates (evidence: `backend/app/api/recovery.py`)
- Recovery API → Audit records: records execution (evidence: `backend/app/api/recovery.py`)
- Analytics API → Revenue risk: uses risk calculation (evidence: `backend/app/api/analytics.py`)
- Invoice API → Invoices: uses invoice records (evidence: `backend/app/api/invoices.py`)
- Payment API → Payments: uses payment records (evidence: `backend/app/api/payments.py`)
- Customer API → Customers: uses customer records (evidence: `backend/app/api/customers.py`)
- Customers → SQLite database: maps to (evidence: `backend/app/models/customer.py`)
- Invoices → SQLite database: maps to (evidence: `backend/app/models/invoice.py`)
- Payments → SQLite database: maps to (evidence: `backend/app/models/payment.py`)
- Recovery cases → SQLite database: maps to (evidence: `backend/app/models/recovery_case.py`)
- Audit records → SQLite database: maps to (evidence: `backend/app/models/audit_log.py`)
- User accounts → SQLite database: maps to (evidence: `backend/app/models/user.py`)
