Problem statement
Design the object model and core APIs for a coupon engine that validates promo codes and computes the discount they grant against a shopping cart at checkout, for a single online store.
Operating context. One store, one currency. A shopper enters one or more codes at checkout. Each code carries an effect (percentage off, fixed amount off, free shipping, or buy-X-get-Y), a set of eligibility rules (active window, minimum subtotal, eligible categories, first-order-only), and redemption limits (a global cap and a per-customer cap). The engine reads a read-only snapshot of the cart, decides which codes are valid, resolves conflicts between them, and returns the resulting price adjustments. Each successful redemption is recorded so limits hold, and checkout may be attempted concurrently from several sessions.
Out of scope. Catalog and inventory management, tax and currency conversion, the payment-capture step, fraud scoring, and the admin UI for authoring campaigns (assume codes already exist in memory).
What to produce. The class hierarchy (Coupon, the discount-effect types, the eligibility-rule types, the redemption ledger, and the engine facade), the public API each exposes, and the evaluation flow from a raw code to an applied adjustment. Be explicit about: how a new discount shape is added without touching the redemption path, how several presented codes stack or exclude one another, and how a code with one remaining use cannot be redeemed twice under concurrent checkouts.
Requirements
This assessment is a Premium feature.
The statement above is free to read. The functional and non-functional requirements, and the graded canvas that scores your design against them, come with Premium.
Topics
- System Design LLD
- Commerce Promotions
- Patterns Chain
- Patterns Strategy
- Oop Solid