System requirements


Functional:

  1. Users can post, repl,y and like tweets.
  2. Followers and the following feature
  3. Home feed
  4. Tweets can have hashtags as well



Non-Functional:

  1. Availability - The system should be highly available
  2. Partial tolerance



Capacity estimation

  1. 500M DAU
  2. Each user makes around 2 tweets a day
  3. Tweet ~1Kb, user info ~512bytes and other meta info ~512bytes
  4. Total capacity to store ~ (2*1Kb + 512bytes + 512bytes) = 3Kb
  5. Storage needed for 2 years = (2*365*3)Kb*500M = 2000*50,00,000 = 10Tb




API design

post_tweet (user_id, content) tweet_id

home_feed(user_id) tweets

follow(user_id, follower_id)





Database design

Defining the system data model early on will clarify how data will flow among different components of the system. Also you could draw an ER diagram using the diagramming tool to enhance your design...

  1. Users
    1. user_id
    2. followers
    3. following
    4. profile_media_link
    5. createdAt
  2. Tweets
    1. tweet_id
    2. user_id
    3. likes
    4. content
  3. Hashtags
    1. id
    2. tweet_id
    3. hashtags





High-level design

You should identify enough components that are needed to solve the actual problem from end to end. Also remember to draw a block diagram using the diagramming tool to augment your design. If you are unfamiliar with the tool, you can simply describe your design to the chat bot and ask it to generate a starter diagram for you to modify...






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

Dig deeper into 2-3 components and explain in detail how they work. For example, how well does each component scale? Any relevant algorithm or data structure you like to use for a component? Also you could draw a diagram using the diagramming tool to enhance your design...






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?