Part VI β The Blueprint Β· Lesson 11.3
HLD β E-commerce App (Amazon, Flipkart)
In one lineDifferent pages need different rendering strategies β that decision is the whole design.
Where you've seen itA product page indexed by Google in seconds, and a cart that's wrong the moment it's served from a cache.
Diagram
1β2 Β· SCOPE AND SCALE
in scope home Β· category Β· search Β· product Β· cart Β· checkout
out seller portal Β· reviews moderation Β· logistics
scale 100M products Β· 10M DAU Β· huge SEO dependency
traffic spikes 20Γ on sale days3 Β· THE RENDERING SPLIT β the core answer
route strategy why
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
/ ISR (5.6) same for everyone, changes daily
/category/:id ISR + edge SEO critical, cacheable
/product/:id ISR + client SEO critical; price & stock
island for are fetched client-side so the
price/stock page itself stays cacheable
/search?q= SSR per-query, must be fresh
/cart CSR per-user, never cached
/checkout CSR per-user, no-store (6.7)
One app, five strategies. Saying "SSR everything" misses the point.4 Β· ARCHITECTURE
ββββββββββ βββββββββββ ββββββββββββββββββββ
β Client βββββββββΊβ CDN βββββββββΊβ BFF / edge SSR β
ββββββ¬ββββ βββββββββββ ββββββββββ¬ββββββββββ
β price/stock, cart, checkout β
βββββββββββββββββββββββββββββββββββββββββββ€
βΌ
catalog Β· pricing Β· inventory Β· cart Β· order6a Β· DEEP DIVE β CART CONSISTENCY
guest cart localStorage (6.2) β survives, no login needed
β user logs in
βΌ
MERGE with server cart β the interesting case
conflict rules: union of items Β· quantities max()
Β· re-validate every price and stock
βΌ
server cart = source of truth from here on
Optimistic add-to-cart with rollback (6.9), because a spinner on
"Add to cart" measurably costs conversions (5.2).6b Β· DEEP DIVE β PRICE AND STOCK FRESHNESS
problem the page is cached for SEO, but price must be current
solve render page shell + product copy from cache (fast LCP)
fetch /api/price-stock?ids=β¦ on mount (always fresh)
re-validate ONCE MORE at checkout (authoritative)
Never trust a cached price at payment time β always re-check
server-side before charging (3.5).How it works
- Split by route β SEO pages static or ISR at the edge, per-user pages client-rendered.
- Islands for dynamic bits so a cacheable page can still show live price and stock.
- Cart starts local for guests, merges on login, and becomes server-owned after that.
- Checkout is
no-store, network-only, with idempotency keys on the order request (1.5). - Search is SSR with cursor pagination and faceted filters kept in the URL (6.10).
Trade-offs
| Choice | Cost |
|---|---|
| ISR for product pages | Stale copy text until revalidation |
| Client-fetched price | An extra request; brief price skeleton |
| Guest cart in localStorage | Merge complexity at login |
| Optimistic add-to-cart | Rollback UI when stock runs out |
Interview angle
"Why not just SSR the whole site?"
- Product and category pages are identical for everyone β rendering them per request wastes capacity that matters on sale days.
- ISR at the edge gives the same SEO and a better LCP, with a client island keeping price and stock accurate.
- Cart and checkout are per-user and must never be cached, so those stay client-rendered with
no-store.
Recap
- The design is the per-route rendering decision.
- Cache the page, fetch the price β islands keep SEO and accuracy together.
- Guest cart merges on login; the server owns it afterwards.