Education

Chat App | WhatsApp | Facebook Messenger | System Design

by ByteMonk

Share:

📚 Main Topics

  1. Functional Requirements of a Chat Application

    • One-on-one chat
    • Group chat functionality
    • Read receipts (double tick marks)
    • Online status sharing
    • Notification system for new messages
    • Multimedia sharing (images, videos, files)
  2. Technical Requirements

    • Low latency for real-time communication
    • High reliability and availability
    • Support for both mobile and desktop clients
    • Storage for chat history
    • Handling large amounts of data (text, photos, videos)
    • End-to-end encryption
    • Client-initiated connections using WebSocket protocol
  3. System Design Components

    • Messaging ServiceHandles sending and receiving messages.
    • Relay ServiceTemporarily stores messages for offline users.
    • Session ServiceManages user connections and server mappings.
    • Last Seen ServiceTracks user activity timestamps.
    • Asset ServiceManages multimedia file storage and retrieval.
    • Group Messaging ServiceManages messages sent to groups.
  4. Database Schema

    • Users table: user ID, username, contact number
    • Groups table: group ID, user IDs of group members
    • Unsent messages table: message ID, sender ID, receiver ID, content/media URL, timestamp
    • Last seen table: user ID, timestamp
    • Sessions table: user ID, server ID mapping
  5. Group Messaging Logic

    • Uses Kafka for message queuing and handling.
    • Group message handler retrieves user connections and sends messages accordingly.
  6. Media File Handling

    • Media files are compressed and encrypted on the sender's device.
    • Files are uploaded to a server, and links are sent to the receiver for download.

✨ Key Takeaways

  • Real-time chat applications require careful consideration of both functional and technical requirements.
  • WebSocket protocol is preferred for real-time communication due to its persistent connection capabilities.
  • Proper capacity planning is essential, especially when dealing with large user bases and high message volumes.
  • A hybrid database approach may be necessary to accommodate different data types and relationships.

🧠 Lessons Learned

  • There is no one-size-fits-all design; flexibility and adaptability to requirements are crucial.
  • Understanding the underlying technologies (like WebSockets and Kafka) is important for implementing efficient systems.
  • Security measures, such as end-to-end encryption, are vital in protecting user data in chat applications.
  • Effective communication and clarification of requirements with stakeholders (like interviewers) can lead to better design outcomes.

Transcript excerpt

0:00 in this video I'll design a chat app like Facebook Messenger or WhatsApp so let's get started following our regular system design template let's first figure out the key functional requirements of a chat application a regular chat application should have a one-on-one chat it should have a feature of group chat a read listed feature which means when you are sending messages to someone else you should be able to get the double tick mark you should be able to see the online status or share your online status with others there should be a provosting of

0:30 notification that is if there is a new message waiting for you in your chat there should be a pop-up notification and then you should be able to share multimedia data such as pictures videos give files and whatnot coming to the system requirements or the technical requirements one of the first things the most important thing for any real-time chat application or a real-time let's say stock broker application is low latency low latency is must for any real-time chat the system should be also

🔒 The full, searchable transcript is available with Pro.

🔒 Unlock Premium Features

This is a premium feature. Upgrade to unlock unlimited Q&A, transcripts, mindmaps, and translations.

🔒 Unlock Premium Features

Access to Chat is a premium feature. Upgrade now to unlock unlimited studying tools.

🔒 Unlock Premium Features

Access to Mindmap is a premium feature. Upgrade now to unlock unlimited studying tools.

🔒 Unlock Premium Features

Access to Translation is a premium feature. Upgrade now to unlock unlimited studying tools.

Get unlimited summaries, Q&A, transcripts and more with Pro

Upgrade to Pro

Suggestions

🔒 Unlock Premium Features

Access to AI Suggestions is a premium feature. Upgrade now to unlock unlimited studying tools.