Loyalty points for a coffee chain
Your task
Design the loyalty program for a coffee chain with 150 stores and 800,000 members. Members earn 10 points per dollar spent when the cashier scans their app at the register, and redeem 1,500 points for a free drink. Registers send each purchase to the backend and retry when the network drops, so the same purchase can arrive more than once. A member can open the app on two phones and try to redeem on both at once. Points expire 12 months after they are earned. About 120,000 purchases a day earn points. Describe how points are recorded, how a balance is computed, and how you prevent double earning and double spending.
It covers
- Append only ledger
- Idempotency
- Points expiry