KatInterview

Build a Restaurant and Dish Rating Service End to End

System DesignModel answer
MediumModel answerSystem Designsystem-designreviewssearch

Last updated

Design a backend for browsing eateries, posting star ratings and written reviews, and keeping aggregates, search, and moderation trustworthy at scale.

Build a Restaurant and Dish Rating Service

You are asked to design the backend for a service where people find places to eat, read what others wrote, and publish their own star ratings and written reviews.

Begin by pinning down scope. Decide whether reviews target restaurants only, individual dishes, or both, and state whether ordering and delivery are handled by a different system.

Part 1: Product and data contract

Describe the core records: users, businesses, dishes (if in scope), reviews, ratings, photos, and moderation status. Give the read and write APIs. State your policy on whether a user can review the same entity more than once, and how edits and removals change the displayed totals.

Cover:

  • Stable identifiers for entities and reviews.
  • Rating scale, review lifecycle, and duplicate-review rule.
  • Idempotent creation and versioned edits.
  • Who can see or change what: authors, business owners, moderators, anonymous readers.

Part 2: Discovery and review reads

Design lookup for businesses or dishes, nearby and text search if needed, review listing with pagination and sorting, rating summaries, photo display, caching, and what a user sees right after posting.

Cover:

  • Authoritative records versus derived search and aggregate views.
  • Cursor pagination that stays stable, with a deterministic tie-breaker.
  • Maintaining rating count and sum through edits and removals.
  • Stated freshness expectations for search results, summaries, and detail pages.

Part 3: Abuse, trust, and privacy

Explain how you handle spam, harassment, fake reviews, owner disputes, user reports, automated detection, human moderation, appeals, and personal data.

Cover:

  • Moderation states that are distinct from hard deletion.
  • Behavioral signals (rate, account age, relationships) treated as evidence, not proof.
  • Evidence retention, appeal history, and auditable decisions.
  • Protection of personal data and sensitive location data.

Part 4: Scale and operations

Discuss partitioning, very popular businesses, read and write amplification, search-index lag, media delivery, retries, reconciliation, and monitoring.

Cover:

  • Partitioning that avoids a single global lock on reviews.
  • Idempotent change events and projections that can be rebuilt.
  • CDN-served media with safe upload handling.
  • Metrics for freshness, aggregate drift, abuse, and user-perceived latency.

Hints

Hint 1

Settle review identity first: choose a uniqueness rule such as one active review per (user, entity), and make creation idempotent with a client-supplied key so retries never double count.

Hint 2

Treat the review table as the single source of truth and everything else (search index, rating summary, caches) as a projection fed by an ordered, idempotent event stream that can be replayed.

Hint 3

Keep moderation as a state machine (pending, published, hidden, removed, appealed) rather than deleting rows, and have aggregates react to state transitions, not just to creates.

Hint 4

For hot businesses, shard reviews by entity but accumulate aggregate deltas in batches or per-shard counters so one popular place does not become a write hotspot.