Preparing your design workspace

Loading the problem and your latest saved attempt…

Design a Mobile and Server Shopping Cart

Keep a user cart useful offline while reconciling server prices, inventory, multi-device edits, and idempotent checkout.

Problem statement

For this exercise, assume the following practice scope. Design a shopping cart across mobile clients and a server. A signed-in user adds, removes, and changes quantities, may edit while briefly offline, sees cached product data and a clearly labeled estimated total, and later synchronizes from several devices.

Each client mutation has a stable operation ID and base cart version. The server is authoritative for cart state and deterministically accepts, rejects, or rebases mutations; deleted lines cannot be resurrected by stale retries.

Price, promotion eligibility, and inventory are estimates until an idempotent checkout creates an immutable order snapshot or returns explicit changed-price, unavailable-item, or conflict results. Guest carts may merge once into an account cart with a durable receipt.

Design the mobile data model and queue, server cart model and APIs, synchronization and conflict policy, product cache, guest merge, checkout, observability, and recovery. Payment execution, fulfillment, recommendation, and catalog authoring are outside scope.

What to build

  1. Edit and render a cart on mobile with bounded offline support and freshness labels.
  2. Synchronize idempotent operations from multiple devices without resurrecting deleted lines.
  3. Merge a guest cart into an account cart exactly once logically.
  4. Reprice and check inventory at checkout and return explicit conflicts or adjustments.
  5. Create one immutable order snapshot from one successful checkout operation.

At scale

  • Assume 10 million daily users, 2 million active carts, and 100,000 cart mutations per second at peak.
  • Online mutations should complete within 300 ms p95 and synchronization within five seconds p95 after reconnect.
  • Offline edits are supported for 24 hours; carts expire after 30 days of inactivity; order snapshots are retained for seven years.
  • A retry, reconnect, or concurrent device edit cannot duplicate quantity changes or create two orders.