# varunsingh7389/meshpay-offline-upi-payments-over-mesh architecture

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

- Interactive diagram: https://gitdiagram.com/varunsingh7389/meshpay-offline-upi-payments-over-mesh
- Repository: https://github.com/varunsingh7389/meshpay-offline-upi-payments-over-mesh

## Overview

MeshPay is a Spring Boot proof-of-concept for offline UPI payments relayed through an in-memory device mesh. A sender composes a payment; it is encrypted into a packet, gossiped across devices, and uploaded by a bridge. Backend ingestion verifies and decrypts it, checks duplicates and freshness, then transactionally settles and records the payment. The dashboard exposes the demo flow and ledger. Relationships below follow README documentation; source excerpts were unavailable, so implementation-level call details are not inferred.

Main entry points: [`upimesh/src/main/java/com/demo/upimesh/service/BridgeIngestionService.java`](https://github.com/varunsingh7389/meshpay-offline-upi-payments-over-mesh/blob/main/upimesh/src/main/java/com/demo/upimesh/service/BridgeIngestionService.java) (Bridge Ingestion), [`upimesh/src/main/java/com/demo/upimesh/controller/ApiController.java`](https://github.com/varunsingh7389/meshpay-offline-upi-payments-over-mesh/blob/main/upimesh/src/main/java/com/demo/upimesh/controller/ApiController.java) (REST API), [`upimesh/src/main/java/com/demo/upimesh/service/DemoService.java`](https://github.com/varunsingh7389/meshpay-offline-upi-payments-over-mesh/blob/main/upimesh/src/main/java/com/demo/upimesh/service/DemoService.java) (Demo Payment Setup), [`upimesh/src/main/java/com/demo/upimesh/service/MeshSimulatorService.java`](https://github.com/varunsingh7389/meshpay-offline-upi-payments-over-mesh/blob/main/upimesh/src/main/java/com/demo/upimesh/service/MeshSimulatorService.java) (Mesh Simulator)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_demo["Demo and API"]
  node_dashboard["Payment Dashboard<br/>[dashboard.html]"]
  node_dashboard_controller["Dashboard Controller"]
  node_api["REST API<br/>[ApiController.java]"]
  node_demo_service["Demo Payment Setup<br/>[DemoService.java]"]
end

subgraph group_mesh["Offline Mesh"]
  node_mesh_simulator["Mesh Simulator"]
  node_virtual_device["Virtual Device<br/>[VirtualDevice.java]"]
  node_packet["Encrypted Mesh Packet<br/>[MeshPacket.java]"]
end

subgraph group_ingestion["Secure Ingestion"]
  node_ingestion["Bridge Ingestion"]
  node_crypto["Hybrid Crypto"]
  node_key_holder["Server Key Holder"]
  node_instruction["Payment Instruction"]
  node_idempotency["Idempotency Check"]
end

subgraph group_settlement["Settlement and Ledger"]
  node_settlement["Transactional Settlement"]
  node_account[("Account Repository")]
  node_transaction[("Transaction Repository")]
  node_transaction_model["Settled Transaction<br/>[Transaction.java]"]
end

node_sender(("Payment Sender"))
node_bridge(("Bridge Node"))

node_sender -->|"composes payment"| node_dashboard
node_dashboard -->|"loads"| node_dashboard_controller
node_sender -->|"injects payment"| node_api
node_api -.->|"starts demo"| node_demo_service
node_demo_service -->|"creates encrypted"| node_packet
node_demo_service -->|"injects packet"| node_mesh_simulator
node_mesh_simulator -->|"simulates hops"| node_virtual_device
node_mesh_simulator -->|"relays with TTL"| node_packet
node_bridge -->|"uploads packet"| node_api
node_api -->|"ingests packet"| node_ingestion
node_ingestion -->|"verifies and decrypts"| node_crypto
node_crypto -->|"uses private key"| node_key_holder
node_crypto -->|"decrypts payload"| node_instruction
node_ingestion -->|"rejects duplicates"| node_idempotency
node_ingestion -->|"settles verified payment"| node_settlement
node_settlement -->|"debits and credits"| node_account
node_settlement -->|"records settlement"| node_transaction
node_transaction -->|"persists record"| node_transaction_model

click node_dashboard "https://github.com/varunsingh7389/meshpay-offline-upi-payments-over-mesh/blob/main/upimesh/src/main/resources/templates/dashboard.html"
click node_dashboard_controller "https://github.com/varunsingh7389/meshpay-offline-upi-payments-over-mesh/blob/main/upimesh/src/main/java/com/demo/upimesh/controller/DashboardController.java"
click node_api "https://github.com/varunsingh7389/meshpay-offline-upi-payments-over-mesh/blob/main/upimesh/src/main/java/com/demo/upimesh/controller/ApiController.java"
click node_demo_service "https://github.com/varunsingh7389/meshpay-offline-upi-payments-over-mesh/blob/main/upimesh/src/main/java/com/demo/upimesh/service/DemoService.java"
click node_mesh_simulator "https://github.com/varunsingh7389/meshpay-offline-upi-payments-over-mesh/blob/main/upimesh/src/main/java/com/demo/upimesh/service/MeshSimulatorService.java"
click node_virtual_device "https://github.com/varunsingh7389/meshpay-offline-upi-payments-over-mesh/blob/main/upimesh/src/main/java/com/demo/upimesh/service/VirtualDevice.java"
click node_packet "https://github.com/varunsingh7389/meshpay-offline-upi-payments-over-mesh/blob/main/upimesh/src/main/java/com/demo/upimesh/model/MeshPacket.java"
click node_ingestion "https://github.com/varunsingh7389/meshpay-offline-upi-payments-over-mesh/blob/main/upimesh/src/main/java/com/demo/upimesh/service/BridgeIngestionService.java"
click node_crypto "https://github.com/varunsingh7389/meshpay-offline-upi-payments-over-mesh/blob/main/upimesh/src/main/java/com/demo/upimesh/crypto/HybridCryptoService.java"
click node_key_holder "https://github.com/varunsingh7389/meshpay-offline-upi-payments-over-mesh/blob/main/upimesh/src/main/java/com/demo/upimesh/crypto/ServerKeyHolder.java"
click node_instruction "https://github.com/varunsingh7389/meshpay-offline-upi-payments-over-mesh/blob/main/upimesh/src/main/java/com/demo/upimesh/model/PaymentInstruction.java"
click node_idempotency "https://github.com/varunsingh7389/meshpay-offline-upi-payments-over-mesh/blob/main/upimesh/src/main/java/com/demo/upimesh/service/IdempotencyService.java"
click node_settlement "https://github.com/varunsingh7389/meshpay-offline-upi-payments-over-mesh/blob/main/upimesh/src/main/java/com/demo/upimesh/service/SettlementService.java"
click node_account "https://github.com/varunsingh7389/meshpay-offline-upi-payments-over-mesh/blob/main/upimesh/src/main/java/com/demo/upimesh/repository/AccountRepository.java"
click node_transaction "https://github.com/varunsingh7389/meshpay-offline-upi-payments-over-mesh/blob/main/upimesh/src/main/java/com/demo/upimesh/repository/TransactionRepository.java"
click node_transaction_model "https://github.com/varunsingh7389/meshpay-offline-upi-payments-over-mesh/blob/main/upimesh/src/main/java/com/demo/upimesh/model/Transaction.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_api,node_demo_service toneBlue
class node_mesh_simulator,node_virtual_device,node_packet toneAmber
class node_ingestion,node_crypto,node_key_holder,node_instruction,node_idempotency toneMint
class node_settlement,node_account,node_transaction,node_transaction_model toneRose
class node_sender,node_bridge toneIndigo
```

## Components

### Demo and API

- [Payment Dashboard](https://github.com/varunsingh7389/meshpay-offline-upi-payments-over-mesh/blob/main/upimesh/src/main/resources/templates/dashboard.html): `upimesh/src/main/resources/templates/dashboard.html`
- [Dashboard Controller](https://github.com/varunsingh7389/meshpay-offline-upi-payments-over-mesh/blob/main/upimesh/src/main/java/com/demo/upimesh/controller/DashboardController.java): `upimesh/src/main/java/com/demo/upimesh/controller/DashboardController.java`
- [REST API](https://github.com/varunsingh7389/meshpay-offline-upi-payments-over-mesh/blob/main/upimesh/src/main/java/com/demo/upimesh/controller/ApiController.java): `upimesh/src/main/java/com/demo/upimesh/controller/ApiController.java`
- [Demo Payment Setup](https://github.com/varunsingh7389/meshpay-offline-upi-payments-over-mesh/blob/main/upimesh/src/main/java/com/demo/upimesh/service/DemoService.java): `upimesh/src/main/java/com/demo/upimesh/service/DemoService.java`

### Offline Mesh

- [Mesh Simulator](https://github.com/varunsingh7389/meshpay-offline-upi-payments-over-mesh/blob/main/upimesh/src/main/java/com/demo/upimesh/service/MeshSimulatorService.java): `upimesh/src/main/java/com/demo/upimesh/service/MeshSimulatorService.java`
- [Virtual Device](https://github.com/varunsingh7389/meshpay-offline-upi-payments-over-mesh/blob/main/upimesh/src/main/java/com/demo/upimesh/service/VirtualDevice.java): `upimesh/src/main/java/com/demo/upimesh/service/VirtualDevice.java`
- [Encrypted Mesh Packet](https://github.com/varunsingh7389/meshpay-offline-upi-payments-over-mesh/blob/main/upimesh/src/main/java/com/demo/upimesh/model/MeshPacket.java): `upimesh/src/main/java/com/demo/upimesh/model/MeshPacket.java`

### Secure Ingestion

- [Bridge Ingestion](https://github.com/varunsingh7389/meshpay-offline-upi-payments-over-mesh/blob/main/upimesh/src/main/java/com/demo/upimesh/service/BridgeIngestionService.java): `upimesh/src/main/java/com/demo/upimesh/service/BridgeIngestionService.java`
- [Hybrid Crypto](https://github.com/varunsingh7389/meshpay-offline-upi-payments-over-mesh/blob/main/upimesh/src/main/java/com/demo/upimesh/crypto/HybridCryptoService.java): `upimesh/src/main/java/com/demo/upimesh/crypto/HybridCryptoService.java`
- [Server Key Holder](https://github.com/varunsingh7389/meshpay-offline-upi-payments-over-mesh/blob/main/upimesh/src/main/java/com/demo/upimesh/crypto/ServerKeyHolder.java): `upimesh/src/main/java/com/demo/upimesh/crypto/ServerKeyHolder.java`
- [Payment Instruction](https://github.com/varunsingh7389/meshpay-offline-upi-payments-over-mesh/blob/main/upimesh/src/main/java/com/demo/upimesh/model/PaymentInstruction.java): `upimesh/src/main/java/com/demo/upimesh/model/PaymentInstruction.java`
- [Idempotency Check](https://github.com/varunsingh7389/meshpay-offline-upi-payments-over-mesh/blob/main/upimesh/src/main/java/com/demo/upimesh/service/IdempotencyService.java): `upimesh/src/main/java/com/demo/upimesh/service/IdempotencyService.java`

### Settlement and Ledger

- [Transactional Settlement](https://github.com/varunsingh7389/meshpay-offline-upi-payments-over-mesh/blob/main/upimesh/src/main/java/com/demo/upimesh/service/SettlementService.java): `upimesh/src/main/java/com/demo/upimesh/service/SettlementService.java`
- [Account Repository](https://github.com/varunsingh7389/meshpay-offline-upi-payments-over-mesh/blob/main/upimesh/src/main/java/com/demo/upimesh/repository/AccountRepository.java): `upimesh/src/main/java/com/demo/upimesh/repository/AccountRepository.java`
- [Transaction Repository](https://github.com/varunsingh7389/meshpay-offline-upi-payments-over-mesh/blob/main/upimesh/src/main/java/com/demo/upimesh/repository/TransactionRepository.java): `upimesh/src/main/java/com/demo/upimesh/repository/TransactionRepository.java`
- [Settled Transaction](https://github.com/varunsingh7389/meshpay-offline-upi-payments-over-mesh/blob/main/upimesh/src/main/java/com/demo/upimesh/model/Transaction.java): `upimesh/src/main/java/com/demo/upimesh/model/Transaction.java`

### Other components

- **Payment Sender**
- **Bridge Node**

## Connections

- Payment Sender → Payment Dashboard: composes payment (evidence: `README.md`)
- Payment Dashboard → Dashboard Controller: loads (evidence: `README.md`)
- Payment Sender → REST API: injects payment (evidence: `README.md`)
- REST API → Demo Payment Setup: starts demo
- Demo Payment Setup → Encrypted Mesh Packet: creates encrypted (evidence: `README.md`)
- Demo Payment Setup → Mesh Simulator: injects packet (evidence: `README.md`)
- Mesh Simulator → Virtual Device: simulates hops (evidence: `README.md`)
- Mesh Simulator → Encrypted Mesh Packet: relays with TTL (evidence: `README.md`)
- Bridge Node → REST API: uploads packet (evidence: `README.md`)
- REST API → Bridge Ingestion: ingests packet (evidence: `README.md`)
- Bridge Ingestion → Hybrid Crypto: verifies and decrypts (evidence: `README.md`)
- Hybrid Crypto → Server Key Holder: uses private key (evidence: `README.md`)
- Hybrid Crypto → Payment Instruction: decrypts payload (evidence: `README.md`)
- Bridge Ingestion → Idempotency Check: rejects duplicates (evidence: `README.md`)
- Bridge Ingestion → Transactional Settlement: settles verified payment (evidence: `README.md`)
- Transactional Settlement → Account Repository: debits and credits (evidence: `README.md`)
- Transactional Settlement → Transaction Repository: records settlement (evidence: `README.md`)
- Transaction Repository → Settled Transaction: persists record (evidence: `README.md`)
