How the server works
The federation's processes, HTTP paths, where data lives and what makes up a federation's identity.
Request path
app ──HTTPS / WSS──▶ proxy (Caddy) ──┬─ /identity/* ──▶ Keycloak
├─ /app/* ──▶ web client
├─ /push/* ──▶ push relay
└─ everything else ──▶ federation server ──▶ PostgreSQL
│ └──────▶ data directory
├── SFU (HTTP control inside Docker)
devices ──UDP──▶ TURN, SFU (call ports, bypassing the proxy)The proxy terminates TLS and passes requests to the server over plain HTTP inside Docker (the
--behind-tls-proxy option). Calls bypass the proxy: devices reach TURN and the SFU directly over
UDP (calls).
The app's connection
The app opens the WebSocket wss://<domain>/comon and, inside TLS, sets up a Noise session with the
server's key. Every request of the app and every live update goes over this connection. Before the
first connection the app reads the federation document:
GET https://<domain>/.well-known/comon-federation{
"version": 1,
"federation_id": "comon-1a2b3c4d5e6f",
"endpoint": "wss://chat.example.org/comon",
"server_public_key": "<Noise key, base64url>",
"identity_issuer": "https://chat.example.org/identity/realms/comon",
"display_name": "Our federation"
}The app remembers the server's key and stops connecting if it ever changes.
The server's HTTP paths
| Path | What is there |
|---|---|
/comon | The apps' WebSocket |
/.well-known/comon-federation | The federation document; answers any site (CORS) so web clients can find other federations |
/auth/oidc/start, /auth/oidc/callback | OIDC sign-in |
/u/<name>, /join/<code>, /call/<code> | Link pages for browsers (web client and links) |
/rules, /child-safety, /delete-account | The federation's public pages (federation settings) |
/.well-known/apple-app-site-association, /.well-known/assetlinks.json | Opening links in the apps, when --apple-app-id or --android-app is set |
/bot/v1/<method> | HTTP Bot API |
/health | The process is alive; does not touch the database |
/ready | Ready to serve: the database answers and its schema matches (operations) |
Where data lives
| Where | What |
|---|---|
PostgreSQL 17, database comon | Everything except media bytes: the federation, access, bots and messaging schemas, and a module_<name> schema per module |
Data directory (--data, the federation volume) | The Noise key noise-server-key and media in media/ (or --media-dir) |
The postgres volume | PostgreSQL's files. In the ready-made stack Keycloak's database lives there too |
The caddy volume | Caddy's certificates |
The state directory .local/mvp | Configuration, passwords, keys, Compose files |
The database and the media belong together: media rows in the database refer to files on the
volume, and the comon-media-volume.json file in the media directory names the volume the database
is bound to. A server started with its database on another or empty volume refuses to start with
MediaVolumeMismatch.
The server never changes the database schema itself. A separate migrate_database command applies
it, and the ready-made stack runs it before the server (upgrading).
One writer
The server takes a writer lock in the database: a second server on the same database will not
start while the first one runs. The offline commands (federation_admin, reset_profile_password,
install_system_stickers) take the same lock, so stop the server before running them
(operations).
To spread connections over several machines you put gateways in front of the server, but still only one process may write to the database (scaling).
The federation's identity
A federation is defined by its ID (--federation-id, a random comon-… in the ready-made
stack) and the Noise key in its data directory, not by its domain. Apps remember the key on
their first connection.
- Lose the key and devices can no longer connect. The server refuses to start without a key when the database has authorized devices, so it never issues a new key silently.
- Keep the ID and the key in your backups (backups).
- The domain can change as long as the ID and the key stay (moving).
Modules
Parts of the server with their own storage plug in as modules: each has its own database schema and
background jobs. The --modules option limits which modules a process serves. The current build has
no modules with storage of their own; speech recognition is part of the core.