Practice/Amazon/Design Amazon Grocery Store
Design Amazon Grocery Store
System DesignOptional
Problem Statement
Design an automated grocery store system (like Amazon Go) where shoppers identify themselves on entry, pick items off shelves, and walk out without a traditional checkout. The system tracks items in real time using sensors and computer vision, maintains a live cart, and charges customers automatically at exit.
Interviewers ask this to test how you balance real-time state management, noisy sensor inputs, consistency, and money movement. You need to decompose the problem into edge events, stream processing, cart state management, inventory control, and a safe, idempotent payment workflow while handling failure modes like dropped events, offline store, and duplicate charges.
Key Requirements
Functional
- Real-time cart tracking -- users see an accurate, real-time cart as they add or remove items in the store
- Automatic checkout -- users are automatically charged upon exiting the store and receive a receipt tied to their session
- Inventory management -- managers add and update inventory and pricing, and see low-stock alerts
- Dispute resolution -- managers review sessions, resolve disputes, and issue refunds for incorrect charges
Non-Functional
- Scalability -- support hundreds of concurrent shoppers per store with thousands of sensor events per second
- Reliability -- maintain store operation during cloud connectivity interruptions through local edge computing and buffering
- Latency -- cart updates reflected within 1-2 seconds of item pickup, exit checkout completed within 5 seconds
- Consistency -- strong consistency for payment capture and inventory counts; eventual consistency acceptable for real-time cart display
What Interviewers Focus On
Based on real interview experiences, these are the areas interviewers probe most deeply:
1. Sensor Event Processing and Cart State
Converting noisy, high-frequency sensor signals into accurate cart state is the core technical challenge.
Hints to consider:
- Use an event-driven architecture where shelf sensors and cameras publish pickup/putback events to a local message queue
- Maintain per-shopper cart state as an event-sourced aggregate, applying sensor events and reconciling conflicts
- Handle sensor noise and false positives by requiring corroboration from multiple signal types before updating cart state
- Design a confidence scoring system that flags uncertain items for post-session review rather than charging incorrectly
2. Exit Payment Workflow
The checkout flow must atomically finalize the cart, calculate totals, capture payment, and issue a receipt without double-charging or missing charges.
Hints to consider:
- Model exit checkout as a saga: freeze cart state at exit detection, compute totals with applicable taxes and promotions, authorize and capture payment with idempotency keys, then generate receipt
- Use payment holds pre-authorized at entry to reduce checkout latency at exit
- Implement compensating actions for each step: if payment fails after cart freeze, queue for retry rather than blocking the shopper
- Handle edge cases like shoppers who enter but make no purchases, return all items, or have expired payment methods
3. Edge Computing and Offline Resilience
Physical retail requires the system to function even when cloud connectivity is interrupted.
Hints to consider:
- Deploy local edge servers in each store that can process sensor events, maintain cart state, and complete checkout independently
- Buffer events locally during connectivity loss and synchronize with the cloud when connection is restored
- Design idempotent sync protocols so duplicate events from buffered replay do not corrupt cart or inventory state
- Implement local failover for payment processing with store-and-forward for settlement
4. Inventory Tracking and Hot SKU Contention
Popular items and shared shelf spaces create hot keys and concurrent updates that must be handled without losing accuracy.
Hints to consider:
- Track inventory at the individual item level (not just SKU counts) using RFID or weight-based sensor data
- Use conditional writes and atomic operations to prevent concurrent shoppers from corrupting inventory counts
- Design real-time low-stock alerts using streaming aggregation with configurable thresholds per product
- Implement batch inventory reconciliation using overnight shelf scans to correct any drift from sensor inaccuracies
Suggested Approach
Step 1: Clarify Requirements
Confirm scope with the interviewer. Ask about store size and shopper capacity, types of sensors available (cameras, shelf weight sensors, RFID), whether the system should handle fresh/weighted items or only packaged goods, and payment method constraints. Clarify whether multi-store operation is in scope and if inventory is shared across stores. Establish offline operation requirements: how long must the store function without cloud connectivity?