Digital Game Marketplace: Catalog, Checkout, Downloads, Reviews
System DesignModel answerLast updated
Design a digital game marketplace covering category browsing, a payment-safe purchase flow, entitlement-gated downloads, and a review system, with explicit policies and retry-safe behavior.
You are asked to design the backend and user-facing flows for an online marketplace that sells digital games. Users should be able to:
- Browse games organized by category.
- Buy a game and then download it.
- Leave reviews on games.
Walk through the user journeys, the data model, the APIs, and the backend behavior that keeps all of this consistent, including what happens when requests are retried or a payment outcome is unclear.
No traffic numbers are given, so begin by stating the clarifying questions you would ask and the assumptions you will make (catalog size, peak traffic, installer sizes, client platforms, availability targets). Treat pricing, refunds, and how long download access lasts as product policies that you must define explicitly.
Part 1: Catalog browsing. Describe the category listing and game-detail pages, how they link to each other and to the buy action, what data each needs, and how you handle ordering, pagination, and caching.
Part 2: Purchase and download. Describe how a purchase is created, how payment state is tracked (including retries and unknown outcomes), how a lasting right to download is recorded, and how downloads are authorized and delivered efficiently for large files.
Part 3: Reviews. Describe who may review, whether reviews are editable, how they are stored and validated, how duplicates and abuse are handled, and how review lists are paginated and cached, including any consistency trade-offs.
Hints
Hint 1
Separate the catalog (read-heavy, cacheable, eventually consistent) from purchases and entitlements (write-sensitive, strongly consistent). Different parts deserve different storage and caching choices.
Hint 2
Use an idempotency key on checkout and a state machine for orders (created, pending, paid, failed, refunded). Treat the payment provider's webhook, not the browser redirect, as the source of truth, and add reconciliation for unknown outcomes.
Hint 3
Never serve game files from your application servers. Check entitlement, then issue a short-lived signed CDN URL. For reviews, enforce one review per user per game with a unique constraint, and keep aggregate ratings as a denormalized, asynchronously updated value.
Model answer
Medium Try it yourself first — then compare your approach, complexity and edge cases.
Clarifying questions and assumptions
- Scale: assume about 50k games, 5M monthly users, and 50k peak browse requests per second, mostly reads. Purchases are far rarer, perhaps tens per second at peak.
- Artifacts: installers range from 100 MB to 100 GB, so resumable downloads are required.
- Clients: web plus a desktop launcher. Both use the same API.
- Policies I will define: a purchase is permanent unless refunded; refunds are allowed within a fixed window and revoke the entitlement; only owners can review; each user gets one review per game, editable.
- Availability: browsing and downloads should be highly available; checkout may degrade gracefully.
Data model
games(id, title, description, price_cents, currency, status, artifact_id, avg_rating, rating_count)categories(id, slug, name)andgame_categories(game_id, category_id)(many-to-many)orders(id, user_id, game_id, amount, status, idempotency_key, provider_ref, created_at)with a unique index on(user_id, idempotency_key)entitlements(user_id, game_id, order_id, granted_at, revoked_at)with a primary key on(user_id, game_id)reviews(id, user_id, game_id, rating, body, status, created_at, updated_at)with a unique index on(user_id, game_id)
A relational database (Postgres) fits the transactional data. Catalog reads are served from cache and a search index.
Part 1: Browsing
Pages: Category list, then category page (games in the category), then game detail (description, price, rating, reviews, Buy or Download button).
APIs:
GET /categoriesGET /categories/{slug}/games?cursor=...&limit=24&sort=popularGET /games/{id}
Pagination: use cursor (keyset) pagination on a stable composite key such as (popularity_score desc, game_id). This avoids duplicates or skips when the catalog changes and is cheaper than deep offsets. The tie-breaker on game_id guarantees a deterministic order.
Caching: category and game-detail responses are nearly identical for all users, so cache them at the CDN with a short TTL (1 to 5 minutes) and purge on edit. Personalized parts (owned or not, wishlist) come from a separate small authenticated call, so the main payload remains cacheable. Popularity ordering can be precomputed periodically into a sorted structure per category.
Part 2: Purchase and download
Checkout flow:
- Client calls
POST /orderswithgame_idand anIdempotency-Key. The server rejects it if the user already owns the game. It reads the price server-side (never trusts the client) and creates an order increated. - The server creates a payment intent with the provider, using the order ID as the provider-side idempotency reference, and moves the order to
pending. - The client completes payment with the provider's SDK.
- The provider calls our webhook. After verifying the signature, we move the order to
paidand create the entitlement in one transaction. Webhook handling is idempotent: replays find the order alreadypaidand do nothing. - The client polls
GET /orders/{id}(or receives a push) to show the outcome.
Uncertain outcomes: if the client times out, a retry with the same idempotency key returns the same order rather than creating a second charge. If the webhook never arrives, a reconciliation job queries the provider for orders stuck in pending beyond a few minutes and resolves them to paid or failed. The UI shows "processing" rather than guessing. Never grant access based on the browser redirect alone.
Order states: created -> pending -> paid | failed | expired, and paid -> refunded. Transitions are enforced with conditional updates (WHERE status = 'pending').
Entitlement: a durable row keyed by (user_id, game_id). Refunds set revoked_at. Keeping this separate from orders gives download checks a single fast lookup, and it supports gifts or promotions later.
Download:
POST /games/{id}/downloadchecks the entitlement.- The server returns a short-lived signed URL (for example 10 minutes) pointing at the CDN or object store.
- The CDN serves the file with HTTP range support, so the launcher can resume and download in parallel chunks.
Large files never pass through application servers. Signed URLs are cheap to verify at the edge. Because the URL expires, a revoked entitlement stops working quickly, and the user can request a new URL at any time. Log download grants for audit and abuse detection (for example, one account issuing thousands of URLs). Version artifacts and expose checksums so clients can verify integrity.
Part 3: Reviews
Policy: only users with an active entitlement can review (reducing fake reviews). One review per user per game; edits update the same row. Ratings are 1 to 5, with a body length limit (say 5,000 characters).
API:
PUT /games/{id}/reviews/mecreates or updates the user's review (naturally idempotent, so retries and double-clicks are safe; the unique index backs it up).GET /games/{id}/reviews?cursor=...&sort=recent|helpful
Validation and abuse: sanitize and escape text, rate-limit per user, run a lightweight profanity and spam filter, and let users report reviews. Flagged items go to a moderation queue and are hidden by setting status. Reviews from users whose purchase was later refunded can be kept but flagged, or hidden, according to policy.
Aggregates: maintain avg_rating and rating_count on games. Update them asynchronously from a review-change event stream, or via incremental updates (sum and count), so the write path stays light. Recomputing from scratch periodically fixes drift.
Consistency trade-off: a user should see their own review immediately (read-your-writes). Return it in the PUT response and merge it client-side, or bypass the cache for the author. Everyone else may see the new review and updated average after a short delay (seconds to minutes) because list pages and aggregates are cached. This is acceptable because reviews are not financial data.
Trade-offs and common mistakes
- Granting access on the client-side payment redirect rather than a verified webhook.
- Missing idempotency, which leads to double charges on retries.
- Streaming large files through app servers instead of using signed CDN URLs.
- Offset pagination on a changing catalog, causing duplicates and gaps.
- Recomputing average ratings on every request.
- Not defining refund and review policy, leaving revoked entitlements and orphaned reviews unaddressed.
- Putting personalized data into cached catalog responses, which fragments the cache or leaks data.
Scaling notes
Reads scale through CDN, cache, and read replicas. The order and entitlement database is low-volume and can use a single primary with replicas for failover. Download bandwidth is the main cost and is handled by the CDN. Add search (an inverted index) later without changing the core flows.