Course Content
Data Structures & Algorithms
Full Stack Web Development
Understanding and playing with DOM (Document Object Model)
0/2
MERN project
0/2
Low Level System Design
LLD Topics
High Level System Design
Fast-Track to Full Spectrum Software Engineering
Class Diagram of WhatsApp (Explanation)

Overview:

 

A class diagram in UML (Unified Modeling Language) helps model the static structure of a system by showing its classes, attributes, operations (methods), and the relationships among objects. For WhatsApp, this diagram focuses on users, messaging, media handling, group management, and calling features.



Key Classes and Their Responsibilities:

1. User

Attributes:

  • userId: String
  • name: String
  • phoneNumber: String
  • status: String
  • lastSeen: DateTime

 

Methods:

  • sendMessage(msg: Message): void
  • makeCall(receiver: User, type: CallType): void
  • updateStatus(status: String): void


2. Message

Attributes:

  • messageId: String
  • sender: User
  • receiver: User
  • content: String
  • timestamp: DateTime
  • messageType: Enum (TEXT, IMAGE, VIDEO, DOCUMENT)

 

Methods:

  • encrypt(): void
  • decrypt(): void


3. Chat

Attributes:

  • chatId: String
  • participants: List<User>
  • messages: List<Message>

 

Methods:

  • addMessage(msg: Message): void
  • deleteMessage(msgId: String): void


4. GroupChat (inherits from Chat)

Attributes:

  • groupName: String
  • admin: User

 

Methods:

  • addUser(user: User): void
  • removeUser(user: User): void
  • assignNewAdmin(newAdmin: User): void


5. Call

Attributes:

  • callId: String
  • caller: User
  • receiver: User
  • startTime: DateTime
  • endTime: DateTime
  • callType: Enum (VOICE, VIDEO)

 

Methods:

  • startCall(): void
  • endCall(): void


6. Media

Attributes:

  • mediaId: String
  • fileType: Enum (IMAGE, VIDEO, AUDIO, DOCUMENT)
  • filePath: String
  • uploadedBy: User

 

Methods:

  • upload(): void
  • download(): void


Relationships:

  • User ↔ Chat: Many-to-many (a user can have multiple chats, and each chat can involve multiple users)
  • Chat → Message: One-to-many (each chat has a list of messages)
  • Message ↔ User: Each message has one sender and one receiver (or many in group)
  • GroupChat ⊂ Chat: Inheritance (GroupChat is a specialized form of Chat)
  • User ↔ Call: A user can initiate or receive many calls
  • Message → Media: A message can be associated with a media file (optional)


Teaching Tips:

  • Emphasize the separation of concerns: messaging logic in Message, media management in Media, and user behavior in User.
  • Highlight the use of inheritance between Chat and GroupChat.
  • Point out associations and multiplicity (e.g., one user ↔ many chats).
  • Discuss how methods are tied to real-world features (like makeCall() or encrypt()).
0% Complete
WhatsApp Icon

Hi Instagram Fam!
Get a FREE Cheat Sheet on System Design.

Hi LinkedIn Fam!
Get a FREE Cheat Sheet on System Design

Loved Our YouTube Videos? Get a FREE Cheat Sheet on System Design.