Skip to content

System Architecture ​

Last updated

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:

Select data flow to inspect
  1. Browser / Client
  2. Nginx
  3. Chirp Go Service
  4. SQLite

HTTPS requests pass through the reverse proxy. The Go service verifies account and device eligibility, reading and writing member and room admission records.

Service Network & Component Topology
Clients & BrowsersBrowserRegister · Passkey · AdminNative ClientsmacOS · iOS · AndroidWindows · Local MLSE2EE BoundaryVoice / Chat / FilesBundled SWAG / NginxTLS Termination443/TCP HTTPS & WSS80/TCP (HTTP-01 opt.)Block /twirp & /internalRate-limit /authorizationBackend Services & StorageChirp Go (app :18115/TCP)Passkey · /admin/ · /v1/ API · SSEAuth /authorization/v5/ · Group HubEncrypted Attachments · AdmissionsLiveKit SFU (:7880/TCP)WSS Signaling (/rtc) · 7882/UDP MediaTURN, TCP fallback & ext IP disabledchirp_datachirp.db · auth.db · filesmedia-keys & logskeys.json · 7d logs443/TCPHTTPS/WSSexcept /rtc/rtc/*RPC7882/UDP direct media (bypasses Nginx, E2EE encrypted frames)
Bundled Nginx route: Compose runs 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 EntryCore Responsibility
CLI Entrypoint → App WiringInitializes SQLite storage, LiveKit admin client, and three background sweeps; mounts all HTTP handlers plus admin CLI commands.
Passkey Auth · Admin UI · Embedded WebServes registration, login, phone QR /device approval, and /admin/ pages directly from Go embed assets.
Core REST API · SQLite StoreDiscovery, profiles, rooms, attachments, and devices. Storage validates login state, device eligibility, and room entries atomically inside SQLite write transactions.
V5 Identity · Authorization ServiceCertificate chains, signature domains, append-only revocation logs, and nonce-bound signed history snapshots.
Group Coordinator · Action ValidatorTracks active room rosters, keying phases, and smooth rotation; relays KeyPackage, Welcome, confirmations, and issues 3s media leases.
Media Room Service · DirectoryMints 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 ​

From Discovery to Voice: Five-Stage Security Chain
ParticipantsClient → app
Key EndpointsGET /v1/client-config
Credentials & TTLPlatform, version & build headers

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 ​

  1. Version policy & endpoints: Clients query GET /v1/client-config with X-Chirp-Platform, X-Chirp-Version, and X-Chirp-Build. The server validates platform minimums and returns passkey_origin, API endpoints, and update policy. Discovery Handler · Version Check
  2. Passkey sign-in & S256 PKCE: Native clients complete WebAuthn via browser callback (1m auth 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.
  3. Device key proof, Bearer & resumption issuance: First-time accounts generate a root key and export .chirpkey; additional devices restore .chirpkey or 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 sending X-Chirp-Login-Resumption: 1 also receive a resume_token to exchange for a rotated Bearer after process restarts via /api/client/resume/challenge → /complete (Chirp login resumption v1 signature) under the exact same deadline. Passkey Server · Login Store · Resumption Store
Native Client Authentication: Browser PKCE vs. Mobile QR
1

S256 PKCE Challenge

Client generates code_verifier and state, opens system browser at passkey_origin.

2

WebAuthn Verification

User authenticates via Face ID / Touch ID / Windows Hello; server issues a 1-min code.

3

Platform Callback & Handoff

Redirects to cn.youzifeile.chirp*://auth/callback (Windows polls /windows-handoff up to 60s).

4

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

  1. Preflight password check: Before switching rooms, clients send password + join_sequence to POST /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
  2. Atomic join & media JWT: Submitting the Proof to join transitions the room entry atomically and returns entry_id, livekit_url, and a short-lived LiveKit JWT. Entry validity stays at 30 seconds, renewed via group join or 2s heartbeat ticks.
  3. 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
Group Key Establishment State Machine & Verification Hold
Pre-Gate: Unverified Device Present → Control-Only Session (No Transition Timeout)Only after all peers mutually verify SAS & fresh snapshots do clients submit KeyPackages to start the 12s timer.1. collectingCollect signed bindings& 120s KeyPackages2. welcomingLeader batches Add& publishes Welcome3. confirmingVerify roster & install32B sender keys first4. ready3s media leases active2s heartbeat · 60s rotatePeer join/leave · 6s heartbeat loss · 12s timeout → Retire keys & advance generation

Server Route & Auth Matrix ​

Caller & Path PrefixAuthentication & Security RulesKey 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 ​