Architecture
A map of the code, for when you want to change something and need to know where it lives.
Two halves
WhatsZori
├── main.go, internal/ Go: WhatsApp, storage, privacy, the desktop shell
└── frontend/ React + TypeScript: everything you seeWails runs the interface in the system's web view and connects it to Go in two directions:
- Bound services. Go methods the interface calls as async functions:
Messages.SendText,Chats.SetPinnedand so on. - Events. Go pushes these to the interface: a new message, a status change, a reaction.
The interface only talks to Go through one TypeScript interface, Backend. A mock implements it too, so the interface runs in a plain browser with made-up chats.
Go packages
| Package | |
|---|---|
internal/app |
The desktop shell: windows, tray, notification window, asset routes |
internal/core |
Wires everything below together; start, stop, settings |
internal/wa |
The whatsmeow wrapper: connecting, logging in, sending |
internal/ingest |
Turns whatsmeow events into database rows and interface events |
internal/privacy |
The only way out for presence, typing and receipts |
internal/antispam |
The rate limits in front of every send |
internal/store |
Opens the database and runs its migrations; repo/ has the queries |
internal/media, avatar |
Download and serve attachments and profile pictures |
internal/notify |
Desktop notifications: the rules, plus Windows and freedesktop backends |
internal/export |
Chat export to HTML, JSON and text |
internal/services |
The services bound to the interface |
internal/domain |
The data structures the interface sees |
internal/events |
Event names and the batching emitter |
A message coming in
WhatsApp → whatsmeow → wa.Manager → ingest → SQLite (one transaction)
└→ after commit → events → interface- whatsmeow decrypts a message and hands it to the manager.
- Ingest normalises the sender (WhatsApp has two kinds of ids for people), writes everything in one transaction, and only then queues events for the interface.
- whatsmeow acknowledges the message to the server only after ingest succeeded. If the write fails, the server delivers the message again.
- Events are batched every 50 ms, so a history sync with thousands of messages becomes a few dozen updates.
A message going out
interface → Messages.SendText → connected? → anti-spam → privacy gate
→ stored as "pending" → shown at once
→ sent in the background → sent / failedDelivered and read come back later as receipts and move the ticks.
Storage
Two SQLite files live in the data folder.
session.dbbelongs to whatsmeow: keys, device identity, contact names from the phone. WhatsZori never changes its schema.whatszori.dbis WhatsZori's own.
| Table | |
|---|---|
chats |
One row per chat: name, pinned, archived, muted, unread, favourite |
contacts |
Names from the phone and push names |
messages |
Text, kind, reply, status, the deletion and edit columns, and the original protocol message |
message_edits |
Every version of an edited message |
media |
What's needed to download an attachment later, and where it's stored |
reactions, receipts |
Per person |
poll_votes |
The latest vote of each person on each poll |
status_seen |
Which statuses were opened here |
messages_fts |
The full-text search index |
chat_lists, group_events |
Your own lists; membership history |
extensions, plugin_settings, plugin_storage |
Plugins |
Migrations are numbered SQL files in internal/store/migrations, applied in order. Settings aren't in SQLite: they're in settings.json.
The privacy gate
Presence, typing, read receipts, "played" receipts and status views are sent only by internal/privacy. It applies ghost mode in one place, so no feature can forget to. A test parses every Go file and fails if anything else calls those whatsmeow methods.
What leaves your computer lists exactly what the gate lets through.
The interface
| Folder | |
|---|---|
src/api |
The Backend interface, the Wails implementation and the mock |
src/stores |
State, in zustand stores: chats, messages, settings |
src/features |
Screens and their parts: chat list, conversation, settings, statuses |
src/ui |
Small shared components: buttons, menus, dialogs |
src/theme, src/themes |
Tokens, the theme manager and the built-in themes |
src/plugin-core |
Slots, the plugin loader and the plugin context |