Skip to content

Repository files navigation

FORGE Logo

# FORGE — Real-Time Auction & Commerce Engine

A high-performance concurrent bidding engine wrapped in a production-grade enterprise platform.

JavaSpring BootPostgreSQLRedisTestsCoverageBenchmark


What is FORGE?

FORGE is a real-time online auction platform where sellers list items, bidders compete in live auctions, and the system handles concurrent bid matching, settlement, and wallet management — processing hundreds of thousands of bids per second using lock-free data structures and Java 21 Virtual Threads.


Architecture — Two Module Design

forge/
├── forge-engine/ # Pure Java 21 — zero Spring dependencies
│ ├── BiddingEngine # ConcurrentSkipListMap + Virtual Threads
│ ├── PriceTracker # AtomicReference CAS loop — lock-free
│ ├── BidBook # O(log n) thread-safe ordered bid storage
│ ├── AuctionStateMachine # ReentrantReadWriteLock state transitions
│ ├── EventBus # BlockingQueue pub/sub — Producer-Consumer
│ └── SettlementCalculator # Fee + tax computation
│
└── forge-platform/ # Spring Boot 3.2 — wraps the engine
├── REST API # JWT-secured endpoints
├── WebSocket # STOMP real-time bid feed
├── PostgreSQL # JPA + Hibernate 6 + Flyway migrations
├── Redis # Distributed caching
├── Quartz # DB-backed persistent job scheduling
└── MinIO # S3-compatible image storage

Why two modules? The engine is pure Java — no annotations, no DI framework. It can be embedded in any Java application. The platform wraps it with Spring Boot for REST, security, and persistence. ArchUnit enforces this separation automatically on every build.


Tech Stack

LayerTechnology
LanguageJava 21 (Virtual Threads, Records, Sealed Classes)
FrameworkSpring Boot 3.2
DatabasePostgreSQL 16
MigrationsFlyway
CacheRedis 7
SchedulerQuartz (DB-backed, crash-safe)
File StorageMinIO (S3-compatible)
SecuritySpring Security 6 + JWT
Real-timeWebSocket + STOMP
TestingJUnit 5 + Mockito + ArchUnit
BenchmarksJMH
CoverageJaCoCo (80%+)
BuildMaven multi-module

Performance

MetricResult
JMH Throughput400K–700K ops/sec (8 threads)
Concurrency Stress1000 virtual threads, 0 failures
Total Tests128 passing, 0 failures
JaCoCo Coverage80%+
Architecture RulesAll passing (ArchUnit)

Design Patterns

PatternImplementation
StrategyPricingStrategy → English, Dutch, Sealed auction types
ObserverEventBus + EngineEventListener → WebSocket, DB bridge
StateAuctionStateMachine with validated transitions
Producer-ConsumerLinkedBlockingQueue in EventBus
CAS LoopPriceTracker — lock-free price updates
BuilderAuction creation

Prerequisites

  • Java 21+
  • Maven 3.9+
  • Docker (for PostgreSQL, Redis, MinIO)

Quick Start

1. Start Infrastructure

# PostgreSQL
docker run -d --name postgres-forge \
-e POSTGRES_DB=forge_db \
-e POSTGRES_USER=postgres \
-e POSTGRES_PASSWORD=sensei \
-p 5432:5432 postgres:16
# Redis
docker run -d --name redis-forge \
-p 6379:6379 redis:7-alpine
# MinIO
docker run -d --name minio-forge \
-p 9000:9000 -p 9001:9001 \
-e MINIO_ROOT_USER=sensei \
-e MINIO_ROOT_PASSWORD=sensei123 \
quay.io/minio/minio server /data --console-address ":9001"

2. Build

# Build engine firstcd forge-engine && mvn clean install
# Run platformcd ../forge-platform && mvn spring-boot:run

3. Verify

API: http://localhost:8080/api/v1/
Swagger: http://localhost:8080/swagger-ui.html
MinIO UI: http://localhost:9001

API Reference

Auth

POST /api/v1/auth/register Register user
POST /api/v1/auth/login Login → returns JWT

Auctions

POST /api/v1/auctions Create auction
GET /api/v1/auctions/active List active auctions
GET /api/v1/auctions/active/paged List with pagination (?page=0&size=20)
DELETE /api/v1/auctions/{id} Delete auction

Bidding

POST /api/v1/auctions/{id}/bid Place bid (REST)
WS /ws WebSocket STOMP endpoint
SUB /topic/auctions/{id} Subscribe to live bid feed

Wallet

POST /api/v1/wallet/topup Add funds
GET /api/v1/wallet/balance Get balance

Images

POST /api/v1/images/upload Upload auction image → returns MinIO URL

Running Tests

# All engine tests (pure Java, no Docker needed)cd forge-engine && mvn test# All platform testscd forge-platform && mvn test# Full test suite with coverage report
mvn clean verify
# View coverage: forge-platform/target/site/jacoco/index.html

Concurrency Model

Bid Request (1000 concurrent)
↓
Virtual Thread Pool (Java 21)
↓
AuctionStateMachine.isActive() — READ LOCK
↓
PriceTracker.updatePrice() — CAS Loop (lock-free)
↓
BidBook.addBid() — ConcurrentSkipListMap O(log n)
↓
EventBus.publish() — LinkedBlockingQueue (non-blocking)
↓
WebSocket broadcast + DB persist (async)

Project Structure

forge-engine/src/
├── main/java/com/forge/engine/
│ ├── bidding/ BiddingEngine, BidBook
│ ├── event/ EventBus, EngineEvent (sealed), BidPlacedEvent
│ ├── model/ Bid, BidKey, Money, AuctionStateMachine, BidResult
│ ├── pricing/ PricingStrategy, English/Dutch/SealedBidPricing
│ ├── settlement/ SettlementCalculator, FeeCalculator, SettlementResult
│ └── tracker/ PriceTracker (AtomicReference CAS)
└── test/java/com/forge/engine/
├── architecture/ EngineArchitectureTest (ArchUnit)
├── benchmark/ BiddingEngineBenchmark (JMH)
├── bidding/ BidBookTest, BiddingEngineConcurrencyTest
├── model/ MoneyTest, AuctionStateMachineTest
└── settlement/ FeeCalculatorTest
forge-platform/src/
├── main/java/com/forge/platform/
│ ├── config/ Security, Redis, Quartz, MinIO, Engine wiring
│ ├── controller/ Auth, Auction, Bid, Wallet, Image, User
│ ├── entity/ User, Auction, Bid, Wallet
│ ├── service/ AuctionService, WalletService, AuthService, BidService
│ ├── repository/ JPA repositories with custom JPQL queries
│ ├── scheduler/ Quartz jobs (AuctionLifecycleJob)
│ ├── security/ JWT filter, token service
│ ├── bridge/ Engine ↔ Platform (DatabaseBridge, WebSocketBridge)
│ └── exception/ GlobalExceptionHandler
└── test/ 128 tests — service, controller, repository, arch

Also Published

PII Masker Spring Boot Starter — auto-masks Aadhaar/PAN numbers in logs

<dependency>
<groupId>io.github.ketansinghrajput</groupId>
<artifactId>pii-masker-spring-boot-starter</artifactId>
<version>1.0.1</version>
</dependency>

Maven Central


Author

Ketansingh Rajput — System Engineer Intern @ EdgeVerve Systems (Infosys)

B.E. Electronics & Telecommunication — SPPU 2025

About

A production-grade, highly scalable microservices backend built with Spring Boot, featuring asynchronous event-driven communication and distributed caching.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages