
Digital Bank- Distributed transactions and real-time fraud detection.
Production-ready digital banking ecosystem built with Spring Boot microservices, Kafka event orchestration, distributed transactions, real-time fraud detection, Redis caching, and Razorpay payments
Timeline
2 months
Role
Developer
Team
Solo
Status
OngoingTechnology Stack
Key Challenges
- Maintaining distributed data consistency across independent microservices during financial transactions
- Implementing SAGA-based transaction orchestration with reliable compensation and rollback workflows
- Building real-time fraud detection with OTP verification for suspicious transactions
- Ensuring transaction idempotency and preventing duplicate debit or credit operations
- Securing banking APIs with gateway rate limiting and integrating Razorpay webhooks reliably
Key Learnings
- Designing production-grade Spring Boot microservices for distributed banking workflows
- Implementing Apache Kafka event-driven architecture and SAGA orchestration patterns
- Building real-time fraud detection and OTP verification workflows using Kafka and Redis
- Handling distributed transaction integrity with idempotency guards and compensating actions
- Integrating Razorpay payments, webhook processing, API Gateway security, and rate limiting
DigitalBank - Transactions and real-time fraud detection
Overview
Digital Banking System is a production-ready banking platform designed to handle secure money transfers, distributed transactions, real-time fraud detection, and payment processing. The platform uses a microservices architecture where independent services communicate through event-driven workflows to maintain transaction integrity and reliability.
I built the system using Spring Boot microservices, Apache Kafka for event-driven communication and SAGA orchestration, OpenFeign for service-to-service communication, MySQL for persistent data, Redis for caching and OTP storage, an API Gateway with rate limiting, and Razorpay integration for external payment processing.
Live on DigitalBank.saiifbaba.co
Problem Statement
Traditional banking systems often rely on tightly coupled transactional workflows that become difficult to maintain when functionality is distributed across independent microservices. A failure during a money transfer can leave transactions partially completed, creating consistency and reliability challenges. The system needed a production-oriented architecture that could securely process transfers, coordinate distributed transactions, detect fraud in real time, and handle external payments reliably.
System Architecture
The Digital Banking System uses independent Spring Boot microservices coordinated through Kafka-based event-driven workflows and the SAGA pattern:
Client
↓
API Gateway → Rate Limiting / Security
↓
Transaction Service → Kafka → SAGA Orchestration
↓ ↓
Account Service Fraud Detection Service
↓ ↓
MySQL verification.required
↓
OTP Verification
↓
Notification Service
↓
Transaction Flow
External Payments → Razorpay → Webhook → Payment Service
↓
MySQL Status Update
Redis → OTP Storage / CachingKey Features
- Microservices & Transaction Infrastructure
- Spring Boot + Java for production-oriented banking microservices
- Apache Kafka for asynchronous event-driven communication between services
- SAGA orchestration through the Transaction Service for distributed money-transfer workflows
- OpenFeign for synchronous service-to-service communication
- Independent service databases and transaction boundaries using MySQL
- Compensating transactions to reverse previously completed operations when downstream failures occur
- Transaction lifecycle management using states such as PROCESSING, SUCCESS, and FAILED
Transaction Integrity & Idempotency
- Centralized Transaction Service coordinates debit, fraud validation, credit, and notification workflows
- Idempotency guards verify that transactions are still in the PROCESSING state before applying debit - or credit operations
- Prevents duplicate financial operations when Kafka events are redelivered
- Compensation workflows ensure partially completed transactions are safely reverted or marked for recovery
- Kafka-based event flow provides reliable communication across distributed services
Real-Time Fraud Detection & OTP
- Dedicated Fraud Detection Service evaluates transactions for suspicious activity
- Fraud checks execute as part of the transaction workflow before completing transfers
- Suspicious transactions publish a verification.required Kafka event
- Transaction Service generates and manages OTP verification
- Redis provides fast OTP storage and temporary verification data
- Notification Service delivers OTP and transaction alerts
- Transactions proceed only after successful OTP verification
Security & Payment Infrastructure
- API Gateway provides centralized routing and security controls
- Gateway-level rate limiting protects APIs against brute-force and excessive requests
- Authentication and authorization applied across banking services
- Razorpay integration for external payment processing
- Razorpay webhooks handle asynchronous payment success and failure callbacks
- Payment status is verified and persisted in MySQL
- Docker + Docker Compose used to containerize and orchestrate Kafka, MySQL, Redis, and supporting infrastructure
Payment & Transaction Systems
- Razorpay payment gateway integrated in the React Native app via
react-native-razorpay - Backend webhook endpoint verifies Razorpay signature for every transaction
- Booking and payment states synced atomically, so there are no orphaned bookings on payment failure
- Custom Expo plugin (
plugins/) to fix Razorpay native module compatibility with Expo 54 - Transactional validation ensures reliable checkout even on network interruption
Production Deployment
- Microservices: Docker containers with Docker Compose for local and production-style infrastructure
- Kafka: Apache Kafka + Zookeeper for event-driven communication and SAGA orchestration
- Database: MySQL containers with persistent volumes for banking transaction data
- Redis: Redis container for OTP storage, caching, and temporary verification data
- API Gateway: Centralized routing with authentication and rate-limiting configuration
- Payments: Razorpay integration with webhook-based payment status verification
- Environment: Configuration separated for development and production environments
Tech Stack
| Layer | Technology | Purpose |
|---|---|---|
| Backend | Spring Boot + Java | Microservices backend |
| Communication | Apache Kafka | Event-driven communication |
| Orchestration | SAGA Pattern | Distributed transaction management |
| Service Communication | OpenFeign | Synchronous service-to-service calls |
| Database | MySQL | Persistent banking data |
| Caching / OTP | Redis | OTP storage and caching |
| Gateway | API Gateway | Routing, security, and rate limiting |
| Payments | Razorpay | External payment processing |
| Infrastructure | Docker + Docker Compose | Containerization and service orchestration |
| Security | Spring Security | Authentication and authorization |
| Messaging | Kafka Topics | Transaction and fraud events |
Database Schema
Key entities managed across the banking microservices using MySQL:
users -- Customer accounts and authentication details
accounts -- Bank accounts, balances, and account status
transactions -- Transfer records and transaction lifecycle states
transaction_logs -- Transaction events and processing history
otp_verifications -- OTP records and verification status
fraud_checks -- Fraud evaluation results and risk information
payments -- Razorpay payment records and gateway status
notifications -- User transaction and security notificationsEach microservice maintains ownership of its data and transaction boundaries. Distributed workflows are coordinated through Kafka and the SAGA pattern rather than relying on a single database transaction.
What I Learned
Building the Digital Banking System taught me:
- Designing production-grade microservices for complex financial workflows and distributed systems
- Implementing Apache Kafka for reliable event-driven communication between independent services
- Applying the SAGA pattern to coordinate distributed transactions and execute compensating actions
- Building idempotent financial operations to prevent duplicate debit and credit transactions
- Designing real-time fraud detection workflows with OTP-based transaction verification
- Using Redis for high-speed OTP storage, caching, and temporary verification data
- Integrating Razorpay payments and handling asynchronous webhook callbacks reliably
- Securing banking APIs with Spring Security, API Gateway rate limiting, and service-level authorization
Impact
The Digital Banking System demonstrates how a production-oriented banking platform can handle distributed financial transactions while maintaining security, reliability, and consistency.
- Distributed transactions – SAGA orchestration coordinates multi-service money transfers
- Real-time fraud detection – Suspicious transactions are intercepted and routed through OTP verification
- Transaction integrity – Idempotency guards prevent duplicate debit and credit operations
- Fault tolerance – Compensating transactions recover from failures during distributed workflows
- Event-driven architecture – Kafka enables reliable asynchronous communication across banking services
- Secure payments – Razorpay integration supports external payment processing and webhook verification
- API protection – Gateway-level rate limiting helps defend against brute-force and excessive requests
Architecture Highlights
- SAGA orchestration: Transaction Service acts as the central coordinator, managing debit, fraud validation, credit, notification, and compensation workflows
- Event-driven communication: Kafka topics propagate transaction events between independent microservices without tightly coupling services
- Idempotency guards: Services verify the transaction state before processing operations, preventing duplicate financial actions from repeated events
- Compensating transactions: Failed workflows trigger reverse operations to recover previously completed steps and prevent money from becoming stuck
- Fraud-first workflow: Transactions pass through the Fraud Detection Service, with suspicious activity triggering
verification.requiredand OTP verification - Redis-backed verification: OTPs are stored temporarily in Redis for fast validation and expiration
- Independent databases: Microservices maintain their own data boundaries using MySQL rather than relying on a single distributed ACID transaction
- Gateway security: API Gateway centralizes routing, authentication controls, and configurable rate limiting
- External payment integration: Razorpay webhooks asynchronously update payment states while maintaining transaction records in MySQL