Build a Shipping Cost Calculator With Pluggable Pricing Rules

Last updated: November 29, 2026

Quick Overview

Design a shipping cost calculator where the base rate depends on weight and zone, and adjustments such as Prime free shipping, oversize surcharges, and promotional discounts can be added, removed or reordered by configuration without changing the calculator.

Amazon
Software Engineering Fundamentals
Software Engineer
Amazon
November 29, 2026
Software Engineer
Technical Screen
Software Engineering Fundamentals
Medium

0

0

0 solved


Design a shipping cost calculator where the base rate depends on weight and zone, and adjustments such as Prime free shipping, oversize surcharges, and promotional discounts can be added, removed or reordered by configuration without changing the calculator.

A design-for-extension question in the style of Amazon SDE technical screens. The interviewer checks use of the strategy or chain-of-responsibility pattern, a clear rule ordering contract, money in integer cents, and an explanation trail for customer support.

What the Interviewer Expects
  • Separate base rate strategy from adjustment rules
  • Define a rule interface and an explicit ordering
  • Use integer cents and never go below zero
  • Produce a breakdown explaining each adjustment
  • Make rules unit-testable in isolation
Key Topics to Cover
Strategy Pattern
Chain of Responsibility
OOP
Extensibility
Money Handling
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
  • How would you load rule configuration at runtime safely?
  • How would you A/B test a new surcharge?
  • How do you prevent two discounts from stacking when they should not?
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

Shipment has weight in grams, destination zone (1 to 8), dimensions, and customer flags (is_prime). Rules apply in configured order, each seeing the running total. Output total cents and a list of (ru...

High-Level Design
  • BaseRate strategy: price(shipment) -> cents from a weight-tier and zone table.
  • Rule interface: apply(shipment, running_cents) -> delta_cents (0 means not applicable).
  • Concrete rules: `Ov...

Submit Your Answer
Markdown supported