Skip to main content

Preview — Pro guide

You are seeing a portion of this guide. Sign in and upgrade to unlock the full article, quizzes, and interview answers.

Social Follow & Home Feed — LLD (Graph, Push vs Pull, Feed Strategies)

Object-oriented design for follow relationships, optional follow requests, blocking, and feed generation. Teaches how to model the social graph separate from posts, when to use Strategy for push-fanout vs pull-merge feeds, and what to leave to infrastructure without faking a single Map that scales to billions of edges.

48 min read 3 sections 1 interview questions
Social Graph LLDPush Fan-outPull k-way MergeFollow UnfollowBlockEdgeFeedBuilder StrategyObject-Oriented DesignNews FeedTwitter ModelSEDIE FrameworkTAO-Style Graph
IMPORTANT

What Interviewers Are Actually Testing

They are not asking you to rebuild Twitter at HLD scale in 40 minutes. They want: a clean graph model (User, FollowEdge with state, BlockEdge), a Feed abstraction that does not entangle storage of every post inside User, and the push vs pull tradeoff expressed as replaceable strategies, not buzzwords. Strong candidates say: push materializes fan-out at write time (inbox per user); pull merges at read from followed author lists — each is a class implementing FeedBuilder. Weak candidates return List<Post> from User.getFeed() with O(follows × posts) hidden in a getter and call it done.

Clarifying Questions

01

Directed follow (Twitter) vs symmetric friends (Facebook classic)?

FollowEdge is asymmetric; Friendship is two approval edges or one undirected record — model changes follow-up questions on privacy.

02

Follow requests vs instant follow?

Add PENDING state on edge; accept() transitions to ACTIVE. Private accounts — only approved followers see posts.

03

Block vs mute?

BlockEdge removes follow, hides both ways; mute is reader-only filter — separate type or flag on consumer side.

04

Global feed ordering — reverse chrono only?

Start with time; ranker is a separate FeedRanker strategy for 'For you' mix — do not implement a DNN in LLD, name the seam.

05

Scale hints?

If celebrity with 50M followers is in scope, fan-out write path is expensive — you either cap delivery, hybridize, or acknowledge HLD — the LLD still has the right interfaces.

IMPORTANT

Premium content locked

This guide is premium content. Upgrade to Pro to unlock the full guide, quizzes, and interview Q&A.