List functional requirements for the system (Ask the chat bot for hints if stuck.)...
1) Allow users to share the file
2) Allow users to message other people in the same organization
3) Allow users to make a call user to other person in the same organization
4) Allow usere to make a video call to other useres in same organization
5) Allow users to make a group and allow him to add other users in the group
List non-functional requirements for the system...
1) System should be highly scalable
2) System should be fault tolorent
3) System should have low latency
Estimate the scale of the system you are going to design...
Lets assume that we have around 10000 people in an organization and the current product is supporting 100 such organization each user
makes around 100 messages in a day then total number of messages =1000*100*100=10^8 messages in a day
So number of request served in a second=10^8/10^5=10^3
Let's assume a server takes a 0.01 seconds to serve a request then number of requests served in a second =1/0.01=100
So 100 requests are served in a second by a single server =1000/100=10
Define what APIs are expected from the system...
/message ->
RequestBody
{
messageText=“”,
messageFrom=“”,
messageTo=“”
}
This api is used in 1-1 chats to message to people
/messageGroup
RequstBody
{
messageText=“”
groupId=“”
}
This API is used to add a message in a particular group
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...
Chats are both read and write heavy
we can use nosql database like mongodb which offeres flexible schema which can be used to store messages with emojis,gif and other things for storing videos we can use a blob storage like Aws s3 or azure blob storage and for storing the metadata we can use sql database like oracle or MySQL
The database scheme for storing the message in database like mongodb is
{
_id=“”
messageText=“”,
messageId=“”
from=“”
to=“”
gif=“”// this will store the link of the emoji which can be stored in the s3
}
The database schema for storing video metadata is
videoId video name meetingId recordedby
This table will store the videoId, video name,meeting Id, and recorded by
each recorded by field is a foreign of key of users table which will store the users details.
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...
When a user tries to message another user a websocket connection is established between the users using which users can message each other the messages are in turn stored in mongodb database which helps in durability and maintaining history of the message for group chats each user will be establishing connection other user and once user adds a message in a group the message is pushed to all the users within the group and the same is stored in mongodb database which helps in maintaing history of the data. For uploading the file each files is first broken into chunks and then transferred to the server where they are agreegated and then retrieved or we can upload the file to a blob storage like Aws s3 and then retireved from s3 for video streaming we can use protocols like hls which supports adaptive bit rate streaming as there can be many people on the same video call so we cannot use protocols like webrtc the video chunk can be transcoded into various formats and can be stored in the blob storage like Aws s3 which helps to stream the video at a later point of time
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...
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...
When a user tries to message another user a websocket connection is established between the users using which users can message each other the messages are in turn stored in mongodb database which helps in durability and maintaining history of the message for group chats each user will be establishing connection other user and once user adds a message in a group the message is pushed to all the users within the group and the same is stored in mongodb database which helps in maintaing history of the data. For uploading the file each files is first broken into chunks and then transferred to the server where they are agreegated and then retrieved or we can upload the file to a blob storage like Aws s3 and then retireved from s3 for video streaming we can use protocols like hls which supports adaptive bit rate streaming as there can be many people on the same video call so we cannot use protocols like webrtc the video chunk can be transcoded into various formats and can be stored in the blob storage like Aws s3 which helps to stream the video at a later point of time
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...
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...
When a user tries to message another user a websocket connection is established between the users using which users can message each other the messages are in turn stored in mongodb database which helps in durability and maintaining history of the message for group chats each user will be establishing connection other user and once user adds a message in a group the message is pushed to all the users within the group and the same is stored in mongodb database which helps in maintaing history of the data. For uploading the file each files is first broken into chunks and then transferred to the server where they are agreegated and then retrieved or we can upload the file to a blob storage like Aws s3 and then retireved from s3 for video streaming we can use protocols like hls which supports adaptive bit rate streaming as there can be many people on the same video call so we cannot use protocols like webrtc the video chunk can be transcoded into various formats and can be stored in the blob storage like Aws s3 which helps to stream the video at a later point of time
Explain any trade offs you have made and why you made certain tech choices...
By using mongodb the consistency will sufffer as mongodb does not provide consistency guarantee we can mitigate this by using quorams
Hls might not be suitable protocol as it introduces latency
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?