How alokraj04/offlinepay works
OfflinePay demonstrates offline-first UPI payments: a sender creates an encrypted payment packet, simulated nearby devices relay it by gossip, and a connected bridge submits it for deduplication, replay checks, and ledger settlement. The API also exposes mesh controls, server-key metadata, account and transaction views, and a dashboard. The frontend React entry is empty in the sampled source; the dashboard is served from the Spring template. Mesh transport is simulated rather than real Bluetooth, and unsampled subsystem links are limited to documented behavior.
Main entry points: ApiController.java REST API · BridgeIngestionService.java Bridge ingestion · DemoService.java Packet creation · MeshSimulatorService.java Mesh gossip
Components 17
Payment flow
- Packet creation
src/main/java/com/demo/offlinepay/service/DemoService.java - Hybrid crypto
src/main/java/com/demo/offlinepay/crypto/HybridCryptoService.java - Server keys
src/main/java/com/demo/offlinepay/crypto/ServerKeyHolder.java
Mesh simulation
- Mesh gossip
src/main/java/com/demo/offlinepay/service/MeshSimulatorService.java - Virtual devices
src/main/java/com/demo/offlinepay/service/VirtualDevice.java
Ingestion and ledger
- Bridge ingestion
src/main/java/com/demo/offlinepay/service/BridgeIngestionService.java - Deduplication cache
src/main/java/com/demo/offlinepay/service/IdempotencyService.java - Ledger settlement
src/main/java/com/demo/offlinepay/service/SettlementService.java - Account repository
src/main/java/com/demo/offlinepay/model/AccountRepository.java - Transaction repository
src/main/java/com/demo/offlinepay/model/TransactionRepository.java - Relational database
API and dashboard
- REST API
src/main/java/com/demo/offlinepay/controller/ApiController.java - Dashboard route
src/main/java/com/demo/offlinepay/controller/DashboardController.java - Dashboard template
src/main/resources/templates/dashboard.html
Other components
- Sender device
- Bridge node
- API client
Connections 23
- Sender device → REST API: requests send
- REST API → Packet creation: creates packet
- Packet creation → Hybrid crypto: encrypts payment
- Packet creation → Server keys: gets public key
- Hybrid crypto → Server keys: uses private key
- REST API → Mesh gossip: injects and controls
- Mesh gossip → Virtual devices: stores and relays
- API client → REST API: calls endpoints
- REST API → Bridge ingestion: dispatches ingest
- Bridge node → REST API: uploads packet
- Mesh gossip → REST API: flush uploads
- REST API → Bridge ingestion: flushes packets
- Bridge ingestion → Hybrid crypto: hashes and decrypts
- Bridge ingestion → Deduplication cache: claims hash
- Bridge ingestion → Ledger settlement: settles payment
- Ledger settlement → Account repository: reads and updates
- Ledger settlement → Transaction repository: records outcome
- REST API → Account repository: lists accounts
- REST API → Transaction repository: lists transactions
- Account repository → Relational database: persists accounts
- Transaction repository → Relational database: persists transactions
- API client → Dashboard route: opens dashboard
- Dashboard route → Dashboard template: renders view