Food Review System
Design item-level ratings and reviews for a food-delivery menu, including verified purchasers, switchable votes, low-latency browse projections, and exactly-once reviewer rewards at configurable upvote thresholds.
Problem statement
Design item reviews for a food-delivery application. For the initial scope, assume one restaurant, one menu, and multiple menu items. An item page shows item details, a 1–5 average rating, paginated and sorted reviews, and visible upvote and downvote counts.
Only a user who purchased the item may create a review, and each user keeps at most one current review per item. A signed-in reader may have at most one current vote on a review and may switch that vote between up and down.
When a review first crosses a configurable eligible-upvote threshold, its author must receive the associated reward exactly once.
A submitted review and each reader's vote must remain idempotent under retries; item averages, vote counts, sorting, moderation visibility, threshold detection, and reward state must converge after edits, vote changes, or hides. Review browsing should complete within 500 ms under normal operation.
For practice, keep recent ordering and one deterministic helpful ordering with a stable tie-breaker; define a policy for vote reversals or moderation after a reward becomes eligible, without coupling review or vote availability to the payout provider.
The original report states about 10 million daily active users, 1 million new reviews per day, 10 million votes per day, a roughly 50:1 read-to-write ratio, and a sub-500 ms browse target.
Design the domain model, APIs, item-average and vote projections, pagination, cache and database ownership, read and write paths, hot-review vote handling, eviction-loss recovery, threshold evaluation, and exactly-once payout handoff.
Exclude multi-restaurant hierarchy, menu authoring, ordering, delivery, recommendations, photos, and payment-rail internals.
What to build
- A verified purchaser can idempotently create or edit one 1–5 rating and text review per user and menu item.
- A reader can view item details, the item average rating, visible vote counts, and stable paginated review lists in recent or helpful order.
- An internal moderation decision can hide a review and cause item averages, vote counts, ordering, and reader pages to converge without accepting new votes.
- A signed-in reader can idempotently set or switch one current upvote or downvote on another user's visible review, durable totals converge after retries, and the first eligible threshold crossing creates one auditable reward obligation for exactly-once payout handoff.
At scale
- Source-backed workload: about 10 million daily active users, 1 million new reviews per day, and 10 million review votes per day.
- Source-backed access mix and target: roughly 50 reads per write, with normal review-browse requests completing in under 500 ms.
- Source-backed scope: users review purchased food items with 1–5 stars and text, browse aggregate ratings and reviews, maintain one switchable vote per review, and earn rewards at configurable eligible-upvote thresholds.
- For practice, acknowledged reviews, votes, and reward obligations survive service restarts; projections and caches may be asynchronous, but durable authorities and reconciliation prevent eviction or retries from losing counts or duplicating a payout.