List functional requirements for the system (Ask the chat bot for hints if stuck.)...
List non-functional requirements for the system...
Estimate the scale of the system you are going to design...
Define what APIs are expected from the system...
shard document if user exceeds the max storage per doc.
POSTGRES - for follow/following relationship
POST /tweet -> store mongodb -> push queue -> consumer reads -> sends to newsfeedsvc -> push new event to all followers newsfeed( in case of popular user just store it as one of the popular events ).
GET /newsfeed -> go to newsfeed svc -> query newfeed for the user + merge with popular tweets list -> respond.
Newsfeed svc - need to store a stack of newsfeed to be shown to the user. Just use document store (mongoDB) here as well to push new tweets to the newsfeed.
Popular tweets -> store popular user's tweets in a cache like redis. query latest 5 posts of all the popular tweets and merge the result in the newsfeed.
Explain any trade offs you have made and why you made certain tech choices...
What are some future improvements you would make? How would you mitigate the failure scenario(s) you described above?