# tulir/whatsmeow architecture

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

- Interactive diagram: https://gitdiagram.com/tulir/whatsmeow
- Repository: https://github.com/tulir/whatsmeow

## Overview

whatsmeow is a Go client library for WhatsApp’s multidevice API. A consumer creates a client with a device store, connects and authenticates, then uses client APIs to exchange messages and manage chats; registered handlers receive events. The graph highlights transport, protocol encoding, persistent device/session state, app-state synchronization, and documented messaging and chat capabilities. Some feature modules were not sampled, so their links are dashed where the precise runtime caller is unverified.

Main entry points: [`client.go`](https://github.com/tulir/whatsmeow/blob/main/client.go) (WhatsApp client), [`send.go`](https://github.com/tulir/whatsmeow/blob/main/send.go) (Message sending), [`store/store.go`](https://github.com/tulir/whatsmeow/blob/main/store/store.go) (Device store API), [`socket/framesocket.go`](https://github.com/tulir/whatsmeow/blob/main/socket/framesocket.go) (WebSocket frames)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_connection["Connection and sessions"]
  node_client["WhatsApp client<br/>[client.go]"]
  node_transport["WebSocket frames<br/>[framesocket.go]"]
  node_handshake["Login handshake<br/>[handshake.go]"]
end

subgraph group_protocol["Protocol and events"]
  node_binary["Binary node codec<br/>[decoder.go]"]
  node_legacyproto["Legacy proto aliases<br/>[legacy.go]"]
  node_eventtypes["Event types<br/>[events.go]"]
end

subgraph group_features["Messaging and chat"]
  node_send["Message sending<br/>[send.go]"]
  node_receive["Message receiving<br/>[message.go]"]
  node_media["Media transfer<br/>[upload.go]"]
  node_groups["Group management<br/>[group.go]"]
  node_presence["Presence and receipts<br/>[presence.go]"]
end

subgraph group_state["Device and sync state"]
  node_appstate["App-state sync<br/>[decode.go]"]
  node_storeapi["Device store API<br/>[store.go]"]
  node_sqlstore[("SQL persistence<br/>[store.go]")]
  node_clientpayload["Login payload<br/>[clientpayload.go]"]
end

node_consumer(("Library consumer"))
node_whatsapp(("WhatsApp servers"))

node_consumer -->|"creates and uses"| node_client
node_client -->|"connects through"| node_transport
node_client -.->|"runs login"| node_handshake
node_transport -->|"exchanges frames"| node_whatsapp
node_client -->|"accepts device store"| node_storeapi
node_client -->|"dispatches events"| node_eventtypes
node_consumer -->|"handles events"| node_eventtypes
node_client -.->|"offers messaging"| node_send
node_client -.->|"receives messages"| node_receive
node_send -.->|"sends messages"| node_whatsapp
node_receive -.->|"receives messages"| node_whatsapp
node_send -.->|"supports media"| node_media
node_client -.->|"manages groups"| node_groups
node_client -.->|"exchanges presence and receipts"| node_presence
node_client -.->|"syncs app state"| node_appstate
node_appstate -->|"uses sync storage"| node_storeapi
node_sqlstore -->|"implements store API"| node_storeapi
node_client -.->|"configures login"| node_clientpayload
node_client -.->|"decodes protocol nodes"| node_binary
node_binary -.->|"uses protobuf types"| node_legacyproto

click node_client "https://github.com/tulir/whatsmeow/blob/main/client.go"
click node_transport "https://github.com/tulir/whatsmeow/blob/main/socket/framesocket.go"
click node_handshake "https://github.com/tulir/whatsmeow/blob/main/handshake.go"
click node_binary "https://github.com/tulir/whatsmeow/blob/main/binary/decoder.go"
click node_legacyproto "https://github.com/tulir/whatsmeow/blob/main/binary/proto/legacy.go"
click node_eventtypes "https://github.com/tulir/whatsmeow/blob/main/types/events/events.go"
click node_send "https://github.com/tulir/whatsmeow/blob/main/send.go"
click node_receive "https://github.com/tulir/whatsmeow/blob/main/message.go"
click node_media "https://github.com/tulir/whatsmeow/blob/main/upload.go"
click node_groups "https://github.com/tulir/whatsmeow/blob/main/group.go"
click node_presence "https://github.com/tulir/whatsmeow/blob/main/presence.go"
click node_appstate "https://github.com/tulir/whatsmeow/blob/main/appstate/decode.go"
click node_storeapi "https://github.com/tulir/whatsmeow/blob/main/store/store.go"
click node_sqlstore "https://github.com/tulir/whatsmeow/blob/main/store/sqlstore/store.go"
click node_clientpayload "https://github.com/tulir/whatsmeow/blob/main/store/clientpayload.go"

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_client,node_transport,node_handshake toneBlue
class node_binary,node_legacyproto,node_eventtypes toneAmber
class node_send,node_receive,node_media,node_groups,node_presence,node_whatsapp toneMint
class node_appstate,node_storeapi,node_sqlstore,node_clientpayload toneRose
class node_consumer toneIndigo
```

## Components

### Connection and sessions

- [WhatsApp client](https://github.com/tulir/whatsmeow/blob/main/client.go): `client.go`
- [WebSocket frames](https://github.com/tulir/whatsmeow/blob/main/socket/framesocket.go): `socket/framesocket.go`
- [Login handshake](https://github.com/tulir/whatsmeow/blob/main/handshake.go): `handshake.go`

### Protocol and events

- [Binary node codec](https://github.com/tulir/whatsmeow/blob/main/binary/decoder.go): `binary/decoder.go`
- [Legacy proto aliases](https://github.com/tulir/whatsmeow/blob/main/binary/proto/legacy.go): `binary/proto/legacy.go`
- [Event types](https://github.com/tulir/whatsmeow/blob/main/types/events/events.go): `types/events/events.go`

### Messaging and chat

- [Message sending](https://github.com/tulir/whatsmeow/blob/main/send.go): `send.go`
- [Message receiving](https://github.com/tulir/whatsmeow/blob/main/message.go): `message.go`
- [Media transfer](https://github.com/tulir/whatsmeow/blob/main/upload.go): `upload.go`
- [Group management](https://github.com/tulir/whatsmeow/blob/main/group.go): `group.go`
- [Presence and receipts](https://github.com/tulir/whatsmeow/blob/main/presence.go): `presence.go`

### Device and sync state

- [App-state sync](https://github.com/tulir/whatsmeow/blob/main/appstate/decode.go): `appstate/decode.go`
- [Device store API](https://github.com/tulir/whatsmeow/blob/main/store/store.go): `store/store.go`
- [SQL persistence](https://github.com/tulir/whatsmeow/blob/main/store/sqlstore/store.go): `store/sqlstore/store.go`
- [Login payload](https://github.com/tulir/whatsmeow/blob/main/store/clientpayload.go): `store/clientpayload.go`

### Other components

- **Library consumer**
- **WhatsApp servers**

## Connections

- Library consumer → WhatsApp client: creates and uses (evidence: `client.go`)
- WhatsApp client → WebSocket frames: connects through (evidence: `client.go`)
- WhatsApp client → Login handshake: runs login
- WebSocket frames → WhatsApp servers: exchanges frames (evidence: `socket/framesocket.go`)
- WhatsApp client → Device store API: accepts device store (evidence: `client.go`)
- WhatsApp client → Event types: dispatches events (evidence: `client.go`)
- Library consumer → Event types: handles events (evidence: `types/events/events.go`)
- WhatsApp client → Message sending: offers messaging
- WhatsApp client → Message receiving: receives messages
- Message sending → WhatsApp servers: sends messages
- Message receiving → WhatsApp servers: receives messages
- Message sending → Media transfer: supports media
- WhatsApp client → Group management: manages groups
- WhatsApp client → Presence and receipts: exchanges presence and receipts
- WhatsApp client → App-state sync: syncs app state
- App-state sync → Device store API: uses sync storage (evidence: `appstate/decode.go`)
- SQL persistence → Device store API: implements store API (evidence: `store/sqlstore/store.go`)
- WhatsApp client → Login payload: configures login
- WhatsApp client → Binary node codec: decodes protocol nodes
- Binary node codec → Legacy proto aliases: uses protobuf types
