Users:
user_id primary key,
user_name index,
email,
created_at,
updated_at
Friendships:
from_user_id index,
to_user_id index,
created_at
primary_key(from_user_id, to_user_id)
To look up whom a user is following and we can make from_user_id as partition key and to_user_id as sort key.
To easily view who are following a user, we can create a GSI for revert relationship: to_user_id as partition key and from_user_id as sort key
Tweets:
tweet_id primary key,
content,
created_by index,
created_at inxex
We need fast reads on tweets, and there isn't a strong need to join with other tables, so we can select a key-value database like DynamoDB to allow fast reads and easy to be scalable.
To look up tweets by user id and sort tweets by created_at, we can create GSI: created_by as partition key and created_at as sort key
Likes:
tweet_id,
user_id,
created_at
Hashtag:
hashtag_id index,
tweet_Id index,
created_at
primary_Key(hashtag_id, tweet_id)
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...
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?