8 Tweets 28 reads Jan 16, 2023
1/ How do we design a 𝐜𝐑𝐚𝐭 𝐚𝐩𝐩π₯𝐒𝐜𝐚𝐭𝐒𝐨𝐧 like WhatsApp, Facebook Messenger or Discord?
The diagram below shows a design for a simplified 1 to 1 chat application.
2/ π”π¬πžπ« 𝐋𝐨𝐠𝐒𝐧 𝐅π₯𝐨𝐰
πŸ”ΉStep 1: Alice logs in to the chat application and establishes a web socket connection with the server side.
πŸ”ΉSteps 2-4: The presence service receives Alice's notification, updates her presence, and notifies Alice's friends about her presence.
3/ 𝐌𝐞𝐬𝐬𝐚𝐠𝐒𝐧𝐠 𝐅π₯𝐨𝐰
πŸ”ΉSteps 1-2: Alice sends a chat message to Bob. The chat message is routed to Chat Service A.
πŸ”ΉSteps 3-4: The chat message is sent to the sequencing service which generates a unique ID, and is persisted in the message store.
4/ πŸ”ΉStep 5: The chat message is sent to the message sync queue to sync to Bob’s chat service.
5/ πŸ”ΉStep 6: Before forwarding the messaging, the message sync service checks Bob’s presence:
a) If Bob is online, the chat message is sent to chat service B.
b) If Bob is offline, the message is sent to the push server and gets pushed to Bob’s device.
6/ πŸ”ΉSteps 7-8: If Bob is online, the chat message is pushed to Bob via the web socket.
7/ πŸ‘‰ Over to you: How to sync the chat messages among Alice’s different devices?
8/ I hope you've found this thread helpful.
Follow me @alexxubyte for more.
Like/Retweet the first tweet below if you can:

Loading suggestions...