Skip to content

Latest commit

 

History

88 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 

Repository files navigation

FlashGuard

A high performance distributed inventory locking system designed to prevent race conditions in high-traffic e-commerce environments.

Tech stack

Spring Boot 3, AWS(S3), Redis, Next js 15, PostgresSQL(supabase), hosting - render, vercel

Technical Problem

  • The Problem: Traditional database locking (PostgreSQL) causes deadlocks and high latency when 10,000+ users try to buy a limited-stock item simultaneously.

  • The Solution: Implemented Redis Lua scripts to handle inventory validation atomically in-memory before persisting data to the database.

Architecture Diagram

System Architecture

Key features & Performance Metrics

  • High concurrency - optimized to handle 10k+ requests per second. (RPS)
  • Deadlock Reduction - Decoupled validation from persistence, slashing DB contention by 80%.
  • Atomic Locking - Used Redis Lua scripts to ensure "Exactly-once" processing for inventory updates.
  • CI/CD & Security - Automated testing with GitHub Actions and security scanning with CodeQL.

Live Demo

RoadMap

[x] core redis locking logic.
[x] spring boot API integration.
[x] AWS S3 image hosting.
[x] Advanced analytics dashboard.

API Testing & Documentation

The API is fully documented and tested using Posstman.

  • Postman Collection: You can find the raw JSON collection here
  • How to test:
    1. Import the collection into postman.
    2. Set the base_url .
    3. Run the "Stress Test" folder ot simulate inventory lockinng.

Sample API Response (Locking Success)

{
    "oversold": 0,
    "successfulLocks": 8,
    "avgLatency": 54.0939,
    "productId": 6,
    "totalRequests": 10000
}

CI/CD & Security

  • Frontend CI
  • Backend CI
  • Security Scan

Testing

  • Unit tests: JUnit & Mockito for service logic.
  • Stress testing: simulated 10k concurrent users to validate redis performance.

About

A high-concurrency reservation engine using Spring Boot, Redis Lua scripting, and AWS Lambda to prevent race conditions and overselling during traffic bursts.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages