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...
For the number of tweets
Lets assume there are 10^6 users and each user makes 10 tweets a day
then the number QPS =10^6*10=10^7/10^5 =100
Lets assume each user follows 50 users then the number of follows qps=
50 *10^8= 5*10^9/10^6= 5*10^3
Define what APIs are expected from the system...
1) /v1/tweet
RequestBody
{
twitterContent:"",
images and GIF:[""],
userId:""
}
ReponseBody on successfull creation and response code 201
{
tweetId:"12434"
}
and response body on error
{
tweetId:null
}
2) /v1/comment/:tweetId?commentString=" retrun code 200
RepsonseBody
{
message:"successfully added"
}
and response body on error
{
message:cannot insert
}
3) /v1/like/:tweetId
RepsonseBody on status code 200
{
message:"successfully liked"
}
and response body on error
{
tweetId:null
}
4) /v1/seach?tweetName=&limitValue=20&cursorValue=after
responseBody response code 2200
{
tweetId:""
tweetName:"",
postedBy:"",
}
response code 500 on some error
5) /v1/follow
resposne body Returns response code 200
{
followingUserId:"",
followerUserId:"",
}
response code 500 on some error
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...
Sharding (by tweetId) and master-slave replication are used for horizontal scalability and fault tolerance.
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 → API Gateway → Rate Limiter → Services → Kafka → Worker → DB
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...
Client → API Gateway → Rate Limiter → Services → Kafka → Worker → DB
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...
Client → API Gateway → Rate Limiter → Services → Kafka → Worker → DB
Explain any trade offs you have made and why you made certain tech choices...
1) Relation Database are hard to scale
Try to discuss as many failure scenarios/bottlenecks as possible.
What are some future improvements you would make? How would you mitigate the failure scenario(s) you described above?
1) Introducing machine larning to im