Requirements


Functional Requirements:


  • Allow users to tweet messages up to 140 characters.
  • Enable users to follow other users.
  • Allow users to like tweets from other users.
  • Display tweets from followed users in the home feed.
  • Show top K popular tweets in the home feed based on likes and followers.



Non-Functional Requirements:


    List the key non-functional requirements (eg low latency, scalability, reliability, etc.)...


Capacity Estimation

Estimate the scale of the system. Consider daily active users, read/write ratio, storage requirements, bandwidth, and any relevant QPS calculations...




API Design

Tweet:

ADD /tweet/v1/


GET /tweet/v1/tid

POST(modification) /tweet/v1/tid

Delete /tweet/v1/tid


Like:

GET /tweet/v1/tid

POST /tweet/v1/tid


Follower:

LIST /follower/v1/uid

ADD /follower/v1/uid




Workflow:

  1. Client login to Auth server
  2. A token is assigned for login afterward
  3. Login into server, checking below information in cache
    1. Followers
    2. Top Feeds in last 5 minutes
  4. If hit, just sent to client. Else fetch from Database then update Cache



Database Design

Tweet Table:

UID int

TID int

Timeline date

description String


User Table:

UID int

Followers List

Following List




Detailed Component Design