InterviewDB Question

Book Store System Design: Search, Inventory, Cart, and Checkout at Scale

Question Details

Round 1 System Design

Problem

Design an online bookstore serving 1 million daily active users. The system must support:

-

Catalog search: full-text search by title, author, ISBN, genre. Results ranked by relevance and rating.

Inventory management: each book has a stock count. Prevent overselling.

Cart and checkout: users can add books, apply promo codes, and complete purchase.

Order history: users can view past orders and download receipts.

Walk through your high-level architecture, key data models, and the trickiest consistency problem in this system.

Key entities:
  Book(id, title, author, isbn, price, stock_count)
  User(id, email, address)
  Cart(user_id, items: [{book_id, qty}])
  Order(id, user_id, items, total, status, created_at)

Follow-ups

  1. Two users add the last copy of a book to their carts simultaneously. How do you handle checkout to prevent overselling? Walk through your locking or reservation strategy.
  2. Search must return results in under 100ms. Where does Elasticsearch fit, and how do you keep it in sync with your primary DB?
  3. How would you implement "frequently bought together" recommendations without a full ML pipeline?
  4. Design the promo code system: each code can be single-use, limited-count, or percentage-based. Where is validation enforced?

Full Details

Round 1 System Design

Problem

Design an online bookstore serving 1 million daily active users. The system must support:

-

Catalog search: full-text search by title, author, ISBN, genre. Results ranked by relevance and rating.

Inventory management: each book has a stock count. Prevent overselling.

Cart and checkout: users can add books, apply promo codes, and complete purchase.

Order history: users can view past orders and download receipts.

Walk through your high-level architecture, key data models, and the trickiest consistency problem in this system.

Key entities:
  Book(id, title, author, isbn, price, stock_count)
  User(id, email, address)
  Cart(user_id, items: [{book_id, qty}])
  Order(id, user_id, items, total, status, created_at)

Follow-ups

  1. Two users add the last copy of a book to their carts simultaneously. How do you handle checkout to prevent overselling? Walk through your locking or reservation strategy.
  2. Search must return results in under 100ms. Where does Elasticsearch fit, and how do you keep it in sync with your primary DB?
  3. How would you implement "frequently bought together" recommendations without a full ML pipeline?
  4. Design the promo code system: each code can be single-use, limited-count, or percentage-based. Where is validation enforced?
Free preview. Unlock all questions →

Topics

Onsite Phone System Design