# medhansh223/whatsapp architecture

> Architecture diagram of the GitHub repository medhansh223/whatsapp, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-11-15). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/medhansh223/whatsapp
- Repository: https://github.com/medhansh223/whatsapp

## Overview

This is a header-only C++ command-line chat system. A client enters through the demo, which uses the singleton service to manage users and chats; the service resolves participants and delegates chat creation to the factory, then sends messages through the selected chat strategy. Chats retain message history and notify registered observers, while the service also exposes group administration and activity queries. The README documents group activity tracking; GroupChat’s implementation and main.cpp were not excerpted, so their internal calls are not mapped.

Main entry points: [`service/WhatsAppService.h`](https://github.com/medhansh223/whatsapp/blob/main/service/WhatsAppService.h) (WhatsApp service), [`strategies/Chat.h`](https://github.com/medhansh223/whatsapp/blob/main/strategies/Chat.h) (Chat interface), [`models/Message.h`](https://github.com/medhansh223/whatsapp/blob/main/models/Message.h) (Message model), [`factory/ChatFactory.h`](https://github.com/medhansh223/whatsapp/blob/main/factory/ChatFactory.h) (Chat factory)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_entry["Client entry"]
  node_demo["CLI demo<br/>[main.cpp]"]
end

subgraph group_coordination["Service and factory"]
  node_service["WhatsApp service<br/>[WhatsAppService.h]"]
  node_factory["Chat factory<br/>[ChatFactory.h]"]
end

subgraph group_conversation["Chat strategies"]
  node_chat["Chat interface<br/>[Chat.h]"]
  node_private["Private chat<br/>[PrivateChat.h]"]
  node_group["Group chat<br/>[GroupChat.h]"]
end

subgraph group_domain["Messaging domain"]
  node_user["User model<br/>[User.h]"]
  node_message["Message model<br/>[Message.h]"]
  node_chat_type["Chat type<br/>[ChatType.h]"]
  node_message_status["Message status<br/>[MessageStatus.h]"]
end

subgraph group_notifications["Notifications"]
  node_observer["Observer interface<br/>[MessageObserver.h]"]
  node_user_observer["User notifier"]
end

node_client(("Client"))

node_client -->|"runs"| node_demo
node_demo -->|"uses"| node_service
node_service -->|"manages users"| node_user
node_service -->|"creates chats via"| node_factory
node_service -->|"dispatches chat operations"| node_chat
node_factory -->|"selects by"| node_chat_type
node_factory -->|"creates"| node_private
node_factory -->|"creates"| node_group
node_private -->|"implements"| node_chat
node_group -.->|"implements"| node_chat
node_private -->|"records"| node_message
node_private -->|"sets status"| node_message_status
node_chat -->|"stores history"| node_message
node_chat -->|"notifies"| node_observer
node_service -->|"registers"| node_user_observer
node_user_observer -->|"implements"| node_observer
node_user_observer -->|"renders notification"| node_message
node_message -->|"contains sender"| node_user
node_message -->|"tracks status"| node_message_status

click node_demo "https://github.com/medhansh223/whatsapp/blob/main/main.cpp"
click node_service "https://github.com/medhansh223/whatsapp/blob/main/service/WhatsAppService.h"
click node_factory "https://github.com/medhansh223/whatsapp/blob/main/factory/ChatFactory.h"
click node_chat "https://github.com/medhansh223/whatsapp/blob/main/strategies/Chat.h"
click node_private "https://github.com/medhansh223/whatsapp/blob/main/strategies/PrivateChat.h"
click node_group "https://github.com/medhansh223/whatsapp/blob/main/strategies/GroupChat.h"
click node_user "https://github.com/medhansh223/whatsapp/blob/main/models/User.h"
click node_message "https://github.com/medhansh223/whatsapp/blob/main/models/Message.h"
click node_chat_type "https://github.com/medhansh223/whatsapp/blob/main/enum/ChatType.h"
click node_message_status "https://github.com/medhansh223/whatsapp/blob/main/enum/MessageStatus.h"
click node_observer "https://github.com/medhansh223/whatsapp/blob/main/observers/MessageObserver.h"
click node_user_observer "https://github.com/medhansh223/whatsapp/blob/main/observers/UserNotificationObserver.h"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_demo,node_client toneBlue
class node_service,node_factory toneAmber
class node_chat,node_private,node_group toneMint
class node_user,node_message,node_chat_type,node_message_status toneRose
class node_observer,node_user_observer toneIndigo
```

## Components

### Client entry

- [CLI demo](https://github.com/medhansh223/whatsapp/blob/main/main.cpp): `main.cpp`

### Service and factory

- [WhatsApp service](https://github.com/medhansh223/whatsapp/blob/main/service/WhatsAppService.h): `service/WhatsAppService.h`
- [Chat factory](https://github.com/medhansh223/whatsapp/blob/main/factory/ChatFactory.h): `factory/ChatFactory.h`

### Chat strategies

- [Chat interface](https://github.com/medhansh223/whatsapp/blob/main/strategies/Chat.h): `strategies/Chat.h`
- [Private chat](https://github.com/medhansh223/whatsapp/blob/main/strategies/PrivateChat.h): `strategies/PrivateChat.h`
- [Group chat](https://github.com/medhansh223/whatsapp/blob/main/strategies/GroupChat.h): `strategies/GroupChat.h`

### Messaging domain

- [User model](https://github.com/medhansh223/whatsapp/blob/main/models/User.h): `models/User.h`
- [Message model](https://github.com/medhansh223/whatsapp/blob/main/models/Message.h): `models/Message.h`
- [Chat type](https://github.com/medhansh223/whatsapp/blob/main/enum/ChatType.h): `enum/ChatType.h`
- [Message status](https://github.com/medhansh223/whatsapp/blob/main/enum/MessageStatus.h): `enum/MessageStatus.h`

### Notifications

- [Observer interface](https://github.com/medhansh223/whatsapp/blob/main/observers/MessageObserver.h): `observers/MessageObserver.h`
- [User notifier](https://github.com/medhansh223/whatsapp/blob/main/observers/UserNotificationObserver.h): `observers/UserNotificationObserver.h`

### Other components

- **Client**

## Connections

- Client → CLI demo: runs (evidence: `README.md`)
- CLI demo → WhatsApp service: uses (evidence: `README.md`)
- WhatsApp service → User model: manages users (evidence: `service/WhatsAppService.h`)
- WhatsApp service → Chat factory: creates chats via (evidence: `service/WhatsAppService.h`)
- WhatsApp service → Chat interface: dispatches chat operations (evidence: `service/WhatsAppService.h`)
- Chat factory → Chat type: selects by (evidence: `factory/ChatFactory.h`)
- Chat factory → Private chat: creates (evidence: `factory/ChatFactory.h`)
- Chat factory → Group chat: creates (evidence: `factory/ChatFactory.h`)
- Private chat → Chat interface: implements (evidence: `strategies/PrivateChat.h`)
- Group chat → Chat interface: implements
- Private chat → Message model: records (evidence: `strategies/PrivateChat.h`)
- Private chat → Message status: sets status (evidence: `strategies/PrivateChat.h`)
- Chat interface → Message model: stores history (evidence: `strategies/Chat.h`)
- Chat interface → Observer interface: notifies (evidence: `strategies/Chat.h`)
- WhatsApp service → User notifier: registers (evidence: `service/WhatsAppService.h`)
- User notifier → Observer interface: implements (evidence: `observers/UserNotificationObserver.h`)
- User notifier → Message model: renders notification (evidence: `observers/UserNotificationObserver.h`)
- Message model → User model: contains sender (evidence: `models/Message.h`)
- Message model → Message status: tracks status (evidence: `models/Message.h`)
