Skip to main content
PreparationZone Logo
PrepZone

Design a Social Feed

Posts, follows, fan-out on write vs read.

Pass checkpoint below

Read these first

Why this matters

  • User posts tweet; followers see in timeline
  • Scope — what "Fan-out" covers inside Social Feed and what it does not
  • Scope — what "Timeline" covers inside Social Feed and what it does not
  • Scope — what "CampusOS extension" covers inside Social Feed and what it does not
  • Platform problems test entity graphs and derived state (reputation, balance).
Dependency direction
Controller / FacadeHTTP or API entry
Serviceuse cases, orchestration
Domainentities, rules, invariants
Repositorypersistence port
Dependencies point inward — domain never imports infrastructure.

CampusOS context

CampusOS is the fictional smart-campus platform used across this track. Treat this module as a real product slice:

Context

  • Belongs to CampusOS — same naming and design vocabulary as parking, library, and booking modules
  • Scope is one JVM — persistence is in-memory or behind a repository interface
  • Goal is a class diagram + core Java that an interviewer can follow in 35–45 minutes
  • Extension paragraph at the end links to System Design when scale exceeds one process

Requirements snapshot

Functional requirements

  • User posts tweet; followers see in timeline
  • Follow and unfollow users
  • Home timeline: tweets from followed users, reverse chronological
  • Fan-out on write vs read — discuss trade-off
  • Like and retweet (optional scope)

Non-functional requirements

  • Single JVM, in-process design for this LLD article
  • Core flows testable with in-memory repositories
  • Extension points for new rules without editing central god classes
  • Clear public API on facade/service layer
  • CampusOS extension links to System Design when scale demands distribution

The rest of this guide is part of Pro

Free covers every fresher guide in full. Pro unlocks Senior, Staff and Architect guides across every track.

Still to come · 6 sections

  • Overview
  • Requirements
  • Fan-out
  • Timeline
  • CampusOS extension
  • CampusOS extension

Test yourself

Answer these before moving on — recall is what makes it stick.