# nirmal-36/onepay architecture

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

- Interactive diagram: https://gitdiagram.com/nirmal-36/onepay
- Repository: https://github.com/nirmal-36/onepay

## Overview

OnePay is a fintech demo: users authenticate, review and confirm simulated transfers or bill/recharge payments, then inspect wallet activity, receipts, recipients, and account settings. The React client calls a Django API; the backend validates requests and stores account-scoped wallet, recipient, and transaction data in PostgreSQL. QR scanning resolves and verifies a recipient but does not itself pay. The README documents these capabilities; some backend wiring and unsampled page implementations are represented only at the documented subsystem level.

Main entry points: [`frontend/src/AppRoutes.tsx`](https://github.com/nirmal-36/onepay/blob/main/frontend/src/AppRoutes.tsx) (App routes), [`frontend/src/context/DemoProvider.tsx`](https://github.com/nirmal-36/onepay/blob/main/frontend/src/context/DemoProvider.tsx) (Demo state), [`frontend/src/api/payments.ts`](https://github.com/nirmal-36/onepay/blob/main/frontend/src/api/payments.ts) (Payments API client), [`backend/apps/accounts/views.py`](https://github.com/nirmal-36/onepay/blob/main/backend/apps/accounts/views.py) (Account endpoints)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_client["Web experience"]
  node_routes["App routes<br/>[AppRoutes.tsx]"]
  node_demo["Demo state<br/>[DemoProvider.tsx]"]
end

subgraph group_identity["Account access"]
  node_session["Session state<br/>[AuthContext.tsx]"]
  node_authclient["Auth API client<br/>[auth.ts]"]
  node_accountapi["Account endpoints<br/>[views.py]"]
  node_accountdata[("Account records<br/>[models.py]")]
end

subgraph group_payments["Simulated payments"]
  node_paymentclient["Payments API client<br/>[payments.ts]"]
  node_send["Send payment<br/>[SendMoneyPage.tsx]"]
  node_scan["QR scan and resolve<br/>[ScanQrPage.tsx]"]
  node_bills["Bills and recharge<br/>[BillsPage.tsx]"]
  node_recipientui["Recipient management<br/>[RecipientsPage.tsx]"]
  node_history["Transactions and receipts"]
  node_paymentapi["Payment endpoints<br/>[views.py]"]
  node_rules["Payment and QR rules<br/>[services.py]"]
end

subgraph group_storage["Persistent state"]
  node_records[("Wallet and ledger models<br/>[models.py]")]
  node_postgres[("PostgreSQL")]
end

node_user(("OnePay user"))
node_email["Email delivery"]

node_user -->|"uses"| node_routes
node_routes -->|"guards routes"| node_session
node_routes -->|"routes to"| node_send
node_routes -->|"routes to"| node_scan
node_routes -->|"routes to"| node_bills
node_routes -->|"routes to"| node_recipientui
node_routes -->|"routes to"| node_history
node_session -->|"calls"| node_authclient
node_authclient -->|"requests"| node_accountapi
node_accountapi -->|"reads and writes"| node_accountdata
node_accountapi -.->|"sends reset link"| node_email
node_send -->|"uses state"| node_demo
node_scan -->|"resolves QR"| node_paymentclient
node_send -->|"initiates after review"| node_paymentclient
node_bills -->|"uses state"| node_demo
node_recipientui -->|"uses state"| node_demo
node_history -.->|"uses state"| node_demo
node_demo -->|"loads and updates"| node_paymentclient
node_paymentclient -->|"requests"| node_paymentapi
node_paymentapi -->|"delegates payment logic"| node_rules
node_paymentapi -->|"queries and persists"| node_records
node_rules -->|"updates ledger"| node_records
node_records -->|"persists"| node_postgres

click node_routes "https://github.com/nirmal-36/onepay/blob/main/frontend/src/AppRoutes.tsx"
click node_session "https://github.com/nirmal-36/onepay/blob/main/frontend/src/context/AuthContext.tsx"
click node_authclient "https://github.com/nirmal-36/onepay/blob/main/frontend/src/api/auth.ts"
click node_accountapi "https://github.com/nirmal-36/onepay/blob/main/backend/apps/accounts/views.py"
click node_accountdata "https://github.com/nirmal-36/onepay/blob/main/backend/apps/accounts/models.py"
click node_demo "https://github.com/nirmal-36/onepay/blob/main/frontend/src/context/DemoProvider.tsx"
click node_paymentclient "https://github.com/nirmal-36/onepay/blob/main/frontend/src/api/payments.ts"
click node_send "https://github.com/nirmal-36/onepay/blob/main/frontend/src/pages/SendMoneyPage.tsx"
click node_scan "https://github.com/nirmal-36/onepay/blob/main/frontend/src/pages/ScanQrPage.tsx"
click node_bills "https://github.com/nirmal-36/onepay/blob/main/frontend/src/pages/BillsPage.tsx"
click node_recipientui "https://github.com/nirmal-36/onepay/blob/main/frontend/src/pages/RecipientsPage.tsx"
click node_history "https://github.com/nirmal-36/onepay/blob/main/frontend/src/pages/TransactionsPage.tsx"
click node_paymentapi "https://github.com/nirmal-36/onepay/blob/main/backend/apps/payments/views.py"
click node_rules "https://github.com/nirmal-36/onepay/blob/main/backend/apps/payments/services.py"
click node_records "https://github.com/nirmal-36/onepay/blob/main/backend/apps/payments/models.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_routes,node_demo,node_user toneBlue
class node_session,node_authclient,node_accountapi,node_accountdata toneAmber
class node_paymentclient,node_send,node_scan,node_bills,node_recipientui,node_history,node_paymentapi,node_rules toneMint
class node_records,node_postgres toneRose
class node_email toneIndigo
```

## Components

### Web experience

- [App routes](https://github.com/nirmal-36/onepay/blob/main/frontend/src/AppRoutes.tsx): `frontend/src/AppRoutes.tsx`
- [Demo state](https://github.com/nirmal-36/onepay/blob/main/frontend/src/context/DemoProvider.tsx): `frontend/src/context/DemoProvider.tsx`

### Account access

- [Session state](https://github.com/nirmal-36/onepay/blob/main/frontend/src/context/AuthContext.tsx): `frontend/src/context/AuthContext.tsx`
- [Auth API client](https://github.com/nirmal-36/onepay/blob/main/frontend/src/api/auth.ts): `frontend/src/api/auth.ts`
- [Account endpoints](https://github.com/nirmal-36/onepay/blob/main/backend/apps/accounts/views.py): `backend/apps/accounts/views.py`
- [Account records](https://github.com/nirmal-36/onepay/blob/main/backend/apps/accounts/models.py): `backend/apps/accounts/models.py`

### Simulated payments

- [Payments API client](https://github.com/nirmal-36/onepay/blob/main/frontend/src/api/payments.ts): `frontend/src/api/payments.ts`
- [Send payment](https://github.com/nirmal-36/onepay/blob/main/frontend/src/pages/SendMoneyPage.tsx): `frontend/src/pages/SendMoneyPage.tsx`
- [QR scan and resolve](https://github.com/nirmal-36/onepay/blob/main/frontend/src/pages/ScanQrPage.tsx): `frontend/src/pages/ScanQrPage.tsx`
- [Bills and recharge](https://github.com/nirmal-36/onepay/blob/main/frontend/src/pages/BillsPage.tsx): `frontend/src/pages/BillsPage.tsx`
- [Recipient management](https://github.com/nirmal-36/onepay/blob/main/frontend/src/pages/RecipientsPage.tsx): `frontend/src/pages/RecipientsPage.tsx`
- [Transactions and receipts](https://github.com/nirmal-36/onepay/blob/main/frontend/src/pages/TransactionsPage.tsx): `frontend/src/pages/TransactionsPage.tsx`
- [Payment endpoints](https://github.com/nirmal-36/onepay/blob/main/backend/apps/payments/views.py): `backend/apps/payments/views.py`
- [Payment and QR rules](https://github.com/nirmal-36/onepay/blob/main/backend/apps/payments/services.py): `backend/apps/payments/services.py`

### Persistent state

- [Wallet and ledger models](https://github.com/nirmal-36/onepay/blob/main/backend/apps/payments/models.py): `backend/apps/payments/models.py`
- **PostgreSQL**

### Other components

- **OnePay user**
- **Email delivery**

## Connections

- OnePay user → App routes: uses (evidence: `frontend/src/AppRoutes.tsx`)
- App routes → Session state: guards routes (evidence: `frontend/src/AppRoutes.tsx`)
- App routes → Send payment: routes to (evidence: `frontend/src/AppRoutes.tsx`)
- App routes → QR scan and resolve: routes to (evidence: `frontend/src/AppRoutes.tsx`)
- App routes → Bills and recharge: routes to (evidence: `frontend/src/AppRoutes.tsx`)
- App routes → Recipient management: routes to (evidence: `frontend/src/AppRoutes.tsx`)
- App routes → Transactions and receipts: routes to (evidence: `frontend/src/AppRoutes.tsx`)
- Session state → Auth API client: calls (evidence: `frontend/src/context/AuthContext.tsx`)
- Auth API client → Account endpoints: requests
- Account endpoints → Account records: reads and writes (evidence: `backend/apps/accounts/views.py`)
- Account endpoints → Email delivery: sends reset link
- Send payment → Demo state: uses state (evidence: `frontend/src/pages/SendMoneyPage.tsx`)
- QR scan and resolve → Payments API client: resolves QR (evidence: `frontend/src/pages/ScanQrPage.tsx`)
- Send payment → Payments API client: initiates after review (evidence: `frontend/src/pages/SendMoneyPage.tsx`)
- Bills and recharge → Demo state: uses state (evidence: `frontend/src/pages/BillsPage.tsx`)
- Recipient management → Demo state: uses state (evidence: `frontend/src/pages/RecipientsPage.tsx`)
- Transactions and receipts → Demo state: uses state
- Demo state → Payments API client: loads and updates (evidence: `frontend/src/context/DemoProvider.tsx`)
- Payments API client → Payment endpoints: requests
- Payment endpoints → Payment and QR rules: delegates payment logic (evidence: `backend/apps/payments/views.py`)
- Payment endpoints → Wallet and ledger models: queries and persists (evidence: `backend/apps/payments/views.py`)
- Payment and QR rules → Wallet and ledger models: updates ledger (evidence: `backend/apps/payments/services.py`)
- Wallet and ledger models → PostgreSQL: persists
