Design a hierarchical catalog service
Company: Instacart
Role: Software Engineer
Category: System Design
Difficulty: hard
Interview Round: Onsite
Design a product catalog service that supports hierarchical categories implemented with a self-referencing table. Requirements:
(
1) Define the core read/write APIs (e.g., createCategory, moveCategory, listChildren, getBreadcrumbs, createProduct, updateAttributes, attachProductToCategory, search/filter/paginate products within a category).
(
2) Propose the relational schema, including a Categories table with a self-join (id, parent_id, name, path/slug, sort_order), a Products table (id, sku, name, attributes JSON, status), and a ProductCategory join table; discuss indexes required for fast tree traversal and product listing.
(
3) Explain strategies to query the full subtree efficiently (e.g., adjacency list with recursive CTEs vs. materialized paths vs. closure tables) and the trade-offs among them.
(
4) Address scaling: caching hot category pages, pagination, denormalized search indexes, consistency choices, write patterns (bulk imports), and multi-region read replicas.
(
5) Cover data integrity (cycles prevention, referential constraints), API versioning, and rollout plans for schema changes.
Quick Answer: This question evaluates system design and data modeling skills for hierarchical data, covering relational schema design, API surface definition, query performance, caching, and data integrity concerns in a product catalog context.