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...
Thus, your total expected storage requirement would be 756 GB/year in blob storage for video content.
Define what APIs are expected from the system...
POST /videos: Upload a video.GET /videos/{video_id}: Watch a video.GET /videos/search?query={search_query}: Search for videos based on a query.POST /videos/{video_id}/like: Like a video.POST /videos/{video_id}/dislike: Dislike a video.POST /videos/{video_id}/comments: Comment on a video.POST /subscriptions: Subscribe to an account.POST /profiles: Create a user profile.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...
id: Primary Key (Unique identifier for each user).email: User's email (Indexed for fast look-up).username: User's username (Indexed for fast look-up).first_name: User's first name.last_name: User's last name.CREATE TABLE Users ( id SERIAL PRIMARY KEY, email VARCHAR(255) UNIQUE NOT NULL, username VARCHAR(255) UNIQUE NOT NULL, first_name VARCHAR(100), last_name VARCHAR(100)); CREATE INDEX idx_email ON Users (email);CREATE INDEX idx_username ON Users (username);
id: Primary Key (Unique identifier for each video).video_name: Title of the video.upload_date: The date the video was uploaded.length: Duration of the video.file_size: Size of the video file.description: Description of the video.video_link: A link pointing to the video file in blob storage.CREATE TABLE Videos ( id SERIAL PRIMARY KEY, video_name VARCHAR(255) NOT NULL, upload_date TIMESTAMP NOT NULL, length INTERVAL NOT NULL, file_size INT NOT NULL, description TEXT, video_link VARCHAR(255) NOT NULL);
For the NoSQL part, storing video interactions, subscriptions, and user comments adds scalability and flexibility.
video_idcomments: array of comment IDs.like_count: number of likes.dislike_count: number of dislikes. }{ "video_id_1": { "comments": ["comment_id_1", "comment_id_2"], "like_count": 100, "dislike_count": 5 }, "video_id_2": { "comments": ["comment_id_3", "comment_id_4"], "like_count": 50, "dislike_count": 2 } }
user_idsubscribed_to: array of user IDs the user is subscribed to.subscribers: number of users subscribed to them.{ "user_id_1": { "subscribed_to": ["user_id_2", "user_id_3"], "subscribers_count": 250 }, "user_id_2": { "subscribed_to": ["user_id_1"], "subscribers_count": 150 } }
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...
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...
flowchart TD A[User Request] -->|Routes via| B[Load Balancer] B -->|Routes Request| C[App Server] C -->|Fetch Video Link| D[SQL DB] C -->|Fetch Interactions| E[Interaction Service] D -->|Video Link| F[Blob Storage] E -->|Comments/Likes/Dislikes| G[NoSQL DB] F -->|Streams Video| H[Client] G -->|Returns Interactions| H
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...
Explain any trade offs you have made and why you made certain tech choices...
Try to discuss as many failure scenarios/bottlenecks as possible.
Scenario:
Impact:
Scenario:
Impact:
Scenario:
Impact:
What are some future improvements you would make? How would you mitigate the failure scenario(s) you described above?
Mitigation Strategies: