System Architecture
Chirp follows a three-tier architecture built around a lightweight control plane, a self-hosted SFU media relay, and client-owned end-to-end cryptography:
- Chirp Go Server (
app): Serves Passkey / WebAuthn authentication pages, the web admin console, REST/SSE APIs, the V5 authorization log, temporary attachment chunk storage, and the group key coordinator. - LiveKit SFU (
livekit): Forwards already-encrypted audio frames and encrypted reliable DataChannel payloads between room participants. - Four Native Clients: macOS, iOS, Android, and Windows store device private keys locally, compare peer SAS safety codes out-of-band, and derive content keys via OpenMLS (RFC 9420)—the server never accesses voice, chat, or attachment decryption keys.
Overall Topology & Core Data Flows
Click the interactive flow cards below to trace Sign-In & Room Entry, Encrypted Voice, and File Transfers across network boundaries:
- Browser / Client
- Nginx
- Chirp Go Service
- SQLite
HTTPS requests pass through the reverse proxy. The Go service verifies account and device eligibility, reading and writing member and room admission records.
app, livekit, and nginx (SWAG), automatically issuing and renewing TLS certificates via Certbot. Ports 18115 and 7880 communicate internally. Control APIs and WebSocket signaling enter on 443/TCP through your reverse proxy (bundled SWAG Nginx or external Nginx): /rtc routes to LiveKit (7880/TCP), while everything else routes to app (18115/TCP). Encrypted voice media travels directly over 7882/UDP to LiveKit. CHIRP_PUBLIC_ORIGIN anchors WebAuthn RP ID/Origin validation, client discovery URLs, and public signaling endpoints. Compose Config · Config Loader · Operations Reference
Server Codebase Index
| Module Entry | Core Responsibility |
|---|---|
| CLI Entrypoint → App Wiring | Initializes SQLite storage, LiveKit admin client, and three background sweeps; mounts all HTTP handlers plus admin CLI commands. |
| Passkey Auth · Admin UI · Embedded Web | Serves registration, login, phone QR /device approval, and /admin/ pages directly from Go embed assets. |
| Core REST API · SQLite Store | Discovery, profiles, rooms, attachments, and devices. Storage validates login state, device eligibility, and room entries atomically inside SQLite write transactions. |
| V5 Identity · Authorization Service | Certificate chains, signature domains, append-only revocation logs, and nonce-bound signed history snapshots. |
| Group Coordinator · Action Validator | Tracks active room rosters, keying phases, and smooth rotation; relays KeyPackage, Welcome, confirmations, and issues 3s media leases. |
| Media Room Service · Directory | Mints scoped short-lived LiveKit JWTs, invokes internal Twirp RPC to query/kick participants, and merges live roster occupancy. |
End-to-End Call Flow: From Discovery to Live Audio
The client fetches passkey_origin, service endpoints, and platform version policies. Clients below the minimum version are blocked with an update prompt.
Phase 1: Discovery & Passkey Authentication
- Version policy & endpoints: Clients query
GET /v1/client-configwithX-Chirp-Platform,X-Chirp-Version, andX-Chirp-Build. The server validates platform minimums and returnspasskey_origin, API endpoints, and update policy. Discovery Handler · Version Check - Passkey sign-in & S256 PKCE: Native clients complete WebAuthn via browser callback (
1mauth code; Windows also supports an up-to-60s exponential-backoff browser handoff loop at/api/auth/login/windows-handoff) or phone QR scan (3m), all bound with S256 PKCE. Exchange yields a 5-minute Identity Setup Grant. - Device key proof, Bearer & resumption issuance: First-time accounts generate a root key and export
.chirpkey; additional devices restore.chirpkeyor pair via QR. Clients sign a proof-of-possession challenge (/api/client/identity/challenge→/complete) to obtain a business Bearer (valid up to 20 hours, capped by device cert expiry) while atomically superseding prior login sessions. Clients sendingX-Chirp-Login-Resumption: 1also receive aresume_tokento exchange for a rotated Bearer after process restarts via/api/client/resume/challenge→/complete(Chirp login resumption v1signature) under the exact same deadline. Passkey Server · Login Store · Resumption Store
S256 PKCE Challenge
Client generates code_verifier and state, opens system browser at passkey_origin.
WebAuthn Verification
User authenticates via Face ID / Touch ID / Windows Hello; server issues a 1-min code.
Platform Callback & Handoff
Redirects to cn.youzifeile.chirp*://auth/callback (Windows polls /windows-handoff up to 60s).
5-Min Setup Auth → 20h Bearer
Client exchanges code + verifier at /api/client/exchange, then proves device key possession.
Phase 2: Room Authorization, Mutual Verification & Media Gating
Chirp enforces one active login per account, one active room entry per login. Each room entry creates a unique composite identity member_id.login_id.entry_id tying together database access, LiveKit participant identity, and OpenMLS group membership, guarded by monotonic join_sequence checks. Room Store
- Preflight password check: Before switching rooms, clients send password +
join_sequencetoPOST /v1/rooms/{room}/preflight(rate-limited to 5 failed attempts per 30 seconds per member/room). Valid passwords earn a 30-second signed Proof; invalid passwords leave any current call untouched. Preflight Source - Atomic join & media JWT: Submitting the Proof to
jointransitions the room entry atomically and returnsentry_id,livekit_url, and a short-lived LiveKit JWT. Entry validity stays at 30 seconds, renewed via groupjoinor 2sheartbeatticks. - Device trust & OpenMLS keying: Peers inspect each other's device certificate chains, fresh authorization snapshots, and pairwise SAS verification. Only after all members verify identical rosters, exchange confirmations, and acquire a 3-second media send permit do clients unlock audio capture, chat, and files. Group Hub · Shared Rust Core
Server Route & Auth Matrix
| Caller & Path Prefix | Authentication & Security Rules | Key Source |
|---|---|---|
Browser (/, /register, /device, /api/auth/) | WebAuthn challenges, strict Origin enforcement, HttpOnly; SameSite=Strict cookies; native setup APIs live under /api/client/. | Passkey Service |
Admin (/admin/, /admin/api/) | Active admin cookie + role check; same-origin checks on mutations; admin roles mutable solely via server CLI. | Admin Service |
Native clients (/v1/) | Public /v1/client-config; active Bearer required elsewhere; /v1/identity/signals relays origin-scoped opaque E2EE signals ≤ 64 KiB; attachments additionally check entry_id. | HTTP API · Social Relay |
Group coordinator (/v1/group/rooms/{room}/) | GET config validates Bearer; POST action / events require client Ed25519 request signatures and budgets. | Group Server |
Authorization log (/authorization/v5/) | POST append verifies device signatures & auth scope; POST snapshot signs nonce-bound history; full social bodies require device read proofs. | Authorization HTTP |
Health probes (/livez, /healthz, /authorization/healthz) | Process liveness (200), dual SQLite read/write (200), authorization SQLite readiness (204). | Top Router |
Directory updates stream server_id and revision over GET /v1/events SSE so clients fetch fresh GET /v1/state snapshots; group SSE also emits rotation_revision pulses for smooth key transitions. State API · Apple Sync
Persistence Layout & Single-Instance Scope
| Storage Path (Container) | Purpose & Policy |
|---|---|
/data/chirp.db (data volume) | Main SQLite DB (WAL mode, BEGIN IMMEDIATE, requires empty DB or exact schema 23) storing members, Passkeys, logins, resumption records (client_login_resumptions), rooms, policies, blacklists, and attachment state. Schema SQL |
/data/authorization.db (data volume) | Independent authorization SQLite log signed by CHIRP_AUTHORIZATION_KEY_FILE. Key Loader |
/data/attachments/ (data volume) | Temporary encrypted chunks; ineligible objects and orphans clean up on startup. Attachments |
/var/lib/chirp-media/keys.json (media-keys volume) | Auto-generated on first boot by app and mounted read-only into livekit. Key Gen |
/app/log/ (logs volume) | Rolling daily JSON Lines logs (7-day retention), or async streaming to VictoriaLogs. Logging |
::: note Why app must run as a single instance In-memory group state machines, active SSE connections, preflight HMAC secrets, and attachment recipient presence live inside the single app process, and SQLite WAL/SHM locking relies on local POSIX locks. Never horizontally scale multiple app containers against shared storage. :::
Cross-Platform Client Engineering
Explore each client's implementation, E2EE hooks, design system, and shared crates: Unified Design & Shared Core · Apple (macOS / iOS) · Android · Windows.
Further Reading
- Build & Verification: Server Build & Testing · Native Client Builds · Manual QA Checklist
- Protocols & Cryptography: Encryption & Boundaries · V5 E2EE Protocol · Authorization Signing Keys · Attachment Transport ·
.chirpkeyRecovery Format · Client Log Format
