Low-Level Design of a Stackable Coupon and Bank Offer Engine

Last updated: November 29, 2026

Quick Overview

Design the classes for a checkout offer engine that supports flat coupons, category percentage coupons with caps, and bank card offers, enforces that at most one coupon and one bank offer stack, and picks the combination that saves the customer the most.

Flipkart
Software Engineering Fundamentals
Software Engineer
Flipkart
November 29, 2026
Software Engineer
Onsite
Software Engineering Fundamentals
Medium

0

0

0 solved


Design the classes for a checkout offer engine that supports flat coupons, category percentage coupons with caps, and bank card offers, enforces that at most one coupon and one bank offer stack, and picks the combination that saves the customer the most.

Flipkart's machine-coding round asks for a working, extensible design in about 90 minutes, and offers at checkout (flat coupons, category deals, HDFC or Axis card discounts) are a natural fit. Interviewers look for clean abstractions, rules kept in one place, money in integer paise, and whether adding a new offer type touches only one new class.

What the Interviewer Expects
  • Define an Offer abstraction with eligibility and discount computation separated
  • Represent money in integer paise to avoid float rounding
  • Encode stacking rules and application order explicitly
  • Search combinations to find the best saving
  • Show that a new offer type is a new subclass, not an edit to the engine
Key Topics to Cover
object-oriented design
strategy pattern
open-closed principle
money handling
combinatorial selection
How to Approach This
  1. Apply SOLID principles. Single Responsibility makes code testable, Open/Closed makes it extensible.
  2. Choose data structures based on access patterns, not familiarity.
  3. Prefer immutable data and message passing over shared mutable state for concurrency.
  4. Design APIs with RESTful conventions, versioning, meaningful errors, and pagination from day one.
Possible Follow-up Questions
  • Offers grow to 40 per group. How do you avoid trying every combination?
  • How would you add a per-user usage limit for a coupon without breaking the engine's purity?
  • Bank offers should apply on the amount after coupons but before shipping. Where does that rule live?
  • How do you explain to the customer why a coupon was not applied?
Sharpen Your Skills on Codemia

Practice similar problems with our interactive workspace, get AI feedback, and track your progress.

Practice System Design Problems
Sample Answer
Requirements
  • Offer types: flat amount off above a minimum, percentage off a category with a cap, percentage off for a specific bank with a cap.
  • Stacking: at most one offer from the coupon group and one from th...
High-Level Design

Offer is an abstract base holding code, min_amount and group. Subclasses override compute (raw discount) and optionally eligible. The base discount applies the shared guardrails (eligibi...


Submit Your Answer
Markdown supported

Related Questions