# khushi6659/nyranet-pay architecture

> Architecture diagram of the GitHub repository khushi6659/nyranet-pay, 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/khushi6659/nyranet-pay
- Repository: https://github.com/khushi6659/nyranet-pay

## Overview

UPI Offline Mesh is a Spring Boot demo of offline payments carried by a simulated device mesh and settled by a backend after a bridge regains connectivity. The user workflow is to compose and encrypt a payment, gossip its packet across virtual devices, upload it through a bridge, reject duplicates or invalid packets, and settle the payment into account balances and a transaction ledger. The README documents these relationships; source excerpts were not provided, so implementation-level call ownership could not be verified.

Main entry points: [`src/main/java/com/demo/upimesh/service/MeshSimulatorService.java`](https://github.com/khushi6659/nyranet-pay/blob/main/src/main/java/com/demo/upimesh/service/MeshSimulatorService.java) (Mesh simulator), [`src/main/resources/templates`](https://github.com/khushi6659/nyranet-pay/tree/main/src/main/resources/templates) (Dashboard), [`src/main/java/com/demo/upimesh/service/BridgeIngestionService.java`](https://github.com/khushi6659/nyranet-pay/blob/main/src/main/java/com/demo/upimesh/service/BridgeIngestionService.java) (Bridge ingestion), [`src/main/java/com/demo/upimesh/service/SettlementService.java`](https://github.com/khushi6659/nyranet-pay/blob/main/src/main/java/com/demo/upimesh/service/SettlementService.java) (Settlement service)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_mesh["Payment Mesh"]
  node_payment["Payment instruction"]
  node_packet["Mesh packet<br/>[MeshPacket.java]"]
  node_simulator["Mesh simulator"]
  node_device["Virtual device<br/>[VirtualDevice.java]"]
end

subgraph group_ingestion["Backend Ingestion"]
  node_crypto["Hybrid encryption"]
  node_keyholder["Server keys"]
  node_bridge["Bridge ingestion"]
  node_api["Ingest API<br/>[ApiController.java]"]
  node_idempotency["Idempotency claims"]
end

subgraph group_settlement["Settlement Ledger"]
  node_settlement_service["Settlement service"]
  node_account[("Accounts<br/>[Account.java]")]
  node_account_repo["Account repository"]
  node_transaction[("Transaction ledger<br/>[Transaction.java]")]
  node_transaction_repo["Transaction repository"]
end

subgraph group_interface["Demo Interface"]
  node_dashboard["Dashboard"]
  node_user_controller["User controls"]
  node_admin_controller["Admin controls"]
end

node_user(("Demo user"))

node_user -->|"operates"| node_dashboard
node_dashboard -->|"drives demo"| node_user_controller
node_user_controller -->|"injects payment"| node_simulator
node_simulator -->|"builds"| node_payment
node_simulator -->|"encrypts with"| node_crypto
node_crypto -->|"uses server key"| node_keyholder
node_simulator -->|"wraps ciphertext"| node_packet
node_simulator -->|"hands packet"| node_device
node_device -->|"gossips packet"| node_device
node_dashboard -->|"runs rounds"| node_simulator
node_dashboard -->|"uploads packets"| node_api
node_api -->|"routes ingest"| node_bridge
node_bridge -->|"claims hash"| node_idempotency
node_bridge -->|"decrypts packet"| node_crypto
node_bridge -->|"settles valid payment"| node_settlement_service
node_settlement_service -->|"updates accounts"| node_account_repo
node_account_repo -->|"persists balances"| node_account
node_settlement_service -->|"writes ledger"| node_transaction_repo
node_transaction_repo -->|"persists entry"| node_transaction
node_admin_controller -.->|"supports admin view"| node_dashboard

click node_dashboard "https://github.com/khushi6659/nyranet-pay/tree/main/src/main/resources/templates"
click node_user_controller "https://github.com/khushi6659/nyranet-pay/blob/main/src/main/java/com/demo/upimesh/controller/UserController.java"
click node_admin_controller "https://github.com/khushi6659/nyranet-pay/blob/main/src/main/java/com/demo/upimesh/controller/AdminController.java"
click node_payment "https://github.com/khushi6659/nyranet-pay/blob/main/src/main/java/com/demo/upimesh/model/PaymentInstruction.java"
click node_crypto "https://github.com/khushi6659/nyranet-pay/blob/main/src/main/java/com/demo/upimesh/crypto/HybridCryptoService.java"
click node_keyholder "https://github.com/khushi6659/nyranet-pay/blob/main/src/main/java/com/demo/upimesh/crypto/ServerKeyHolder.java"
click node_packet "https://github.com/khushi6659/nyranet-pay/blob/main/src/main/java/com/demo/upimesh/model/MeshPacket.java"
click node_simulator "https://github.com/khushi6659/nyranet-pay/blob/main/src/main/java/com/demo/upimesh/service/MeshSimulatorService.java"
click node_device "https://github.com/khushi6659/nyranet-pay/blob/main/src/main/java/com/demo/upimesh/service/VirtualDevice.java"
click node_bridge "https://github.com/khushi6659/nyranet-pay/blob/main/src/main/java/com/demo/upimesh/service/BridgeIngestionService.java"
click node_api "https://github.com/khushi6659/nyranet-pay/blob/main/src/main/java/com/demo/upimesh/controller/ApiController.java"
click node_idempotency "https://github.com/khushi6659/nyranet-pay/blob/main/src/main/java/com/demo/upimesh/service/IdempotencyService.java"
click node_settlement_service "https://github.com/khushi6659/nyranet-pay/blob/main/src/main/java/com/demo/upimesh/service/SettlementService.java"
click node_account "https://github.com/khushi6659/nyranet-pay/blob/main/src/main/java/com/demo/upimesh/model/Account.java"
click node_account_repo "https://github.com/khushi6659/nyranet-pay/blob/main/src/main/java/com/demo/upimesh/model/AccountRepository.java"
click node_transaction "https://github.com/khushi6659/nyranet-pay/blob/main/src/main/java/com/demo/upimesh/model/Transaction.java"
click node_transaction_repo "https://github.com/khushi6659/nyranet-pay/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_payment,node_packet,node_simulator,node_device,node_user toneBlue
class node_crypto,node_keyholder,node_bridge,node_api,node_idempotency toneAmber
class node_settlement_service,node_account,node_account_repo,node_transaction,node_transaction_repo toneMint
class node_dashboard,node_user_controller,node_admin_controller toneRose
```

## Components

### Payment Mesh

- [Payment instruction](https://github.com/khushi6659/nyranet-pay/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/khushi6659/nyranet-pay/blob/main/src/main/java/com/demo/upimesh/model/MeshPacket.java): `src/main/java/com/demo/upimesh/model/MeshPacket.java`
- [Mesh simulator](https://github.com/khushi6659/nyranet-pay/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/khushi6659/nyranet-pay/blob/main/src/main/java/com/demo/upimesh/service/VirtualDevice.java): `src/main/java/com/demo/upimesh/service/VirtualDevice.java`

### Backend Ingestion

- [Hybrid encryption](https://github.com/khushi6659/nyranet-pay/blob/main/src/main/java/com/demo/upimesh/crypto/HybridCryptoService.java): `src/main/java/com/demo/upimesh/crypto/HybridCryptoService.java`
- [Server keys](https://github.com/khushi6659/nyranet-pay/blob/main/src/main/java/com/demo/upimesh/crypto/ServerKeyHolder.java): `src/main/java/com/demo/upimesh/crypto/ServerKeyHolder.java`
- [Bridge ingestion](https://github.com/khushi6659/nyranet-pay/blob/main/src/main/java/com/demo/upimesh/service/BridgeIngestionService.java): `src/main/java/com/demo/upimesh/service/BridgeIngestionService.java`
- [Ingest API](https://github.com/khushi6659/nyranet-pay/blob/main/src/main/java/com/demo/upimesh/controller/ApiController.java): `src/main/java/com/demo/upimesh/controller/ApiController.java`
- [Idempotency claims](https://github.com/khushi6659/nyranet-pay/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/khushi6659/nyranet-pay/blob/main/src/main/java/com/demo/upimesh/service/SettlementService.java): `src/main/java/com/demo/upimesh/service/SettlementService.java`
- [Accounts](https://github.com/khushi6659/nyranet-pay/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/khushi6659/nyranet-pay/blob/main/src/main/java/com/demo/upimesh/model/AccountRepository.java): `src/main/java/com/demo/upimesh/model/AccountRepository.java`
- [Transaction ledger](https://github.com/khushi6659/nyranet-pay/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/khushi6659/nyranet-pay/blob/main/src/main/java/com/demo/upimesh/model/TransactionRepository.java): `src/main/java/com/demo/upimesh/model/TransactionRepository.java`

### Demo Interface

- [Dashboard](https://github.com/khushi6659/nyranet-pay/tree/main/src/main/resources/templates): `src/main/resources/templates`
- [User controls](https://github.com/khushi6659/nyranet-pay/blob/main/src/main/java/com/demo/upimesh/controller/UserController.java): `src/main/java/com/demo/upimesh/controller/UserController.java`
- [Admin controls](https://github.com/khushi6659/nyranet-pay/blob/main/src/main/java/com/demo/upimesh/controller/AdminController.java): `src/main/java/com/demo/upimesh/controller/AdminController.java`

### Other components

- **Demo user**

## Connections

- Demo user → Dashboard: operates (evidence: `README.md`)
- Dashboard → User controls: drives demo (evidence: `README.md`)
- User controls → Mesh simulator: injects payment (evidence: `README.md`)
- Mesh simulator → Payment instruction: builds (evidence: `README.md`)
- Mesh simulator → Hybrid encryption: encrypts with (evidence: `README.md`)
- Hybrid encryption → Server keys: uses server key (evidence: `README.md`)
- Mesh simulator → Mesh packet: wraps ciphertext (evidence: `README.md`)
- Mesh simulator → Virtual device: hands packet (evidence: `README.md`)
- Virtual device → Virtual device: gossips packet (evidence: `README.md`)
- Dashboard → Mesh simulator: runs rounds (evidence: `README.md`)
- Dashboard → Ingest API: uploads packets (evidence: `README.md`)
- Ingest API → Bridge ingestion: routes ingest (evidence: `README.md`)
- Bridge ingestion → Idempotency claims: claims hash (evidence: `README.md`)
- Bridge ingestion → Hybrid encryption: decrypts packet (evidence: `README.md`)
- Bridge ingestion → Settlement service: settles valid payment (evidence: `README.md`)
- Settlement service → Account repository: updates accounts (evidence: `README.md`)
- Account repository → Accounts: persists balances (evidence: `README.md`)
- Settlement service → Transaction repository: writes ledger (evidence: `README.md`)
- Transaction repository → Transaction ledger: persists entry (evidence: `README.md`)
- Admin controls → Dashboard: supports admin view
