Cloud-Native Banking & Transaction Engine
Distributed FinTech backend implementing ACID-compliant fund transfers, idempotency keys, JWT role-based security, and event-driven audit logging with Spring Boot and PostgreSQL.
Problem Statement & Objectives
Financial systems cannot afford dirty reads, double-debit anomalies, or race conditions when concurrent requests attempt to withdraw from or transfer money between bank accounts simultaneously.
Key Project Objectives:
- •Architect decoupled microservices for User Management, Account Balance Ledgers, and Transaction Auditing.
- •Enforce strict transaction boundaries using pessimistic write locks (`SELECT ... FOR UPDATE`) to prevent double-spending race conditions.
- •Implement idempotency keys for all mutating transfer endpoints to ensure network retries never result in duplicate financial deductions.
- •Secure all communication channels with stateless JWT authentication and role-based access control (RBAC).
System Architecture
The system utilizes an API Gateway routing traffic to three distinct Spring Boot services: Auth Service (JWT issuance), Account Service (balance management with pessimistic locking), and Transaction Ledger Service (immutable audit trail). Database transactions execute at `SERIALIZABLE` or `READ_COMMITTED` with row-level locking on balance modifications.
+-------------------------------------------------------------------------+
| CLIENT / WEB DASHBOARD |
+-------------------------------------------------------------------------+
|
| (HTTPS / Bearer Token)
v
+-------------------------------------------------------------------------+
| API GATEWAY & SECURITY |
| (Spring Cloud Gateway / Spring Security JWT Filter) |
+-------------------------------------------------------------------------+
| |
v v
+----------------------------------+ +----------------------------------+
| ACCOUNT SERVICE | | TRANSACTION AUDIT LEDGER |
| (Spring Boot 3 / Hibernate JPA) | | (Append-Only Financial Records) |
+----------------------------------+ +----------------------------------+
| |
v v
+-------------------------------------------------------------------------+
| POSTGRESQL REPOSITORY |
| - Accounts Table (Row-Level Pessimistic Locking: SELECT ... FOR UPDATE)|
| - Ledger Transactions (Immutable Double-Entry Bookkeeping) |
| - Idempotency Keys Cache Table (24-Hour Expiry Window) |
+-------------------------------------------------------------------------+Database Design (Relational (PostgreSQL 16))
Strict 3NF normalized schema with foreign key constraints, check constraints ensuring balances never fall below zero, and B-Tree indexes on account numbers.
Customer and administrative profiles.
Financial ledger accounts with balance check constraints.
Immutable ledger entries recording fund transfers.
REST API Specifications
Authenticates user and returns JWT bearer token.
{
"token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...",
"expires_in": 3600,
"role": "CUSTOMER"
}Executes atomic fund transfer between accounts with required X-Idempotency-Key header.
{
"transaction_id": "b086e3cb-33d3-49d7-84bc-5d9c735d648b",
"source_account": "ACC-100234",
"destination_account": "ACC-800412",
"amount": 250.00,
"status": "COMPLETED"
}Step-by-Step Implementation Guide
Step 1: Account Entity with Versioning & Balance Validation
Define the JPA Account entity with `@Entity`, currency formatting stored in smallest currency units (cents/paise) to eliminate floating-point rounding errors.
Step 2: Atomic Transfer Service with Row Locking
Execute transfer inside `@Transactional` boundary, acquiring pessimistic write locks on both accounts ordered by account number to prevent database deadlocks.
Placement Viva & Technical Questions
Questions commonly asked by college examiners and product company interviewers regarding this project architecture.