KatInterview

Eliminate Duplicates in a Personalized Content Feed

System DesignModel answer
HardModel answerSystem Designdeduplicationpersonalizationrecommendation-systems

Last updated

Design a system that ensures each piece of content appears only once in the initial screen of a personalized homepage with multiple thematic rows.

You're building a personalized content homepage for a streaming service. The page consists of multiple horizontal rows, each with its own theme (e.g., "Action Movies," "Because You Watched X," "Trending Now," "Continue Watching"). Each row displays several content items as tiles.

Your task is to design a system that ensures no content item appears more than once in the portion of the page visible when it first loads (the "initial viewport"). This constraint applies across all rows and within each row.

Additional considerations:

  • Each row has semantic meaning and eligibility rules. An item shown in "Because You Watched Breaking Bad" must legitimately belong there based on the recommendation logic.
  • Some items have editorial requirements (e.g., a newly launched show must appear in position 1 of a specific row).
  • Content has age ratings and regional availability that must be respected.
  • The goal is to maximize overall relevance to the user while satisfying the uniqueness constraint.
  • Users scroll both vertically (more rows) and horizontally (more items in a row), so you need to handle pagination efficiently.
  • The viewport size varies by device: large screens might show 4 rows × 6 items, while mobile shows 3 rows × 2-3 items.

Design the complete system including:

  1. Data models for rows and content candidates
  2. APIs for serving the homepage and handling pagination
  3. The algorithm for selecting and placing items to maximize relevance while enforcing deduplication
  4. Strategies for handling edge cases (insufficient candidates, conflicting requirements)
  5. Caching approach and performance targets
  6. How you'd measure success

State your assumptions about scale, clarify ambiguities, and discuss trade-offs in your design choices.

Hints

Hint 1

Think about whether deduplication should be strict only in the viewport or applied more broadly

Hint 2

Consider processing editorial requirements and hard constraints before running the main selection algorithm

Hint 3

A greedy approach can work well if you process items in the right order—what metric determines priority?