Skip to content

0x76hack/Flash-sale-engine

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Flash Sale Engine

A high-concurrency flash sale backend built using Java, Spring Boot, PostgreSQL, and Redis.


Tech Stack

  • Java 21
  • Spring Boot
  • PostgreSQL
  • Redis
  • Docker
  • Maven
  • JPA / Hibernate

Features

  • 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

Architecture

Client
   ↓
Spring Boot API
   ↓
Redis
   ├── Inventory
   ├── Rate Limiting
   ├── Idempotency
   └── Purchase Locks
   ↓
PostgreSQL
   ├── Users
   ├── Products
   └── Orders

Project Structure

src/main/java/com/flashsale
│
├── config
├── controller
├── dto
├── entity
├── exception
├── repository
└── service

Prerequisites

  • Java 21
  • Docker Desktop
  • Maven
  • PostgreSQL
  • Redis

Running the Project

Start Infrastructure

docker compose up -d

Run Application

mvn spring-boot:run

Application runs on:

http://localhost:8080

API Endpoints

Users

Create User

POST /users

Example:

{
  "name": "Alice",
  "email": "alice@test.com"
}

Products

Create Product

POST /products

Example:

{
  "name": "PS5",
  "description": "Gaming Console",
  "price": 499.99,
  "inventory": 5
}

Purchase

Purchase Product

POST /purchase

Example:

{
  "userId": "USER_ID",
  "productId": "PRODUCT_ID",
  "idempotencyKey": "purchase-123"
}

About

A production-oriented flash sale backend system

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages