System Design: Product Catalog Service
You are designing a product catalog service for an e‑commerce site. Assume a read‑heavy workload, a relational primary store, and JSON over HTTP APIs.
Requirements:
-
Data model
-
Hierarchical categories using a self‑referential Category table (parent → child). Show the self‑join for categories.
-
Products can belong to multiple categories.
-
Model product variants (e.g., size/color) and arbitrary attributes.
-
Specify a relational schema: tables, key fields, and indexes.
-
APIs
-
Create/update products and categories.
-
Browse products by category with pagination and filtering.
-
Search/filter by attributes.
-
Fetch product detail.
-
Provide example endpoints with example request/response payloads. Include pagination and filtering syntax.
-
Architecture/operations
-
Discuss consistency choices (DB vs. cache vs. search index), caching, read/write patterns.
-
How to scale to 10M products and ~1k QPS reads.
Assumptions (you may refine): JSON APIs, REST style; prices/inventory may be separate services; 10M products, typical product has a few variants; peak read 1k QPS, writes much lower.