A high-concurrency flash sale backend built using Java, Spring Boot, PostgreSQL, and Redis.
- Java 21
- Spring Boot
- PostgreSQL
- Redis
- Docker
- Maven
- JPA / Hibernate
- User registration and management
- Product creation and inventory management
- Redis-based inventory caching
- Atomic inventory decrement
- Overselling prevention
- Duplicate purchase prevention
- Idempotent purchase requests
- Distributed rate limiting
- Global exception handling
Client
↓
Spring Boot API
↓
Redis
├── Inventory
├── Rate Limiting
├── Idempotency
└── Purchase Locks
↓
PostgreSQL
├── Users
├── Products
└── Orders
src/main/java/com/flashsale
│
├── config
├── controller
├── dto
├── entity
├── exception
├── repository
└── service
- Java 21
- Docker Desktop
- Maven
- PostgreSQL
- Redis
docker compose up -dmvn spring-boot:runApplication runs on:
http://localhost:8080
POST /usersExample:
{
"name": "Alice",
"email": "alice@test.com"
}POST /productsExample:
{
"name": "PS5",
"description": "Gaming Console",
"price": 499.99,
"inventory": 5
}POST /purchaseExample:
{
"userId": "USER_ID",
"productId": "PRODUCT_ID",
"idempotencyKey": "purchase-123"
}