You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
A production-grade, high-throughput Flash Sale REST API built with ASP.NET Core 8, Redis, and PostgreSQL. Designed to handle 100000+ concurrent users without overselling a single unit.
{
"orderId": "a1b2c3d4-...",
"message": "Your order has been received and is being processed. Poll the status URL to confirm.",
"idempotencyKey": "550e8400-...",
"statusPollUrl": "/api/orders/status/a1b2c3d4-..."
}
🚀 Running the Project
Docker (Recommended — zero config)
git clone https://github.com/soadmahmud/Flash-Sale-API.git
cd Flash-Sale-API
docker-compose up --build
# Swagger UI: http://localhost:5000
Local (requires PostgreSQL + Redis)
export PATH="$PATH:/home/soadm/.dotnet:/home/soadm/.dotnet/tools"cd src/FlashSaleApi
# First run only: apply migrations
DOTNET_ROOT=/home/soadm/.dotnet dotnet-ef database update
# Start
dotnet run
# Swagger: http://localhost:5000
DB write happens asynchronously in the background worker.
🧪 Sample cURL Commands
# 1. Get active flash sale products (with per-user limits)
curl http://localhost:5000/api/flashsale/active
# 2. Add to cart
curl -X POST http://localhost:5000/api/cart \
-H "Content-Type: application/json" \
-H "X-User-Id: user42" \
-d '{"productId": 1, "quantity": 2}'# 3. Place order (multi-item)
curl -X POST http://localhost:5000/api/orders \
-H "Content-Type: application/json" \
-H "X-User-Id: user42" \
-d '{ "idempotencyKey": "my-unique-key-001", "items": [ {"productId": 1, "quantity": 1}, {"productId": 3, "quantity": 2} ] }'# 4. Poll order status (use orderId from step 3 response)
curl http://localhost:5000/api/orders/status/{orderId}
# 5. Order history
curl http://localhost:5000/api/orders/user42
🐳 docker-compose Services
Service
Image
Port
api
Built from Dockerfile
5000
db
postgres:16-alpine
5432
redis
redis:7-alpine
6379
📋 Rate Limiting
Policy: Fixed Window — 10 requests per 10 seconds per IP address
Applied to:POST /api/orders only
Response on exceed:429 Too Many Requests
Per-user purchase quotas (bot protection) are separate from rate limiting and are enforced at the business logic level.
About
A production grade Flash Sale REST API. Built with ASP.NET Core 8, designed to handle 100,000+ concurrent users without overselling a single product unit.