A microservices-based digital banking platform implementing the SAGA pattern for distributed transaction consistency, with real-time fraud detection and event-driven notifications.
| Service | Port | Responsibility |
|---|---|---|
| api-gateway | 8080 | Single entry point, rate limiting |
| account-service | 8081 | Account management, balance, deduct/credit/refund |
| transaction-service | 8082 | SAGA orchestrator — money transfers, transaction history |
| payment-service | 8083 | Razorpay integration, external payments |
| fraud-detection-service | 8084 | Real-time fraud detection via Redis |
| notification-service | 8085 | Transaction and fraud alerts (email/SMS) |
User → API Gateway (rate limiting)
↓
Transaction Service (SAGA orchestrator)
↓
Account Service
(validate balance, deduct)
↓
Apache Kafka
↓
┌────────────────────────┐
│ │
Fraud Detection Transaction Service
(Redis patterns) (decides next step)
│ │
▼ ▼
Account Service Notification Service
(block if fraud / (debit/credit/fraud alerts)
credit receiver)
Each service owns its own database (account DB, transaction DB, payment DB). A traditional single-database system rolls back automatically on failure — in a distributed setup, no single database can undo a step that already committed in another service. The transaction-service acts as the SAGA orchestrator: it tracks each step (deduct → fraud-check → credit) and triggers explicit compensating actions (e.g. refund, unblock) if a later step fails, rather than relying on an implicit rollback.
| Topic | Publisher | Consumer |
|---|---|---|
transaction.initiated |
Transaction Service | Fraud Detection Service |
fraud.check.result |
Fraud Detection Service | Transaction Service |
transaction.completed |
Transaction Service | Account Service, Notification Service |
fraud.detected |
Fraud Detection Service | Account Service, Notification Service |
payment.completed |
Payment Service | Notification Service |
- Backend: Java, Spring Boot, Spring Cloud Gateway, OpenFeign
- Messaging: Apache Kafka
- Caching: Redis (fraud pattern detection, rate limiting)
- Database: MySQL (per-service, separate schemas)
- Payments: Razorpay integration
- Infra: Docker (Kafka, Zookeeper, Redis, MySQL via docker-compose)
docker-compose up -dThis brings up Kafka, Zookeeper, Redis, and MySQL (skip MySQL in
docker-compose if you're running it locally already).
# Terminal 1
cd account-service && mvn spring-boot:run
# Terminal 2
cd transaction-service && mvn spring-boot:run
# Terminal 3
cd payment-service && mvn spring-boot:run
# Terminal 4
cd fraud-detection-service && mvn spring-boot:run
# Terminal 5
cd notification-service && mvn spring-boot:run
# Terminal 6
cd api-gateway && mvn spring-boot:runBefore testing, set the following in each service's application.yml:
- MySQL username/password
- Razorpay API key/secret (payment-service)
- Email/SMS credentials (notification-service)
Note: Do not commit real credentials. Use environment variables or a
.gitignore'd local properties file.
- User initiates a transfer →
POST /api/v1/transactions/transfer - API Gateway rate-limits and forwards to Transaction Service
- Transaction Service calls Account Service to validate and deduct balance
- Transaction saved with status
PROCESSING;transaction.initiatedpublished to Kafka - Fraud Detection Service consumes the event, checks Redis-based patterns
- If clean → Transaction Service credits receiver, publishes
transaction.completed - If suspicious → account is flagged/blocked,
fraud.detectedpublished, user notified - Notification Service sends alerts at each key step (debit, credit, fraud, block)