E-Commerce Checkout Architecture
E-commerce checkout is the canonical capstone — pricing, inventory, payment, fulfilment, notification, audit.
Introduction
E-commerce checkout is the canonical capstone — pricing, inventory, payment, fulfilment, notification, audit. This lesson walks full architecture naming every pattern at every seam with trade-offs experience teaches.
The story
Marketplace checkout lived in one 4,000-line service. Black Friday: payment retries cascaded into inventory locks into notification floods. Rebuild over two quarters used 8 named patterns; next Black Friday peaked 5× load with zero incidents.
The business problem
Checkout failures are direct revenue loss amplified at scale:
- Cascade: payment retry → inventory hold → notification flood.
- Peak load: Black Friday exposes every weak seam.
- PCI/GDPR: payment isolation and audit trails required.
- Multi-provider: Stripe + regional adapters + fallbacks.
The problem teams faced
Checkout architecture forces:
- Distributed workflow across inventory, payment, shipping.
- Partial failure compensation — can't leave money charged without order.
- Reliable domain events for notifications and analytics.
- Resilience on external payment APIs.
Understanding the topic
Intent: Compose patterns into production checkout.
- Strategy — pricing, shipping cost, promotions.
- Saga — place order across services with compensation.
- Circuit Breaker — payment provider resilience.
- Outbox — OrderPlaced events reliably.
- Adapter — normalize payment provider SDKs.
Internal architecture
Checkout service architecture:
API Gateway → Checkout BFF│├─ PricingService (Strategy: standard, promo, member)├─ InventoryService (Repository + optimistic lock)├─ PaymentService (Adapter: Stripe, Adyen) + CircuitBreaker│└─ SagaOrchestrator.placeOrder()1. reserve inventory → compensate: release2. charge payment → compensate: refund3. confirm order → Outbox: OrderPlaced → notify/analytics
Visual explanation
Three diagrams cover checkout flow, saga compensation, Black Friday resilience:
Informative example
Saga orchestrator — TypeScript sketch:
class PlaceOrderSaga {async execute(order: Order) {const reservation = await this.inventory.reserve(order.items)try {const charge = await this.payment.charge(order.total) // breaker insideawait this.orders.confirm(order.id)await this.outbox.publish(new OrderPlaced(order.id))return charge} catch (e) {await this.inventory.release(reservation.id) // compensatethrow e}}}
Execution workflow
Map monolith seams
Pricing, payment, inventory boundaries.
Real-world use
Amazon checkout evolution; Shopify checkout extensibility; Stripe payment orchestration; marketplace saga patterns at Etsy/eBay scale.
Production case study
Black Friday rebuild:
- Before: 4,000-line service; cascade failures.
- Rebuild: 8 patterns over 2 quarters.
- Outcome: 5× peak load, zero incidents next Black Friday.
Trade-offs
- Pro: isolated failure domains; testable seams; scale teams.
- Con: saga operational complexity; eventual consistency UX.
Decision framework
- Multi-step distributed checkout → Saga + Outbox mandatory.
- Multiple payment providers → Adapter + Strategy + Breaker.
- Monolith under 10k orders/day → don't prematurely distribute.
Best practices
- Idempotent saga steps — retry-safe reserve/charge.
- Outbox for every domain event leaving checkout.
- Characterize monolith behavior before extracting saga steps.
Anti-patterns to avoid
- 2PC across microservices for checkout.
- Synchronous notification calls in checkout path.
- Single payment provider with no breaker or fallback.
Common mistakes
- Compensation failures — design idempotent release/refund.
- Inventory oversell under race — optimistic lock or reservation TTL.
Debugging tips
- Saga trace ID through all steps — find stuck compensation.
Optimization strategies
- Cache pricing rules; async analytics via Outbox consumers.
Common misconceptions
- Checkout ≠ one microservice — workflow spans services with saga.
- Saga ≠ no consistency — eventual with compensations.
Advanced interview questions
Interview Prep
Practice concise answers, then expand each card for the explanation.
1AdvancedQuestionDesign checkout — key patterns?+
Answer
Follow-up
2AdvancedQuestionWhy not 2PC for checkout?+
Answer
Follow-up
3AdvancedQuestionBlack Friday prep?+
Answer
Follow-up
Summary
You can architect checkout with named patterns at every seam. Tell the Black Friday 5× story — you own E-Commerce Architecture.