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 see

Wails 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.SetPinned and 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
  1. whatsmeow decrypts a message and hands it to the manager.
  2. 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.
  3. whatsmeow acknowledges the message to the server only after ingest succeeded. If the write fails, the server delivers the message again.
  4. 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 / failed

Delivered and read come back later as receipts and move the ticks.

Storage

Two SQLite files live in the data folder.

  • session.db belongs to whatsmeow: keys, device identity, contact names from the phone. WhatsZori never changes its schema.
  • whatszori.db is 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