bugl
bugl
HomeLearnPatternsPathsSearchPremium
HomeLearnPatternsPaths

Loading lesson path

Learn/System Design/Design a News Feed
System Design•Design a News Feed

Design a News Feed: API & Data Model

Design a home timeline (Twitter/Instagram style) that shows recent posts from accounts a user follows.

How to approach it

Design the API and data model from the user’s actions, not from the database. Name the few core endpoints, the entities and their keys/indexes, and — critically — which data must be strongly consistent versus eventually consistent. The access pattern (how you read the data) should drive the storage choice, not the other way around.

Core APIs

EndpointPurpose
POST /postspublish a post
GET /feedfetch the home timeline (paged)
POST /follow/{userId}follow an account

Entities

EntityKeys / indexes
Post (id, author_id, body, created_at)PK(id), index(author_id, created_at)
Follow (follower_id, followee_id)index(follower_id), index(followee_id)
Timeline (user_id, post_ids[])precomputed per user (fan-out cache)

Note

A post may appear in followers’ feeds a few seconds late — eventual consistency is fine.

Previous

Design a News Feed: Capacity Estimation

Next

Design a News Feed: High-Level Architecture