Design a Cart Pricing Engine With Pluggable Restaurant Offers

Last updated: November 29, 2026

Quick Overview

Design classes that compute a food cart's final price from a set of offers (percentage with cap, new-user flat discount, buy one get one) where some offers stack and others are mutually exclusive.

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

0

0

0 solved


Design classes that compute a food cart's final price from a set of offers (percentage with cap, new-user flat discount, buy one get one) where some offers stack and others are mutually exclusive.

Zomato checkout combines platform coupons, restaurant-funded deals and item offers, and pricing bugs directly cost money or trust. This machine coding style round checks object-oriented design, extensibility and careful money handling.

What the Interviewer Expects
  • Define a common Offer interface so new offer types need no engine changes
  • Store money as integers in paise, never floats
  • Separate stackable item offers from exclusive coupons
  • Pick the best exclusive offer and explain the rule
  • Return a breakdown, not just a total, for the bill screen
  • Write tests for boundary conditions like minimum order value
Key Topics to Cover
Strategy pattern
Extensibility
Money arithmetic
Business rules modeling
Unit testing
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
  • Should a percentage coupon apply to the subtotal before or after the BOGO discount, and who decides?
  • How would you support offers funded partly by the restaurant and partly by Zomato?
  • How do you guarantee the price shown in cart equals the price charged at payment?
  • How would you add a per-user usage limit for a coupon?
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

A cart has items (price in paise, quantity) and a user flag. Offers: percent off with a cap and minimum order, a flat new-user discount, and BOGO on one SKU. BOGO stacks with anything; coupons are exc...

High-Level Design

Offer is an abstract class with discount(cart) -> int and a stackable flag (Strategy pattern). The PricingEngine holds a list of offers and does no type checks, so adding a 'free delivery abov...


Submit Your Answer
Markdown supported

Related Questions