# vamshikpatel/propay architecture

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

- Interactive diagram: https://gitdiagram.com/vamshikpatel/propay
- Repository: https://github.com/vamshikpatel/propay

## Overview

ProPay is a UPI and digital-payment fraud shield. A user submits a payment URI or link through the frontend; the Flask API passes simulation requests to the risk orchestrator, which applies fast deterministic checks, conditionally requests AI forensics, then records the decision and dispatches alerts. The main internal layer is that orchestrator, coordinating rule evaluation, forensic analysis, policy outcomes, email, and audit events. The README documents URL unwrapping, velocity checks, ledger verification, SMTP configuration, and an offline demo; some implementation details were not sampled, so those links are included only where documented.

Main entry points: [`backend/orchestrator.py`](https://github.com/vamshikpatel/propay/blob/main/backend/orchestrator.py) (Risk orchestrator), [`backend/server.py`](https://github.com/vamshikpatel/propay/blob/main/backend/server.py) (Flask API), [`backend/email_agent.py`](https://github.com/vamshikpatel/propay/blob/main/backend/email_agent.py) (Alert dispatcher), [`frontend/js/app.js`](https://github.com/vamshikpatel/propay/blob/main/frontend/js/app.js) (Payment UI)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_client["Client experience"]
  node_frontend["Payment UI<br/>[app.js]"]
  node_api["Flask API<br/>[server.py]"]
end

subgraph group_risk["Risk evaluation"]
  node_orchestrator["Risk orchestrator<br/>[orchestrator.py]"]
  node_rules["URI and risk rules<br/>[rule_engine.py]"]
  node_forensics["AI forensics<br/>[ollama_agent.py]"]
  node_ollama{{"Local Ollama"}}
  node_policy["Payment action<br/>[orchestrator.py]"]
end

subgraph group_services["Response services"]
  node_email["Alert dispatcher<br/>[email_agent.py]"]
  node_smtp{{"SMTP relay"}}
end

subgraph group_audit["Audit trail"]
  node_ledger[("Hash-chain ledger<br/>[event_ledger.py]")]
end

node_user(("Payment user"))

node_user -->|"submits intent"| node_frontend
node_frontend -->|"requests simulation"| node_api
node_api -->|"processes transaction"| node_orchestrator
node_orchestrator -->|"evaluates intent"| node_rules
node_orchestrator -->|"investigates conditionally"| node_forensics
node_forensics -.->|"requests analysis"| node_ollama
node_orchestrator -->|"determines action"| node_policy
node_orchestrator -->|"dispatches alert"| node_email
node_email -->|"sends mail"| node_smtp
node_orchestrator -->|"appends decision"| node_ledger
node_api -->|"configures and tests"| node_email
node_api -->|"reads status"| node_ledger

click node_frontend "https://github.com/vamshikpatel/propay/blob/main/frontend/js/app.js"
click node_api "https://github.com/vamshikpatel/propay/blob/main/backend/server.py"
click node_orchestrator "https://github.com/vamshikpatel/propay/blob/main/backend/orchestrator.py"
click node_rules "https://github.com/vamshikpatel/propay/blob/main/backend/rule_engine.py"
click node_forensics "https://github.com/vamshikpatel/propay/blob/main/backend/ollama_agent.py"
click node_policy "https://github.com/vamshikpatel/propay/blob/main/backend/orchestrator.py"
click node_email "https://github.com/vamshikpatel/propay/blob/main/backend/email_agent.py"
click node_ledger "https://github.com/vamshikpatel/propay/blob/main/backend/event_ledger.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_frontend,node_api,node_user toneBlue
class node_orchestrator,node_rules,node_forensics,node_ollama,node_policy toneAmber
class node_email,node_smtp toneMint
class node_ledger toneRose
```

## Components

### Client experience

- [Payment UI](https://github.com/vamshikpatel/propay/blob/main/frontend/js/app.js): `frontend/js/app.js`
- [Flask API](https://github.com/vamshikpatel/propay/blob/main/backend/server.py): `backend/server.py`

### Risk evaluation

- [Risk orchestrator](https://github.com/vamshikpatel/propay/blob/main/backend/orchestrator.py): `backend/orchestrator.py`
- [URI and risk rules](https://github.com/vamshikpatel/propay/blob/main/backend/rule_engine.py): `backend/rule_engine.py`
- [AI forensics](https://github.com/vamshikpatel/propay/blob/main/backend/ollama_agent.py): `backend/ollama_agent.py`
- **Local Ollama**
- [Payment action](https://github.com/vamshikpatel/propay/blob/main/backend/orchestrator.py): `backend/orchestrator.py`

### Response services

- [Alert dispatcher](https://github.com/vamshikpatel/propay/blob/main/backend/email_agent.py): `backend/email_agent.py`
- **SMTP relay**

### Audit trail

- [Hash-chain ledger](https://github.com/vamshikpatel/propay/blob/main/backend/event_ledger.py): `backend/event_ledger.py`

### Other components

- **Payment user**

## Connections

- Payment user → Payment UI: submits intent (evidence: `README.md`)
- Payment UI → Flask API: requests simulation (evidence: `README.md`)
- Flask API → Risk orchestrator: processes transaction (evidence: `backend/server.py`)
- Risk orchestrator → URI and risk rules: evaluates intent (evidence: `backend/orchestrator.py`)
- Risk orchestrator → AI forensics: investigates conditionally (evidence: `backend/orchestrator.py`)
- AI forensics → Local Ollama: requests analysis (evidence: `README.md`)
- Risk orchestrator → Payment action: determines action (evidence: `backend/orchestrator.py`)
- Risk orchestrator → Alert dispatcher: dispatches alert (evidence: `backend/orchestrator.py`)
- Alert dispatcher → SMTP relay: sends mail (evidence: `README.md`)
- Risk orchestrator → Hash-chain ledger: appends decision (evidence: `backend/orchestrator.py`)
- Flask API → Alert dispatcher: configures and tests (evidence: `backend/server.py`)
- Flask API → Hash-chain ledger: reads status (evidence: `backend/server.py`)
