Skip to main content
DevProjects
AdvancedFinal YearMajorPlacementSpring Boot

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.

Author: Rohit Sharma (Principal Systems Architect & Placement Mentor)
Reviewed by Ananya Verma
Updated: Sep 30, 2026

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.

Real-World Context:Core banking engines, digital wallet platforms (like Paytm / PhonePe architectures), inter-bank settlement gateways, and neobank ledger platforms.

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.

Table: usersPK: id (BIGSERIAL)

Customer and administrative profiles.

idusernameemailpassword_hashrolecreated_at
Table: accountsPK: account_number (VARCHAR 20)

Financial ledger accounts with balance check constraints.

account_numberuser_idcurrencybalance_centsstatusversion
Table: transactionsPK: id (UUID)

Immutable ledger entries recording fund transfers.

idsource_accountdestination_accountamount_centsidempotency_keytimestampstatus

REST API Specifications

POST/api/v1/auth/login

Authenticates user and returns JWT bearer token.

Response Payload:
{
  "token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...",
  "expires_in": 3600,
  "role": "CUSTOMER"
}
POST/api/v1/transfers

Executes atomic fund transfer between accounts with required X-Idempotency-Key header.

Response Payload:
{
  "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.

Account.java
@Entity
@Table(name = "accounts")
public class Account {
    @Id
    private String accountNumber;

    @Column(nullable = false)
    private Long balanceCents;

    @Version
    private Long version;

    public void debit(Long amount) {
        if (this.balanceCents < amount) {
            throw new InsufficientFundsException("Account has insufficient balance");
        }
        this.balanceCents -= amount;
    }

    public void credit(Long amount) {
        this.balanceCents += amount;
    }
}

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.

TransferService.java
@Service
public class TransferService {
    @Autowired
    private AccountRepository accountRepository;

    @Transactional
    public TransactionResult executeTransfer(String fromAcc, String toAcc, Long amount) {
        // Order locks lexicographically to prevent deadlocks
        String firstLock = fromAcc.compareTo(toAcc) < 0 ? fromAcc : toAcc;
        String secondLock = fromAcc.compareTo(toAcc) < 0 ? toAcc : fromAcc;

        Account source = accountRepository.findByAccountNumberForUpdate(fromAcc);
        Account destination = accountRepository.findByAccountNumberForUpdate(toAcc);

        source.debit(amount);
        destination.credit(amount);

        return new TransactionResult(UUID.randomUUID(), "COMPLETED");
    }
}

Placement Viva & Technical Questions

Questions commonly asked by college examiners and product company interviewers regarding this project architecture.

Floating-point numbers in computer architectures cannot accurately represent decimal fractions in base-2 IEEE 754 standards (e.g., 0.1 + 0.2 = 0.30000000000000004). In banking systems, this causes roundoff discrepancy leaks over millions of transactions. We store monetary amounts in atomic integer units (cents/paise) or use Java's BigDecimal with explicit rounding modes.

Project FAQs

Yes. Enterprise backend roles at banks, fintechs, and product firms place heavy emphasis on Spring Boot, ACID transactions, database locking, and microservices architecture.
Cross-Disciplinary Paths

Related Engineering Projects

View All Projects →
IntermediatePortfolio
TypeScript, JavaScript, Python

Real-Time Collaborative Code Editor & Runner

Browser-based collaborative IDE supporting multi-user concurrent code editing via Operational Transformation (CRDT / Yjs), real-time WebSockets, Monaco Editor, and containerized code execution.

Core Competencies
React & TypeScript Component State ManagementWebSocket Protocols & Socket.io Room PartitioningConflict-Free Replicated Data Types (CRDTs)+3 more
Full Architecture & APIs
View Guide
IntermediateFinal Year
Python

AI Resume Screening & Skill Matching Engine

An end-to-end NLP pipeline parsing unstructured candidate resumes (PDF/DOCX), extracting technical skill entities, and computing cosine similarity against job descriptions with FastAPI.

Core Competencies
Natural Language Processing (NLP)Named Entity Recognition (NER)TF-IDF & Dense Embeddings+3 more
Full Architecture & APIs
View Guide