How kunalsingh-bais/offline-upi-system-fullstack works
Purpose and topology
This is an offline-payment/UPI-style system: an Angular client packaged as an Android Capacitor app communicates with Spring Boot microservices for authentication, wallet/profile management, and encrypted transaction processing. Bluetooth Low Energy (BLE) supports device-to-device payment exchange and later synchronization.
Client application and entry points
The Angular application starts at frontend/src/main.ts, with routing and providers assembled in frontend/src/app/app.config.ts and frontend/src/app/app.routes.ts. It exposes login/register, dashboard, payment initiation/completion, pending sync, and history views. HTTP authentication is centralized through the route guard and interceptor:
• frontend/src/app/guards/auth-guard.ts
• frontend/src/app/interceptors/auth-interceptor.ts
• frontend/src/app/services/api.ts
Android/BLE native boundary
Capacitor hosts the web client in Android, entered through frontend/android/app/src/main/java/com/offlineupi/MainActivity.java. Native BLE code owns advertising, discovery/client connections, GATT-server behavior, and connection lifecycle; this is the boundary between browser-facing Angular services and Android Bluetooth APIs:
• frontend/android/app/src/main/java/com/offlineupi/ble/BluetoothConnectionManager.java
• frontend/android/app/src/main/java/com/offlineupi/ble/BluetoothGattServerManager.java
• frontend/android/app/src/main/java/com/offlineupi/ble/BluetoothClient.java
Angular-side Bluetooth, encryption, local IndexedDB, network-state, and BLE-sync services enable offline capture and deferred reconciliation:
• frontend/src/app/services/capacitor-bluetooth.ts
• frontend/src/app/services/indexed-db.ts
• frontend/src/app/services/sync-ble.ts
Gateway and service discovery
The backend is independently built Maven/Spring Boot services. Backend/Api-gateway/src/main/java/com/api/gateway/ApiGatewayApplication.java is the intended external backend entry point, configured by Backend/Api-gateway/src/main/resources/application.yml. Service location/registration is handled separately by:
• Backend/Service-registry/src/main/java/com/service/registry/ServiceRegistryApplication.java
• Backend/Service-registry/src/main/resources/application.properties
This establishes an edge-routing/discovery boundary rather than direct frontend coupling to individual services.
Identity and authorization
Auth Service provides registration, login, and token validation. Its controller delegates credential/user operations to AuthService, persists auth users via UserRepository, and issues/verifies JWTs through JwtTokenProvider:
• Backend/Auth-service/src/main/java/com/auth/service/controller/AuthController.java
• Backend/Auth-service/src/main/java/com/auth/service/service/AuthService.java
• Backend/Auth-service/src/main/java/com/auth/service/security/JwtTokenProvider.java
Security configuration is service-local in Backend/Auth-service/src/main/java/com/auth/service/config/SecurityConfig.java. User Service and Transaction Service each contain security configurations and clients, implying token validation or authenticated service-to-service calls rather than a shared in-process security layer.
User profile and wallet domain
User Service separates profile and wallet persistence/operations. It calls Auth Service through AuthServiceClient, then exposes profile and balance endpoints through distinct controllers:
• Backend/User-service/src/main/java/com/user/service/client/AuthServiceClient.java
• Backend/User-service/src/main/java/com/user/service/controller/UserProfileController.java
• Backend/User-service/src/main/java/com/user/service/controller/WalletController.java
Core state is represented by UserProfile and Wallet, persisted through their repositories. Wallet balance updates are a critical downstream boundary for transaction completion.
Transaction lifecycle and cryptography
Transaction Service manages initiate, BLE sync, and completion flows through TransactionController and TransactionService. Transaction state is persisted independently, while a UserServiceClient links completion to wallet/user operations:
• Backend/Transaction-service/src/main/java/com/transaction/service/controller/TransactionController.java
• Backend/Transaction-service/src/main/java/com/transaction/service/service/TransactionService.java
• Backend/Transaction-service/src/main/java/com/transaction/service/client/UserServiceClient.java
The transaction payload boundary explicitly supports encrypted/decrypted forms and BLE-specific payloads. Encryption is layered: RSA key management/public-key publication, AES encryption, hashing, and orchestration in EncryptionProcessor:
• Backend/Transaction-service/src/main/java/com/transaction/service/encryption/RSAKeyService.java
• Backend/Transaction-service/src/main/java/com/transaction/service/encryption/AESEncryptionService.java
• Backend/Transaction-service/src/main/java/com/transaction/service/encryption/EncryptionProcessor.java>
Main entry points: ApiGatewayApplication.java API gateway · indexed-db.ts Offline store & sync · TransactionService.java Transaction lifecycle · AuthController.java Auth service
Components 17
Angular Client
Offline-capable payment UI and client services.
- Angular app
frontend/src/main.ts - Auth guard & interceptor · Protects routes and attaches authentication to API requests.
frontend/src/app/guards/auth-guard.ts - API service
frontend/src/app/services/api.ts - Offline store & sync · Captures offline payment state for deferred reconciliation.
frontend/src/app/services/indexed-db.ts - Capacitor Bluetooth
frontend/src/app/services/capacitor-bluetooth.ts
Android BLE Boundary
Capacitor-hosted native Bluetooth implementation.
- Capacitor Android host
frontend/android/app/src/main/java/com/offlineupi/MainActivity.java - BLE transport · Owns advertising, discovery, GATT server, and connection lifecycle.
frontend/android/app/src/main/java/com/offlineupi/ble/BluetoothConnectionManager.java
Backend Edge
Gateway routing and service discovery.
- API gateway · External backend entry point and router.
Backend/Api-gateway/src/main/java/com/api/gateway/ApiGatewayApplication.java - Service registry
Backend/Service-registry/src/main/java/com/service/registry/ServiceRegistryApplication.java
Identity & Wallet
Authentication, profiles, and wallet balances.
- Auth service · Registration, login, and token validation.
Backend/Auth-service/src/main/java/com/auth/service/controller/AuthController.java - Auth core & JWT · Authenticates users and issues or verifies JWTs.
Backend/Auth-service/src/main/java/com/auth/service/service/AuthService.java - User & wallet service · Serves profiles and balances; applies wallet updates.
Backend/User-service/src/main/java/com/user/service/controller/WalletController.java - Auth service client
Backend/User-service/src/main/java/com/user/service/client/AuthServiceClient.java
Transaction Processing
Encrypted transaction lifecycle and reconciliation.
- Transaction service · Initiates, synchronizes, and completes payments.
Backend/Transaction-service/src/main/java/com/transaction/service/controller/TransactionController.java - Transaction lifecycle · Persists independent transaction state and drives completion.
Backend/Transaction-service/src/main/java/com/transaction/service/service/TransactionService.java - Encryption processor · Coordinates RSA keys, AES encryption, and hashing for transaction payloads.
- User service client · Links transaction completion to wallet and user operations.
Backend/Transaction-service/src/main/java/com/transaction/service/client/UserServiceClient.java
Connections 20
- Angular app → Auth guard & interceptor: protected requests
- Auth guard & interceptor → API service: authenticated HTTP
- API service → API gateway: backend API
- Angular app → Offline store & sync: offline payments
- Offline store & sync → Capacitor Bluetooth: BLE sync
- Capacitor Bluetooth → Capacitor Android host: Capacitor bridge
- Capacitor Android host → BLE transport: native BLE
- BLE transport → Offline store & sync: peer payloads
- API gateway → Service registry: discovers services
- API gateway → Auth service: routes auth
- API gateway → User & wallet service: routes profile/wallet
- API gateway → Transaction service: routes payments
- Auth service → Auth core & JWT: delegates
- User & wallet service → Auth service client: validates identity
- Auth service client → Auth service: auth calls
- Transaction service → Transaction lifecycle: delegates
- Transaction lifecycle → Encryption processor: encrypts/decrypts payloads
- Transaction lifecycle → User service client: completes payment
- User service client → User & wallet service: wallet update
- Offline store & sync → Transaction service: deferred reconciliation