System requirements


Functional:

List functional requirements for the system (Ask the chat bot for hints if stuck.)...

-user sign-up

-user login with authentication

-user can post tweets

-user sees feed of other users' posts

-user can like tweets of other users

-user can retweet tweets of other users

-user can follow other users

-user log-out

-user get shown tweets based on previous activity/recommendation algorithm

-user get real-time notifications for likes and retweets on their posts


Non-Functional:

List non-functional requirements for the system...

-keep track of all users a user has followed

-show relevant tweets to the user

-keep track of tweets a user has tweeted

-keep track of user info

-form recommendation system

-form latent categories and populate user ratings of them based on activity

-recommend based on nearest matches

-real time notifications



Capacity estimation

Estimate the scale of the system you are going to design...


-support upto 1 billion users

-support 1 million posts per user



API design

Define what APIs are expected from the system...


-user login

-input: email, password

-output: access to platform via jwt authentication token


-user logout


-followed users by a user

-all the users a user follows


-tweets by a user


-getRecommendedUsers

-based on recommendation service


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...


-Mongo DB database for user/post functionality


-table with users

-user info

-table for likes

-user who liked (id)

-post id

-table for comments

-user who commented (id)

-post id

-timestamp

-table for reposts

-user who reposted

-post id

-timestamp


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...



-Client

-user interface

-feed of recommended posts

-create post view


-API gateway


-signup/login service


-content service (make posts, like posts, follow users, retweet posts)


-recommendation service


-MongoDB





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...


Signup/login flow

-user signs up/logs in on client

-client calls relevant method on api gateway

-api gateway calls relevant method on signup/login service to insert a new user or fetch user info

-signup/login service gets relevant user info from MongoDB

-recommendation service fetches recommendation


user action service (like, post, retweet, follow)

-user makes an action via the client

-relevant API method is called

-user action service is called to update mongodb

-recommendation service is updated and latest recommendation fed back to API gateway



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...


-signup/login service

-uses authentication like JWT on the client and in the API

-password encrypted

-info stored in a table in MongoDB

-scales well due to mongoDB to support many users

-asynchronously, new user triggers recommendation service flow

-user action service

-user actions processed asynchronously via message queue and queue worker so user can continue to use the app before waiting for action to complete

-scales to many actions use to mongoDB

-real-time updates performed via web socket



Trade offs/Tech choices

Explain any trade offs you have made and why you made certain tech choices...


-Chose mongoDB due to high scalability and reliability to support many users



Failure scenarios/bottlenecks

Try to discuss as many failure scenarios/bottlenecks as possible.


-double performance of user action leads to redundant actions on the backend




Future improvements

What are some future improvements you would make? How would you mitigate the failure scenario(s) you described above?


-implement live video chats/voice chats