Design a Coupon and Promo Code Service - System Design
“Design a coupon service” sounds like a CRUD table with a discount_percent column until you write down what actually breaks it. Marketing wants to print 10 million unique codes for a Diwali campaign, mail them out, and have each one usable exactly once. The rules are not simple: this code is 20% off, that one is flat 500 off orders over 2000, this batch is one-per-customer across the customer’s lifetime, that batch stacks with free shipping but not with other percentage coupons. And the whole thing has to answer POST /checkout in a few milliseconds during a flash sale when 200,000 people hit “apply code” in the same minute, because the coupon check sits directly on the critical path to revenue. ...