YourPlatform

Amazon System Design

Deep learning is a subset of machine learning...


Functional Requirement

  • seller can add items
  • buyer can search items
  • view item details
  • add item to cart
  • checkout/place order (inventory management, payment etc)
  • view orders

low priority

  • add item to wishlist
  • recommend items to user home page
  • notify users about order status

Non Functional Requirements

  • low latency (for search)
  • high availability (for search)
  • high consistency (for order placement)
  • eventual consistency for item onboarding, search etc

Entities

  • item
  • buyer
  • seller
  • cart
  • order

API

POST /items

{

name, description, price, quantity, ..

}

search items

GET /items?term={}&cursor={}&size={}

add item to cart

PATCH /cart

{

itemId, quantity

}

checkout

POST /checkout

{

cartId, amount, paymentInfo{ paymentType, cardNo, ...

} }

Scale

Daily Active Users 50M – 200M+ users (globally for Amazon) Requests per Second (RPS) 100K – 500K+ during peak (e.g., sale events) Product Catalog 100M+ SKUs across categories Order Volume/day 5M – 15M+ orders (spikes during sales like Big Billion Day) Concurrent Sessions 1M+ active sessions during major events Data Stored Petabytes of item, order, and user behavior data

High Level Design

image

{
  {
  "_id": ObjectId("..."),
  "sku": "TSHIRT-001",
  "name": "Basic Cotton T-Shirt",
  "brand": "ComfortWear",
  "category": "apparel",
  "type": "variant",
  "description": "Soft 100% cotton T-shirt available in multiple colors and sizes.",
  "tags": ["t-shirt", "casual", "cotton", "unisex"],
  "attributes": {
    "material": "cotton",
    "gender": "unisex",
    "fit": "regular"
  },
  "variants": [
    {
      "variant_id": "TSHIRT-001-RD-M",
      "color": "red",
      "size": "M",
      "stock": 20,
      "price": 15.99,
      "images": [
        "https://cdn.site.com/products/tshirt-red-front.jpg",
        "https://cdn.site.com/products/tshirt-red-back.jpg"
      ]
    },
   ...
   ...
  "created_at": "2025-06-15T10:00:00Z",
  "updated_at": "2025-06-15T10:00:00Z"
}
}


{
  "_id": ObjectId("..."),
  "sku": "TV-4K-001",
  "name": "42-inch 4K Smart TV",
  "brand": "ViewLux",
  "category": "electronics",
  "type": "simple",
  "description": "Smart 4K UHD TV with HDR, built-in WiFi, and voice assistant support.",
  "tags": ["tv", "4k", "smart", "electronics"],
  "specifications": {
    "screen_size": "42 inches",
    "resolution": "3840 x 2160",
    "panel_type": "LED",
    "smart_tv": true,
    "hdmi_ports": 3,
    "usb_ports": 2,
    "os": "Android TV"
  },
  "price": 349.99,
  "stock": 8,
  "images": [
    "https://cdn.site.com/products/tv-front.jpg",
    "https://cdn.site.com/products/tv-back.jpg"
  ],
  "status": "active",
  "created_at": "2025-06-15T10:00:00Z",
  "updated_at": "2025-06-15T10:00:00Z"
}

Why ElasticSearch DB for search?

  • Inverted index data structure makes text search extremely fast.
  • A typical database would need LIKE '%term%', which is slow. Elasticsearch does it in milliseconds
  • Supports fuzzy matching, partial words, typo tolerance, stemming, synonyms, etc
  • New data becomes searchable in < 1 second after being indexed

Item Onboarding Flow

image

Deep Dive - Item Onboarding Flow

image

Deep Dive - Order Flow

image

Example Saga:

User places order

CheckoutService creates order → emits OrderCreated

InventoryService listens → reserves stock → emits InventoryReserved

PaymentService listens → charges payment → emits PaymentCompleted

Logistic listens → prepares shipment → emits ShipmentReady

Checkout finalizes → marks OrderCompleted

If any step fails, compensating transactions are triggered:

InventoryService un-reserves stock

PaymentService refunds

CheckoutService cancels order

This achieves eventual consistency, not strict atomicity.

That was a free preview lesson.