Files
system-design-101/data/guides/how-do-we-design-a-chat-application-like-whatsapp-facebook-messenger-or-discord.md
Kamran Ahmed ee4b7305a2 Adds ByteByteGo guides and links (#106)
This PR adds all the guides from [Visual
Guides](https://bytebytego.com/guides/) section on bytebytego to the
repository with proper links.

- [x] Markdown files for guides and categories are placed inside
`data/guides` and `data/categories`
- [x] Guide links in readme are auto-generated using
`scripts/readme.ts`. Everytime you run the script `npm run
update-readme`, it reads the categories and guides from the above
mentioned folders, generate production links for guides and categories
and populate the table of content in the readme. This ensures that any
future guides and categories will automatically get added to the readme.
- [x] Sorting inside the readme matches the actual category and guides
sorting on production
2025-03-31 22:16:44 -07:00

39 lines
1.4 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
---
title: "Designing a Chat Application"
description: "Explore the architecture of chat apps like WhatsApp and Messenger."
image: "https://assets.bytebytego.com/diagrams/0134-chat-app.jpeg"
createdAt: "2024-03-10"
draft: false
categories:
- how-it-works
tags:
- architecture
- messaging
---
![](https://assets.bytebytego.com/diagrams/0134-chat-app.jpeg)
The diagram below shows a design for a simplified 1-to-1 chat application.
## User Login Flow
* 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.
## Messaging Flow
* 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.
* Step 5: The chat message is sent to the message sync queue to sync to Bobs chat service.
* Step 6: Before forwarding the messaging, the message sync service checks Bobs presence:
* If Bob is online, the chat message is sent to chat service B.
* If Bob is offline, the message is sent to the push server and pushed to Bobs device.
* Steps 7-8: If Bob is online, the chat message is pushed to Bob via the web socket.