How gnarendra9014-user/payment-wallet-system works
This is a distributed payment and digital-wallet backend. Clients create wallets and initiate transfers, top-ups, or withdrawals through REST APIs; payment requests are persisted and published as events, then the saga coordinator directs wallet mutations and reports completion or failure. Wallet operations maintain balances and transaction history, with compensation events for failures. The graph reflects the README’s documented event flow and capabilities; some consumer, model, and database wiring is based on documented responsibilities because their implementation was not sampled.
Main entry points: kafkaClient.js Kafka event bus · index.js Wallet service · walletRoutes.js Wallet routes · walletConsumer.js Wallet consumer
Components 19
REST services
- Wallet service
services/wallet-service/src/index.js - Wallet routes
services/wallet-service/src/routes/walletRoutes.js - Wallet operations
services/wallet-service/src/controllers/walletController.js - Wallet consumer
services/wallet-service/src/consumers/walletConsumer.js - Payment service
services/payment-service/src/index.js - Payment routes
services/payment-service/src/routes/paymentRoutes.js - Payment operations
services/payment-service/src/controllers/paymentController.js - Payment consumer
services/payment-service/src/consumers/paymentConsumer.js
Saga coordination
- Saga service
services/saga-orchestrator/src/index.js - Saga consumer
services/saga-orchestrator/src/consumers/sagaConsumer.js - Saga state machine
services/saga-orchestrator/src/orchestrator/sagaOrchestrator.js
Event messaging
- Kafka event bus
shared/kafka/kafkaClient.js
State and storage
- Wallet ledger
services/wallet-service/src/models/walletModel.js - Payment records
services/payment-service/src/models/paymentModel.js - Saga state
services/saga-orchestrator/src/models/sagaModel.js - Idempotency middleware
shared/middleware/idempotency.js - PostgreSQL
- Redis cache
Other components
- API client
Connections 27
- API client → Wallet service: REST requests
- API client → Payment service: REST requests
- Wallet service → Wallet routes: mounts routes
- Wallet routes → Wallet operations: dispatches
- Wallet routes → Idempotency middleware: guards mutations
- Wallet operations → Wallet ledger: reads and mutates
- Wallet service → Wallet consumer: starts consumer
- Wallet consumer → Wallet ledger: applies wallet events
- Wallet consumer → Kafka event bus: consumes and publishes
- Payment service → Payment routes: mounts routes
- Payment routes → Payment operations: dispatches
- Payment routes → Idempotency middleware: guards mutations
- Payment operations → Payment records: creates and queries
- Payment operations → Kafka event bus: publishes initiated
- Payment service → Payment consumer: starts consumer
- Payment consumer → Payment records: updates payment status
- Payment consumer → Kafka event bus: consumes status events
- Saga service → Saga consumer: starts consumer
- Saga service → Saga state: serves saga queries
- Saga consumer → Saga state machine: dispatches events
- Saga consumer → Kafka event bus: consumes events
- Saga state machine → Saga state: creates and updates
- Saga state machine → Kafka event bus: publishes saga commands
- Idempotency middleware → Redis cache: checks cache
- Wallet ledger → PostgreSQL: persists balances and ledger
- Payment records → PostgreSQL: persists payments
- Saga state → PostgreSQL: persists saga state