On a high level, the system is going to be composed of app servers, load balancer, blob store, cdn, sequencer, key-value store, graph db, sql database, and cache.
The api gateway will check for auth and balance the load to the servers. The servers will be composed of feed generator, search engine, like engine, tweet manager. The user data and account will be saved to a sql database for consistency. Likes will be stored in sharded counter for high throughput. tweets and comments will be stored in distributed key value store. The blob store will keep the medias, and they will be distributed through CDN network, and only the media url will be saved in the database. A cache layer will be in front of the database to accomodate popular twwets
Distributed key-value store: (e.g. RockDB) Usage of a sequencer like snowflake (64bit id composed of timestamp, worker_id and counter), we guarantee unique tweet id. Then the shard key for comment would be with tweet ids to allow range query of comments.
The feed generator is an async system that build the news feed for users async so they can retrieve quicly the feed on login. It aggregate the follow data and tweets into a news feed for each user
The search engine allows for full text search with apache lucene inverted index
The sharded counter allow for high throughput like counter and later processing to build the feeds and update periodicly the tweets counts