# lakshyar36/offline-payment architecture

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

- Interactive diagram: https://gitdiagram.com/lakshyar36/offline-payment
- Repository: https://github.com/lakshyar36/offline-payment

## Overview

UPI Offline Mesh is a Spring Boot demo backend plus a software mesh simulator. Its user-to-result workflow composes and encrypts a payment, gossips its packet across virtual devices, uploads it through an internet-enabled bridge, then deduplicates, decrypts, checks freshness, and settles it to the ledger. The README documents these relationships; source excerpts were not provided, so links not established there are omitted. Persistence details and production integrations are not expanded beyond the documented demo behavior.

Main entry points: [`src/main/java/com/demo/upimesh/service/DemoService.java`](https://github.com/lakshyar36/offline-payment/blob/main/src/main/java/com/demo/upimesh/service/DemoService.java) (Payment composer), [`src/main/java/com/demo/upimesh/service/BridgeIngestionService.java`](https://github.com/lakshyar36/offline-payment/blob/main/src/main/java/com/demo/upimesh/service/BridgeIngestionService.java) (Bridge ingestion), [`src/main/resources/templates/dashboard.html`](https://github.com/lakshyar36/offline-payment/blob/main/src/main/resources/templates/dashboard.html) (Dashboard), [`src/main/java/com/demo/upimesh/service/SettlementService.java`](https://github.com/lakshyar36/offline-payment/blob/main/src/main/java/com/demo/upimesh/service/SettlementService.java) (Settlement service)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_demo["Demo Experience"]
  node_dashboard["Dashboard<br/>[dashboard.html]"]
  node_dashboard_controller["Dashboard controller"]
  node_demo_service["Payment composer<br/>[DemoService.java]"]
  node_api_controller["API controller<br/>[ApiController.java]"]
end

subgraph group_mesh["Offline Mesh"]
  node_instruction["Payment instruction"]
  node_packet["Mesh packet<br/>[MeshPacket.java]"]
  node_crypto["Hybrid encryption"]
  node_key_holder["Server key holder"]
  node_simulator["Mesh simulator"]
  node_device["Virtual device<br/>[VirtualDevice.java]"]
end

subgraph group_ingestion["Backend Ingestion"]
  node_bridge["Bridge ingestion"]
  node_idempotency["Idempotency claim"]
end

subgraph group_ledger["Settlement Ledger"]
  node_settlement["Settlement service"]
  node_account["Account<br/>[Account.java]"]
  node_account_repository["Account repository"]
  node_transaction["Transaction record<br/>[Transaction.java]"]
  node_transaction_repository["Transaction repository"]
end

node_user(("Demo user"))

node_user -->|"operates"| node_dashboard
node_dashboard -->|"displays"| node_dashboard_controller
node_dashboard -->|"composes payment"| node_demo_service
node_demo_service -->|"builds"| node_instruction
node_demo_service -->|"encrypts"| node_crypto
node_crypto -->|"uses server key"| node_key_holder
node_demo_service -->|"wraps ciphertext"| node_packet
node_demo_service -->|"hands off packet"| node_simulator
node_simulator -->|"simulates gossip"| node_device
node_device -->|"uploads packet"| node_api_controller
node_api_controller -->|"routes ingest"| node_bridge
node_bridge -->|"claims hash"| node_idempotency
node_bridge -->|"decrypts packet"| node_crypto
node_bridge -->|"settles fresh payment"| node_settlement
node_settlement -->|"debits and credits"| node_account_repository
node_account_repository -.->|"stores accounts"| node_account
node_settlement -->|"writes ledger"| node_transaction_repository
node_transaction_repository -.->|"stores record"| node_transaction

click node_dashboard "https://github.com/lakshyar36/offline-payment/blob/main/src/main/resources/templates/dashboard.html"
click node_dashboard_controller "https://github.com/lakshyar36/offline-payment/blob/main/src/main/java/com/demo/upimesh/controller/DashboardController.java"
click node_demo_service "https://github.com/lakshyar36/offline-payment/blob/main/src/main/java/com/demo/upimesh/service/DemoService.java"
click node_api_controller "https://github.com/lakshyar36/offline-payment/blob/main/src/main/java/com/demo/upimesh/controller/ApiController.java"
click node_instruction "https://github.com/lakshyar36/offline-payment/blob/main/src/main/java/com/demo/upimesh/model/PaymentInstruction.java"
click node_packet "https://github.com/lakshyar36/offline-payment/blob/main/src/main/java/com/demo/upimesh/model/MeshPacket.java"
click node_crypto "https://github.com/lakshyar36/offline-payment/blob/main/src/main/java/com/demo/upimesh/crypto/HybridCryptoService.java"
click node_key_holder "https://github.com/lakshyar36/offline-payment/blob/main/src/main/java/com/demo/upimesh/crypto/ServerKeyHolder.java"
click node_simulator "https://github.com/lakshyar36/offline-payment/blob/main/src/main/java/com/demo/upimesh/service/MeshSimulatorService.java"
click node_device "https://github.com/lakshyar36/offline-payment/blob/main/src/main/java/com/demo/upimesh/service/VirtualDevice.java"
click node_bridge "https://github.com/lakshyar36/offline-payment/blob/main/src/main/java/com/demo/upimesh/service/BridgeIngestionService.java"
click node_idempotency "https://github.com/lakshyar36/offline-payment/blob/main/src/main/java/com/demo/upimesh/service/IdempotencyService.java"
click node_settlement "https://github.com/lakshyar36/offline-payment/blob/main/src/main/java/com/demo/upimesh/service/SettlementService.java"
click node_account "https://github.com/lakshyar36/offline-payment/blob/main/src/main/java/com/demo/upimesh/model/Account.java"
click node_account_repository "https://github.com/lakshyar36/offline-payment/blob/main/src/main/java/com/demo/upimesh/model/AccountRepository.java"
click node_transaction "https://github.com/lakshyar36/offline-payment/blob/main/src/main/java/com/demo/upimesh/model/Transaction.java"
click node_transaction_repository "https://github.com/lakshyar36/offline-payment/blob/main/src/main/java/com/demo/upimesh/model/TransactionRepository.java"

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_dashboard_controller,node_demo_service,node_api_controller,node_user toneBlue
class node_instruction,node_packet,node_crypto,node_key_holder,node_simulator,node_device toneAmber
class node_bridge,node_idempotency toneMint
class node_settlement,node_account,node_account_repository,node_transaction,node_transaction_repository toneRose
```

## Components

### Demo Experience

- [Dashboard](https://github.com/lakshyar36/offline-payment/blob/main/src/main/resources/templates/dashboard.html): `src/main/resources/templates/dashboard.html`
- [Dashboard controller](https://github.com/lakshyar36/offline-payment/blob/main/src/main/java/com/demo/upimesh/controller/DashboardController.java): `src/main/java/com/demo/upimesh/controller/DashboardController.java`
- [Payment composer](https://github.com/lakshyar36/offline-payment/blob/main/src/main/java/com/demo/upimesh/service/DemoService.java): `src/main/java/com/demo/upimesh/service/DemoService.java`
- [API controller](https://github.com/lakshyar36/offline-payment/blob/main/src/main/java/com/demo/upimesh/controller/ApiController.java): `src/main/java/com/demo/upimesh/controller/ApiController.java`

### Offline Mesh

- [Payment instruction](https://github.com/lakshyar36/offline-payment/blob/main/src/main/java/com/demo/upimesh/model/PaymentInstruction.java): `src/main/java/com/demo/upimesh/model/PaymentInstruction.java`
- [Mesh packet](https://github.com/lakshyar36/offline-payment/blob/main/src/main/java/com/demo/upimesh/model/MeshPacket.java): `src/main/java/com/demo/upimesh/model/MeshPacket.java`
- [Hybrid encryption](https://github.com/lakshyar36/offline-payment/blob/main/src/main/java/com/demo/upimesh/crypto/HybridCryptoService.java): `src/main/java/com/demo/upimesh/crypto/HybridCryptoService.java`
- [Server key holder](https://github.com/lakshyar36/offline-payment/blob/main/src/main/java/com/demo/upimesh/crypto/ServerKeyHolder.java): `src/main/java/com/demo/upimesh/crypto/ServerKeyHolder.java`
- [Mesh simulator](https://github.com/lakshyar36/offline-payment/blob/main/src/main/java/com/demo/upimesh/service/MeshSimulatorService.java): `src/main/java/com/demo/upimesh/service/MeshSimulatorService.java`
- [Virtual device](https://github.com/lakshyar36/offline-payment/blob/main/src/main/java/com/demo/upimesh/service/VirtualDevice.java): `src/main/java/com/demo/upimesh/service/VirtualDevice.java`

### Backend Ingestion

- [Bridge ingestion](https://github.com/lakshyar36/offline-payment/blob/main/src/main/java/com/demo/upimesh/service/BridgeIngestionService.java): `src/main/java/com/demo/upimesh/service/BridgeIngestionService.java`
- [Idempotency claim](https://github.com/lakshyar36/offline-payment/blob/main/src/main/java/com/demo/upimesh/service/IdempotencyService.java): `src/main/java/com/demo/upimesh/service/IdempotencyService.java`

### Settlement Ledger

- [Settlement service](https://github.com/lakshyar36/offline-payment/blob/main/src/main/java/com/demo/upimesh/service/SettlementService.java): `src/main/java/com/demo/upimesh/service/SettlementService.java`
- [Account](https://github.com/lakshyar36/offline-payment/blob/main/src/main/java/com/demo/upimesh/model/Account.java): `src/main/java/com/demo/upimesh/model/Account.java`
- [Account repository](https://github.com/lakshyar36/offline-payment/blob/main/src/main/java/com/demo/upimesh/model/AccountRepository.java): `src/main/java/com/demo/upimesh/model/AccountRepository.java`
- [Transaction record](https://github.com/lakshyar36/offline-payment/blob/main/src/main/java/com/demo/upimesh/model/Transaction.java): `src/main/java/com/demo/upimesh/model/Transaction.java`
- [Transaction repository](https://github.com/lakshyar36/offline-payment/blob/main/src/main/java/com/demo/upimesh/model/TransactionRepository.java): `src/main/java/com/demo/upimesh/model/TransactionRepository.java`

### Other components

- **Demo user**

## Connections

- Demo user → Dashboard: operates (evidence: `README.md`)
- Dashboard → Dashboard controller: displays (evidence: `README.md`)
- Dashboard → Payment composer: composes payment (evidence: `README.md`)
- Payment composer → Payment instruction: builds (evidence: `README.md`)
- Payment composer → Hybrid encryption: encrypts (evidence: `README.md`)
- Hybrid encryption → Server key holder: uses server key (evidence: `README.md`)
- Payment composer → Mesh packet: wraps ciphertext (evidence: `README.md`)
- Payment composer → Mesh simulator: hands off packet (evidence: `README.md`)
- Mesh simulator → Virtual device: simulates gossip (evidence: `README.md`)
- Virtual device → API controller: uploads packet (evidence: `README.md`)
- API controller → Bridge ingestion: routes ingest (evidence: `README.md`)
- Bridge ingestion → Idempotency claim: claims hash (evidence: `README.md`)
- Bridge ingestion → Hybrid encryption: decrypts packet (evidence: `README.md`)
- Bridge ingestion → Settlement service: settles fresh payment (evidence: `README.md`)
- Settlement service → Account repository: debits and credits (evidence: `README.md`)
- Account repository → Account: stores accounts
- Settlement service → Transaction repository: writes ledger (evidence: `README.md`)
- Transaction repository → Transaction record: stores record
