System requirements
Functional:
List functional requirements for the system (Ask the chat bot for hints if stuck.)...
A User will have the ability to create Tweets.
A User will have a profile.
A User will be able to follow people and be followed by others.
A User will be able to view his followed tweets.
Ability to share and like tweets.
Non-Functional:
List non-functional requirements for the system...
This system will need to be scalable as we don't want users not to be able to retrieve tweets as we are receiving plenty of tweets a day.
Because twitter is a high availability and quick app we would require availability.
Perhaps metrics to see what tweets are read.
Capacity estimation
Estimate the scale of the system you are going to design...
Approximitely 500m users.
Every user tweets a day so about 500,000,000 tweets every day
API design
Define what APIs are expected from the system...
Post /tweet (UUID userId, String tweet)
Post /likeTweet (UUID userId, UUID tweetId)
Post /followUser (UUID userId, UUID followingUserId)
Post /createUser (String username, String password)
Get /newsFeed (String userId)
Get /shareTweet(UUID tweetId)
Delete /removeLike(UUID tweetId)
Delete /removeTweet(UUID tweetId)
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...
There would be a User Table
User:
UserId PK Unique AutoIncrement
Name
Number
Location
Tweet Table:
TweetId PK Unique AutoIncrement
Varchar Tweet
UserId FK
Follower Table:
FollowerId UserId FK
FollowingId UserId FK
Like Table:
TweetId Composite Key FK
UserId Composite Key FK
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...
We would have a client. We would have Servers which would be serveerless so that we can horizontally scaled. The Server will contain the endpoints. Then there would be a database which would contain the various tables. We would have some sort of backup of all the data just in case it goes down. We would also implement a caching level above the databases so that we can make sure that there isn't too much load going into the db. In the caching we would implement some way that tweets perhaps from people with many followers would be in the caching layer. We would also have 2 databases one perhaps just for the reads and the other that would be for the writes.
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...
So we would have a client lets say creating a tweet. That client would be sending a post request to the server. The server would then validate that it is the proper amount of characters. If it is then it would send back to the client a 200. If it is not it will send a message back to the client that the tweet is not valid. The server will then make sure that the tweet is valid and add the tweet to the Tweet table. If you are going to create a news feed the server will take the userId and then it will create a List of tweets returned back to the clients based on their followers most recent tweets.
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?