a) createChat()
b) sendMessage()
methods used for group messaging
c)modifyParticiapants
methods used for receiving the chat
d)newMessageReceived
e) updateChat
For a chat system, the user might want to view the chat history when logged in, which means that, we need to store the chat details in the system. We also need to store further details like participants of a chat (could be 1-1, or group chat)
The Read - Write ratio is 1:1 . The amount of data that we 'll be dealing with is enormous. on an average it could be about 500 gb of data a day. Therefore, for the chat history and messages, we will be using a NoSQL Key-value store, something like DynamoDB. Key-value stores provide low latency to access the data.
1) Chat table - chatid, chat Metadata, created at
2) Messages for 1-1 chat - message id, message from, message to, content, timestamp.
3) Messages for group chat - channel_id, message_id, content, timestmap
4) ChatParticipant - chat_id, participant_id -> this table can fetch all the participants for a specific chat id.
For all the other user information, user settings and friends list etc, we can use a relational database, that will be well suited for this.
The main components for the chat system are
For a 1-1 Chat.
For a Group chat,
Horizontal scaling across all servers.
Sharding in the NoSQL database - KV store, the channel id is parition key in case of group messages, and the pariticipant id is parition in case of chat participant information.