Coupon redemption service
Your task
Design a coupon/voucher service for an online store. Each coupon has a code, a discount, an expiry date, and a max number of redemptions (sometimes one per customer, sometimes a global cap of, say, 1,000 uses). At checkout the store calls the service to validate and redeem a code. Cover the data model, how validation and redemption work, and how you prevent a limited coupon from being over-redeemed during a sale rush.
It covers
- Idempotency
- Atomic counters