SystemDesignDraw Logo
SystemDesignDraw

Architecture Whiteboard & Math

Fintech & E-CommerceAdvanced Difficulty9 min read

Design E-Commerce Order Checkout & Inventory Saga

A resilient order checkout engine that coordinates inventory reservations, payment gateways, and fulfillment across microservices. It guarantees zero double-charging and eliminates overselling during high-demand flash sales using the distributed Saga pattern.

Estimated Traffic12,000 Checkouts/sec • 85,000 Inventory Checks/sec
5-Year Data Footprint45 Terabytes (Order Ledger & Audit Logs)
Target Latency< 15 milliseconds
Availability Target99.99% (4 Nines)
Need custom numbers for your interview?Calculate QPS & capacity in System Design Cheat Sheet →

Live Architecture Studio

Edit components, modify labels, add databases, or redraw connections directly on this canvas:

Browse Component Stencils & Icons →

1. Problem & Challenge

During flash sales, thousands of shoppers compete for the same stock. Multi-database 2-Phase Commit (2PC) is too slow and fragile. If a payment fails after stock is locked, inventory must be released automatically without manual intervention.

2. Core Building Blocks & Responsibilities

👉 Swipe table horizontally to view roles and responsibilities
ComponentRolePlain-English Explanation
Checkout Web ClientOrder Portal & TimerSubmits checkout cart with UUID Idempotency-Key and displays 15-minute reservation timer.
Saga State MachineDistributed CoordinatorTracks transaction progress and triggers compensating rollback actions if payment or inventory fails.
Inventory ServiceHigh-Concurrency Stock LockerExecutes MySQL 8 SKIP LOCKED or Redis TTL locks to temporarily hold units for 15 minutes.
Stripe Payment GatewayFinancial Capture GatewayAuthorizes credit card, performs 3D Secure verification, and captures customer funds.
Webhook ProcessorAsynchronous State FinalizerIngests charge webhooks, validates signature headers, and transitions orders to PAID.
Fulfillment & Warehouse WorkerDispatch & Notification WorkerEmits warehouse picking tickets and sends customer tracking receipts.

3. Step-by-Step Request Flow

1

Customer Submits Checkout

Customer clicks Place Order with an Idempotency-Key, starting the 15-minute inventory reservation window.

2

Saga Workflow Instantiation

Saga orchestrator creates an order record in PENDING state and coordinates distributed microservice calls.

3

Inventory Soft Reservation

Inventory service locks units using row-level SKIP LOCKED; releases automatically if checkout expires.

4

Payment Gateway Authorization

Orchestrator submits payment request to Stripe with the idempotency key, preventing duplicate charges on retry.

5

Webhook Confirms Payment

Stripe webhook triggers order state transition to PAID, converting the soft reservation into a permanent purchase.

6

Warehouse Fulfillment Dispatch

Warehouse worker prints picking ticket, packs goods, and sends customer shipping tracking notifications.

4. Architectural Trade-offs

Decision:

Orchestrated Saga vs Choreographed Events

Chosen: Orchestrated Saga (Step Functions)

Rationale: Centralized state machine makes complex rollback logic, compensating refunds, and timeouts straightforward to audit.

Decision:

Immediate Inventory Deduction vs Soft Hold

Chosen: 15-Minute Soft Hold with Redis/MySQL

Rationale: Prevents abandoned carts from permanently depleting stock while preventing concurrent overselling.

Interview Tip

Always emphasize compensating transactions: If step 4 (payment) fails, the saga orchestrator immediately triggers ReleaseInventoryReservation to return items back to active catalog stock.

Distributed Architectures

Explore Related System Blueprints

View All Blueprints (19) →
Beginner Friendly6 min read

TinyURL Shortener

A URL shortener converts a long link (like a 100-character article URL) into a compact 7-character key (like tinyurl.com/xyz123) and redirects visitors in under 15 milliseconds.

Study Architecture →
Interview Favorite7 min read

API Rate Limiter

A rate limiter acts as a digital bouncer at the door of your API, ensuring each client stays within their allowed request limits (e.g. 100 requests per minute) and blocking abusive traffic.

Study Architecture →
Streaming & Media9 min read

Video Streaming CDN

Streaming high-definition video to millions of smart TVs and mobile phones requires breaking large 10GB video files into tiny 5-second chunks, encoding each into 20 different resolutions, and caching them right inside local ISP networks.

Study Architecture →
Real-Time & Geo10 min read

Uber Dispatch Engine

A real-time geospatial dispatch system matches riders with the most optimal nearby drivers using 64-bit H3 hexagonal indexing and 2-second batch optimization, minimizing city-wide pickup ETA and driver idle time.

Study Architecture →
Fintech & Ledger11 min read

Stripe Payments Ledger

A resilient financial payments architecture guarantees strict consistency (CP system) using cryptographic idempotency reservation, double-entry balanced postings, and sharded balance locks.

Study Architecture →
Real-Time & Collab9 min read

Figma Multiplayer Engine

A real-time multiplayer document engine uses stateful sticky session routing and server-authoritative operational ordering to sync 2D scene graphs across worldwide collaborators without locking.

Study Architecture →