Design a Ranked Social Network Platform
Create and delete text posts, manage follows and likes, and serve a paginated personal dashboard using seven explicit ranking signals.
Problem statement
Design a social platform where users create and delete text posts, view their own or a selected account’s posts, follow accounts, list followers and following, and like or unlike any live post whether or not they follow its author. Each user also has a paginated dashboard of top posts.
Its ranking considers all seven factors: followed authors, total likes, recent likes, recent post creation, recently followed authors, recently viewed authors and often viewed authors.
Use these given relational fields as a starting point: tweets(tweet_id, text, account_id, date_time); accounts(account_id, date_time); follow(follow_from_account_id, follow_to_account_id, date_time); likes(tweet_id, liked_from_account_id, date_time). Add the state and indexes needed for the requested behavior.
For this exercise, assume all accounts and posts are public. Only the author may delete a post. Use a bounded dashboard candidate pool: up to 200 recent posts from followed authors, 200 popular recent posts globally, and 100 recent posts from recently or often viewed authors, deduplicated to at most 500 IDs.
Here recent posts means the last seven days. The dashboard returns up to 100 ranked posts from that pool, in pages of at most 20. It does not promise the mathematically best posts over every post ever created.
For this exercise, retrieving those candidates may read at most ten bounded source pages or partitions per new session; use precomputed viewer/source indexes or another bounded plan, and report partial/degraded results if source work misses its deadline. The final 500-ID cap alone does not bound reads across authors.
Choose and justify explicit normalization and positive weights for all seven signals, a deterministic tie order, and a versioned scoring rule.
For practice, recent likes are active likes created in the last 24 hours; recent follows and recent account views use seven days; view frequency uses 30 days of account-timeline visits. These are exercise definitions, not reported ranking weights or production internals.
For this exercise, the first dashboard request fixes an ordered candidate snapshot and its scoring version for a ten-minute browsing session. Later likes or views affect a new session, not the order halfway through an existing session.
Every returned post is checked against current deletion state; skip deleted posts and keep scanning forward without duplicates. A missing or expired snapshot requires an explicit restart. Account timelines list live posts newest first with stable ID tie-breaking.
Exclude post editing, media, comments, reposts, direct messages, private accounts, unfollow, search and machine-learning model training. Explain data ownership, request contracts, seven-signal features, ranking and safe pagination.
What to build
- Create text posts, delete only one’s own posts, and list live posts for oneself or a chosen account in a stable newest-first timeline.
- Follow accounts, list followers/following and set or remove one active like per user/post independently of follow state.
- Build a bounded per-user candidate pool and rank it with all seven stated priority factors under an explicit versioned scoring contract.
- Page through one fixed dashboard order while suppressing currently deleted posts and exposing session expiration without duplicates or silent reranking.
At scale
- For this exercise, assume one million registered users, 100,000 daily active users, one million new posts per day and 10,000 dashboard page reads per second at peak. Reads justify cached feature projections and bounded candidate scoring rather than scanning all posts.
- For this exercise, target 500 ms p95 for timeline/dashboard pages and normally propagate accepted likes, follows and account-view events into new dashboard sessions within 30 seconds. Existing session order remains fixed. For this exercise, candidate-source retrieval has a 200 ms deadline within that page target, at most ten bounded source pages per new session and explicit partial/degraded status on deadline or projection lag; never silently claim the normal freshness target for an older fallback.
- For this exercise, bound each dashboard snapshot to 500 candidate IDs, at most 100 returned live posts and ten minutes of validity; pages contain at most 20 posts. A session can end early if candidates are deleted or exhausted.
- For this exercise, acknowledged post/follow/like changes survive one process failure. After a delete acknowledgement, later reads must not return that post; define the current-state read check needed even when rankings and caches lag.