System requirements
Functional:
- View other people's tweets
- Tweet text/images/videos
- Follow other users
- Search for other tweets
- Like or retweet tweets
- Edit your profile
Non-Functional:
- Availability > Consistency
- Scalable
- Low latency
Capacity estimation
Estimate the scale of the system you are going to design...
API design
GET /tweets
- Returns: list of tweets
POST /tweets
- Params: id, user, timestamp, tweet content
POST /users/:userId/follow
- Params: user
GET /tweets
- Params: search keyword
- Returns: list of tweets
POST /tweets/:tweetId/like
POST /tweets/:tweetId/retweet
Database design
- NoSQL
- Users: id, name, email, followers, following, bio
- Tweets: id, content, user, timestamp, likes, retweets
High-level design
- API Gateway
- NoSQL database
- Blob storage
- CDN
- Ranking service
- Load balancer
Request flows
Explain how the request flows from end to end in your high level design. Also you could draw a sequence diagram using the diagramming tool to enhance your explanation...
Detailed component design
- Replicate the user database
- Horizontally shard the tweet database based on timestamp
Trade offs/Tech choices
Explain any trade offs you have made and why you made certain tech choices...
Failure scenarios/bottlenecks
Try to discuss as many failure scenarios/bottlenecks as possible.
Future improvements
What are some future improvements you would make? How would you mitigate the failure scenario(s) you described above?