← Create New Paste

System Design Interview: Designing Product Reviews and Star Ratings

3 views
"Design the reviews and ratings system for an e-commerce site" is a practical system design interview question. Customers write reviews with one to five stars, product pages show the average rating and the most helpful reviews, and the system must resist fake reviews. The challenge is combining fast reads with fair, trustworthy data. 1. Requirements Functional: submit, edit and delete a review with a star rating, text and photos; show average rating, rating distribution and total count on each product page; sort reviews by most helpful, newest or rating; vote reviews as helpful; report abuse. Non-functional: product pages are extremely read-heavy, reviews appear within minutes, and aggregate ratings must be consistent enough that users do not notice errors. 2. Data model - Review: review_id, product_id, user_id, rating, title, body, media links, status (pending, published, rejected), created_at, verified_purchase flag. - HelpfulVote: (review_id, user_id) unique. - ProductRatingSummary: product_id, count, sum, and count per star (1 to 5). A unique constraint on (product_id, user_id) enforces one review per customer per product. 3. Write path The review service validates the request, checks purchase history to set the verified flag, stores the review as pending, and publishes an event. A moderation pipeline (automated text filters, spam and fraud models, and human review for borderline cases) moves it to published or rejected. When published, the summary is updated. 4. Keeping aggregates fresh Recomputing an average over millions of reviews on each page view is wasteful. Maintain the summary incrementally: on publish, count += 1, sum += rating, star_count[rating] += 1; on edit, subtract the old rating and add the new; on delete, subtract. Apply these updates through an idempotent consumer keyed by review_id and version, so retries do not double count. Run a nightly job that recomputes summaries from scratch and corrects drift. 5. Read path Product pages read the summary and the first page of top reviews from a cache (Redis or CDN edge cache), invalidated or refreshed when the summary changes. Review lists are paginated with cursors, not offsets, for large products. 6. Ranking "most helpful" Sorting by raw helpful votes favors old reviews. Use a score such as the lower bound of the Wilson confidence interval on helpful versus not-helpful votes, with a boost for verified purchases and recency. Similarly, show a Bayesian average for products with few reviews, so one 5-star review does not outrank hundreds of 4.7 ratings. 7. Fraud and abuse Signals: new accounts, many reviews in a short time, shared devices or IPs, reviews from sellers' networks, and text similarity. Rate-limit submissions, hold suspicious reviews for human review, and remove reviews retroactively, updating summaries when you do. 8. Scale Shard reviews by product_id, since most queries are per product. Search across reviews (for example "battery life") goes through a search index fed by the same events. Walk through requirements, model, write and read paths, aggregation and fraud. For support when the interviewer asks deeper follow-ups, Linkjob AI (https://linkjob.ai) offers real-time help during job interviews and technical interviews, including system design rounds.
Created Nov 17, 2026 10:29 Expires Nov 17, 2027 10:29