Skip to content

Divinekk/LedgerLoom

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 

Repository files navigation

💳 LedgerLoom: High-Concurrency Transaction Engine

A specialized backend engine for atomic financial transfers, designed to solve the Double-Spending Problem in high-traffic fintech environments.

"In a system processing millions of transactions, a 0.01% race condition is a 100% failure in trust."


🎯 Focus

This is NOT a full banking system. This is a focused demonstration of handling concurrent financial transactions safely.

Key Challenge Solved: Preventing double-spending when multiple transfer requests hit the server simultaneously.

✨ Core Features

  • Wallet Provisioning: Secure creation and funding of digital wallets.
  • Atomic Transfers: Guaranteed "all-or-nothing" fund movements between users.
  • Concurrency Control: Automatic detection and rejection of simultaneous conflicting transactions.
  • Real-time Balance: Instant retrieval of current account state.

🔐 Transaction Safety (ACID Compliance)

🛡️ Optimistic Locking

Uses JPA @Version to detect concurrent modifications:

  • If User A and User B both try to transfer from the same wallet at the same millisecond, the first transaction succeeds.
  • The second transaction fails immediately (Fail-fast) to prevent a "Lost Update."
  • Benefit: Prevents double-spending without the performance bottleneck of heavy database locks.

⚛️ Atomic Transactions

The @Transactional annotation ensures that both wallet updates (Deduct from sender → Add to receiver) succeed or both fail:

  • If ANY step fails, the entire transaction rolls back.
  • Benefit: No partial transfers or "missing" money in the ledger.

🏗️ Tech Stack

  • Java 17 & Spring Boot 3.4+
  • Spring Data JPA (Hibernate)
  • PostgreSQL (Chosen for robust transaction support)
  • Spring Security & JWT (Stateless Authentication)
  • Docker & Docker Compose (Containerized Environment)

📡 API Endpoints

Method Endpoint Description
POST /api/auth/register Create a new user and wallet
POST /api/auth/login Authenticate and receive JWT
POST /api/wallet/deposit Add funds to current user's wallet
POST /api/wallet/transfer Execute atomic transfer to another user
GET /api/wallet/balance View current balance

🚀 Quick Start

# Clone the repository
git clone https://github.com

# Start the PostgreSQL database
docker compose up -d

# Run the application
mvn spring-boot:run

About

A Secure, Atomic Transaction Engine for Digital Wallets.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors