# Flash Sale Platform

> A flash sale demo that uses one Redis Lua script to stop overselling when many people click Reserve at once.

- Kind: Open source
- Stack: TypeScript, Fastify, Redis, Lua, SQS, DynamoDB, Docker
- Repository: [https://github.com/jimzandueta/flash-sale-demo](https://github.com/jimzandueta/flash-sale-demo)

I built this demo to show how Redis can handle a flash sale, where everyone clicks at once. The shop has limited stock, and the sale opens at a set time.

A reservation is a single Lua script in Redis. It checks the customer and the stock and takes the item in one step, so two people can't get the last one. A unique request key makes sure each customer reserves only one item. The API answers straight away, and a worker saves the reservation from an SQS queue to DynamoDB. A hold that isn't checked out within three minutes expires, and a sweeper puts the item back on sale.

It runs with one `docker compose up`, and the repository has diagrams of the local setup and a production design on AWS.
