Creating a Scalable and Secure Chat App - System Design Overview

Learn about the system design of a chat app including features, real-time messaging, high traffic handling, and storage needs.

00:00:00 Design a chat app with essential features like one-on-one and group chat, read receipts, online status, notifications, and media sharing. Ensure low latency, reliability, scalability, and end-to-end encryption in both mobile and desktop clients.

📱💻 A chat application like Facebook Messenger or WhatsApp should have one-on-one and group chat, read receipts, online status, and multimedia sharing for both mobile and desktop clients.

⚡🔒 Low latency and high reliability are crucial for a real-time chat application, along with end-to-end encryption and client-initiated connections.

📚🔍 The chat app needs to store chat history, handle large amounts of data including text, photos, and videos, and support notifications for new messages.

00:01:28 Learn about system design for a chat app, including the use of the WebSocket protocol and long polling for real-time messaging. Plan for high traffic and storage needs.

1️⃣ The video discusses the use of websocket protocol for a chat app, as it allows for an open connection between server and client.

2️⃣ Another option mentioned is long polling in HTTP, where the server keeps the client connection open until a timeout or threshold is reached.

3️⃣ In terms of capacity planning, it is estimated that the chat app will have around 18,000 messages per second and storage needs to handle billions of messages per day.

00:02:57 This video discusses the system design of a chat application, including the required storage for messages and the API calls for sending and receiving messages.

WhatsApp and Facebook Messenger handle billions of messages, requiring a storage capacity of 75 petabytes.

The two main API calls are sending messages and getting messages, with parameters such as user IDs, text, screen size, and timestamp.

The system design includes services such as messaging, relay, group, session, last scene, and asset.

00:04:26 Learn how a messaging service works, including session management, message storage, and group messaging. Explore the use of various databases and storage services.

💬 The messaging service uses a session service to identify and send messages to users.

📥 If a user is offline, the message is temporarily stored by the relay service until it can be delivered.

📅 The session service stores timestamps of user activity to track online status and differentiate between user and application activity.

🖼️ Asset services are used to store and retrieve multimedia files in a storage system like AWS S3.

👥 The group messaging service publishes messages to all users associated with the same group ID.

00:05:57 This video discusses the system design of a chat app and focuses on group messaging and database schema. It explains the use of RDBMS and NoSQL databases, as well as the tables used for users, groups, unsent messages, last seen, and sessions.

📌 The session service identifies the server to which each user is connected.

📚 The choice of database can be a relational database management system (RDBMS) or a hybrid database with NoSQL.

💬 Group chats have a separate database and each group has a unique group ID with user mappings.

00:07:27 A chat app system design overview showing how messages are sent, received, and stored, with emphasis on encryption and compression of media files.

💬 The chat app tracks active users and stores messages in a queue or Kafka topic.

📩 Group message handler sends messages to individual machines through websockets.

🔒 Media files sent over the chat are compressed, encrypted, and stored in the server's database.

00:08:58 This video discusses the design of a chat app and how it handles image sharing. Images can be uploaded to a server and downloaded by users. Another method involves compressing the image and storing it in a blob store. No right or wrong design.

📷 Images are uploaded to a server and assigned an ID, which can be used to search and download the image.

📱 Another method is to compress the image on the sending device and send it to the asset service.

🔒 The asset service stores media and image files in an S3 bucket, with links to the file locations stored in a database.

Summary of a video "Chat App | WhatsApp | Facebook Messenger | System Design" by ByteMonk on YouTube.

Chat with any YouTube video

ChatTube - Chat with any YouTube video | Product Hunt