Model Shop and Platform Coupons in an Ichiba Cart
Last updated: November 29, 2026
Quick Overview
Design classes for shop-specific and platform-wide coupons (fixed amount or percentage with a cap and minimum spend) and a cart method that applies the best allowed combination: at most one coupon per shop plus one platform coupon.
Rakuten
November 29, 20260
0
0 solved
Design classes for shop-specific and platform-wide coupons (fixed amount or percentage with a cap and minimum spend) and a cart method that applies the best allowed combination: at most one coupon per shop plus one platform coupon.
Ichiba carts often hold items from several shops, and both shops and Rakuten itself issue coupons with different rules. This low-level design question checks clean abstractions, the open-closed principle and careful handling of caps and minimums.
What the Interviewer Expects
- Define an abstract Coupon with eligibility and discount methods
- Keep shared rules (minimum spend, shop scope, never exceed subtotal) in the base class
- Add new coupon types without changing the engine
- Choose the best coupon per shop independently
- Use integer yen to avoid rounding errors
Key Topics to Cover
How to Approach This
- Apply SOLID principles. Single Responsibility makes code testable, Open/Closed makes it extensible.
- Choose data structures based on access patterns, not familiarity.
- Prefer immutable data and message passing over shared mutable state for concurrency.
- Design APIs with RESTful conventions, versioning, meaningful errors, and pagination from day one.
Possible Follow-up Questions
- Add a 'buy 2, get 10 percent off' coupon. Which classes change?
- Should the platform coupon's percentage apply before or after shop coupons? How would you make that configurable?
- Coupons have usage limits per user. Where does that check belong?
Sharpen Your Skills on Codemia
Practice similar problems with our interactive workspace, get AI feedback, and track your progress.
Practice System Design ProblemsSample Answer
Requirements
A cart has line items with shop id, price and quantity. Coupons are fixed amount or percentage (with optional cap), have a minimum spend, and are scoped to a shop or to the whole platform. The engine ...
High-Level Design
Coupon is an abstract base holding code, min spend and optional shop id. It implements eligible and discount (clamping to the relevant subtotal) and delegates the raw amount to _raw_discount, ...