System requirements
Functional:
User should be able to compose and share the post
Post should appear in his timeline
The post should be published to the user's followers' timeline
Users should be able to express their likeness to the post
Non-Functional:
The solution should be scalable
High availability
Security
Capacity estimation
Let us consider that each post contains the following information:
> PostId: 4bytes = 2^32 range
> Content: 300 bytes = 300 char char length
API design
@app.post("/post/tweet")
def post_tweet (request):
@app.get("/fetch/tweet")
def fetch_tweet():
@app.get("fetch/timeline")
def fetch_timeline(timeline_src: str = 'self'):
Database design
tweet_tabel{
tweet_id: str (32 chars)
tweet_content: str(300 chars)
tweet_time: Date
}
user: {
user_id: str ()
user_name: str,
user_location: str
}
user_followers: {
id: str(32)
user_follower: str(32)
user_follwed: str(32)
}
High-level design
At a high level, I see the following components are applicable:
> Application server(which handles)
>
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?