Architecture

Four programs with strict jobs, one local protocol between them, and no server of our own anywhere. A Tiny server is one you add, run by its owner.

Processes, and what each may never do

ProcessDoesNever
chatdAlways on, one per data directory (it holds chatd.lock). Answers its socket first, then reads the sessions. Holds the sessions, the network sockets, SQLite and the media cache. Call signalling. Decides what notifies, with the window closed.Decode media, link a codec or audio code, hold a member list or history in memory, fetch a link from a message, send anything you did not ask for.
mediadExists from “connecting” to the end of one call: Discord’s voice gateway, or a Tiny server’s WebRTC media over UDP or ICE-TCP. Opus. Discord seals the audio with DAVE. A Tiny call seals Opus and the one H.264 picture when the server offers e2ee_calls. Echo cancellation, noise suppression, audio devices. Also started briefly to play a voice message or a notification sound.Stay running after its call or sound, touch SQLite, the credential store or the chat socket. It speaks only to chatd, over stdin and stdout.
tinyclientThe window. Draws what chatd reports and decodes images for the rows on screen. Starts chatd when nothing answers.Talk to a network, read the database or the credential store, or block its main thread on a socket, file or decode.
tinyclient-loginOne sign-in window, then exits with the session on stdout.Stay running.

The local protocol

The window and chatd talk over a local socket: a Unix domain socket at chat.sock in the data directory, or the matching named pipe on Windows. Nothing listens on a network port. The one exception is a Tiny server sign-in: chatd listens on 127.0.0.1, at a port the system picks, for the browser’s one return, then stops.

chatd and mediad use the same framing over mediad’s stdin and stdout. Closing stdin is the hang-up. tinyclient-login prints its session as one line of JSON on stdout and says how it ended with its exit status.

The full contract is the code in crates/protocol, and the map of it is docs/architecture.md.

Storage

DataWhere
SessionsThe system credential store, service tinyclient, one item per network. Never in the database.
Accounts, conversations, people, messageschat.sqlite in the data directory, with a 1 MB page cache.
Media bytesmedia/<network>/<account>/, 500 MB, least recently used evicted first.
Signal statesignal/<account>.state: keys, sessions, contacts and groups, each value sealed with a key that only the credential store item holds.
Presence, typing, voice occupants, upload progresschatd’s memory, bounded, gone at restart.
Logscrash.log (cut at 256 KB) and chatd.log (cut at 4 MB at start), credentials redacted.
Window stateThe window’s own preferences file: last conversation, pane widths, scroll positions.

Retention: the newest 2,000 messages per conversation, and nothing older than 90 days unless you opened the conversation in that time. Pruned at start and daily.

Adapters

Each network is one adapter inside chatd, on its own thread, mapping the network’s model onto one shared one: Spaces (a server, workspace or team), groups, conversations, threads and messages. No network markup reaches the window.

NetworkBuilt onTLS
DiscordDiscord’s HTTP API and gateway websocket, written in this repositorySystem
SlackSlack’s web API and websocket, written in this repositorySystem
TeamsThe chat service and push channel of Microsoft’s Teams client, written in this repositorySystem
Telegramgrammers, a pure-Rust MTProto clientMTProto’s own encryption
Signalpresage, on libsignal-service-rs and Signal’s libsignalrustls, pinned to Signal’s certificate authority
MessagesThe same pairing messages.google.com uses, written in this repository. The phone stays the account.System
Tiny servertinyserver’s HTTP API and its live WebSocketSystem

“System” TLS is the operating system’s: Security.framework on macOS, SChannel on Windows, OpenSSL on Linux. Telegram and Signal run on one single-threaded async runtime each, created only when such an account exists or a sign-in begins.

Idle means idle

Calls

A call on Discord starts mediad, which connects to Discord’s voice servers itself, runs Discord’s end-to-end encryption (DAVE, through davey on OpenMLS) and encodes with Opus (libopus 1.3.1 transpiled to Rust, so no C toolchain). Every way a call can fail ends the same way: the reason stays on screen until dismissed, mediad is gone, and the network is told we left.

A call on a Tiny server is WebRTC to the server’s own SFU, through str0m in pure Rust: one audio stream out, one in for each other person, over UDP, or ICE-TCP on the same port where UDP is blocked. When the server offers e2ee_calls and every app in the call can do it, the client seals Opus and the one H.264 picture in an MLS group and leaves the one-byte NAL header clear. The server forwards that payload and does not seal video. Otherwise the call says encrypted to the server. A room that allows video shows one picture: a screen share, or one other person’s camera. The camera and screen share send on Windows, macOS and Linux. Echo cancellation, noise suppression and automatic gain come from sonora, a pure-Rust port of WebRTC’s audio processing, and default on. A Discord call carries a camera too, and Go Live is a connection of its own. Stage channels, Slack huddles, Teams meetings, Telegram calls and Messages calls open in that network’s own app.

Sizes

macOS arm64 release builds of 0.2.0, 2026-10-14, not measured again since; mediad has grown with Tiny server calls and audio processing. chatd includes Signal’s libraries. Memory measured 2026-10-13. Every budget: 07-budgets-and-risk.md.
ProgramBinaryMemoryRuns
chatd28 MB10 MB RSS signed in to DiscordAlways
tinyclient22 MB64 MB RSSWhile the window is open
mediad5.5 MBUnder 40 MB RSS in a call (test-asserted)During a call
tinyclient-login1.8 MBDuring a sign-in

Edit this page on GitHub