System requirements


Functional:

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

Users should be able to compose and share tweets

Users should be able to read tweets from other users

Users should be able to like tweets

Users should be able to update or delete tweets


A tweet should be less than 280 characters

Tweets can be public or private with a list of allowed viewers


Non-Functional:

List non-functional requirements for the system...

High availability

eventual consistency

scalability

durability


Capacity estimation

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

storage = 200million users * 500B * 1 tweet/day * 365 days * 5years * 3 replicas

download/write = 200 million users * 500 B * 1 tweet/day / 24h / 3600s

upload/read = download * 10


API design

Define what APIs are expected from the system...

POST /api/v1/tweets

POST /api/v1/likes/{tweetId}

DELETE /api/v1/tweets/{tweetId}

PUT /api/v1/tweets/{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...

Table User:

UserId(primary key)

email

hashed password


Table Tweet:

TweetId(primary key)

UserId

CreatedTimestamp

LastUpdatedTimestamp

TweetContent

Privacy

allowedViewers


Table like:

UserId

TweetId



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


if a celebrity sends a tweet, pull

if a tweet is sent by non-celebrity, push



Trade offs/Tech choices

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


database replicas, use sharding; shard by userId can use hotspot problems, but sharding by itemId can cause reading several shards for one user





Future improvements

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