System Design: Online Bookstore (Browse + Purchase)
Context
Design an online bookstore that allows customers to browse/search books, view product details, add to cart, and purchase. Assume web and mobile clients, users can be guests or logged-in, and third-party payment processing is used. Optimize for high read traffic on catalog/search and correctness during checkout.
Requirements
Functional Requirements
-
Catalog and discovery
-
Browse categories, filter, sort (by price, rating, relevance).
-
Full-text search with facets (author, genre, format, price range, language).
-
Product detail page: title, authors, description, ISBN, formats (hardcover/ebook), price, availability, images, ratings.
-
Cart and checkout
-
Cart operations: create, add/update/remove items, view cart, merge guest cart on login.
-
Checkout: shipping options, taxes, discounts/coupons, payment, order confirmation.
-
Order history for users; guest order lookup by email+order ID.
-
Inventory and pricing
-
Real-time inventory/availability per SKU (format/edition/warehouse).
-
Promotions/discounts; price snapshots at order time.
-
Payments
-
Integrate with a PSP; support cards and wallets; handle 3DS/SCA when applicable.
-
Notifications
-
Email confirmations for order placement, payment, and shipment.
Non-Functional Requirements
-
Scale read-heavy catalog/search; low-latency PDP and cart.
-
Strong consistency for inventory reservation and order state transitions.
-
High availability (multi-AZ; consider multi-region DR).
-
Security and privacy (PII, PCI scope minimization).
-
Observability with actionable SLOs.
-
Idempotent APIs for checkout/payment/order creation.
Deliverables
-
APIs: search/browse, product detail, cart, checkout, payments, order history.
-
Data model: books, authors, inventory, pricing, users, carts, orders.
-
Service decomposition and storage choices (SQL/NoSQL), search indexing, caching/CDN, read/write patterns.
-
Address inventory reservation and consistency, idempotency, security/privacy, observability, capacity planning, scalability/availability/fault tolerance.