C++ signaling · protobuf · LiveKit

Real-time communication, built from the wire up.

Kergit is a Discord-like text and voice platform built to explore the hard parts behind the interface: sessions, state, backpressure, reconnects, and server-owned voice.

Core
C++ / Bazel
Wire
Protobuf / WSS
Media
LiveKit / WebRTC
Client
Nuxt / Vue
session / 7f2a ready
01 →
AUTHaccess_token
0.0 ms
02 ←
STATE_SYNC3 hubs · 11 channels
14.2 ms
03 →
VOICE_JOINbuild-room
4.8 s
04 ←
VOICE_TOKENowner · node · resume
18.6 ms
browserC++ authoritymedia

Interactive product demo

Don’t just read about it. Click through it.

Switch channels, send a local message, join a voice room to open the call grid, spotlight a participant, toggle a simulated camera or screen share, and inspect the member list. It behaves like the product while staying entirely inside this page.

Simulation only — no account, server, microphone, WebRTC, or stored data.

kergit.local/channels/kergit-lab/genel
local demo
genel Kergit için ortak alan
Enter to send locally
Interactive browser simulation Try #cpp-core, then join Build room and click a tile to spotlight it.

Under the interface

The UI is the easy part. The contract beneath it is the project.

Every interaction enters a server-authoritative path. Media is delegated to LiveKit; application truth, permissions, recovery, and ownership stay in the C++ core.

Kergit high-level design Browsers reach Caddy over HTTPS and WSS. Caddy routes / and /api to the Nuxt server, /ws to the C++ signaling server, /livekit to the LiveKit cluster and /admin-api to the operator-only control HTTP server. Inside the C++ server a network stack authenticates sockets, an event pipeline with High and Low priority queues feeds worker threads and per-connection outboxes, services persist to PostgreSQL and use Redis for TTL-bound coordination, and the voice service mints LiveKit tokens. LiveKit webhooks return to the server on an internal port, are deduplicated in Redis and reconciled into voice state. Kergit — high-level design what is built · numbers follow a user from sign-in to a voice call 1–2 edge 3–5 signaling core 6–8 voice + media 9 operator BROWSERS 1 W Web client Nuxt 4 · Vue 3 · LiveKit A Admin client Nuxt · operator console 1 a. sign in → Supabase session b. open WSS, send AUTH first c. render STATE_SYNC snapshot d. apply STATE_DELTA updates e. VOICE_JOIN → token → LiveKit f. dropped → reconnect + resync BACKPRESSURE · PER CONNECTION 4 HIGH state, membership, voice LOW TYPING, VOICE_ACTIVITY a. outbox full → drop LOW b. HIGH evicts newest LOW c. nothing LOW → overflow d. 4 overflows → close 4409 client reconnects + resyncs e. voice: seq + ACK + resend JOIN VOICE 6 a. channel + hub membership b. other tab owns voice → verified kick + revoke c. stage intent + nonce (Redis) d. E2EE key: reuse or rotate 15 s debounce · keyring mod 16 e. node = least users + rooms/4 f. mint token · TTL 10 min → VOICE_TOKEN_ISSUED EDGE 2 Caddy TLS routing origin CORS CF client IP admin CIDR WEB-NODE Nuxt server SSR + /api /api/auth/* sign-in · refresh · session /api/chat/attachments upload · signed read URLs /api/chat/link-preview SSRF-hardened fetch C++ SIGNALING SERVER · AUTHORITATIVE Bazel · C++23 Network stack uWebSockets 3 origin check at upgrade · AUTH in 5 s or close 4403 JWT vs Supabase public JWK · decode + validate Envelope Event pipeline High / Low priority 4 inbound queue worker pool dispatcher outbox / conn outgoing worker outgoing queue Services app/services 5 session hub message invite presence audit Voice service session-owned 6 VoiceService · VoiceSessionManager · ChannelKeyService one voice owner per user (Idle → Owner) E2EE key per channel · fresh key on every rotation LiveKit token minted here · browser never mints one voice events sent reliably: seq + ACK + resend MANAGED Supabase Auth · Storage Auth issues the JWT the server verifies Storage: chat-attachments (private bucket) DURABLE · SCHEMA kergit_app PostgreSQL libpqxx profiles user_id → auth.users hubs UNIQUE (owner_id, lower(name)) hub_members PK (hub_id, user_id) · role channels type · position UNIQUE (hub_id, lower(name)) messages UNIQUE (channel_id, message_seq) idx (channel_id, seq DESC) message_attachments → storage object audit_events actor · hub · channel · time EPHEMERAL · EVERY KEY EXPIRES Redis redis++ invite:{token} ↔ invite_hub:{hub} 1 h voice:pending_join:{user} token + 10 s voice:resume_id:{user} 24 h voice:e2ee:channel:{id} AES-GCM 24 h voice:webhook_seen:{event} 24 h LiveKit cluster state (shared) OPERATOR ONLY · :8081 Control HTTP 9 /health /metrics/public · /metrics/snapshot /metrics/timeseries drop + slow-consumer counters reachable from ADMIN_ALLOWED_CIDR MEDIA PLANE · SFU LiveKit cluster 7 livekit-a :7880 livekit-b :7890 room = voice channel media: UDP/TCP straight to a node forwards E2EE-encrypted frames VOICE STATE Webhook + reconciler 8 POST server-node:8080/webhook · internal, not via Caddy a. dedupe event id in Redis (24 h) b. joined / left must match a staged intent + nonce c. reconcile 6 cases: periodic, on WS drop, on mismatch d. recovery-first: a WS drop never removes voice HTTPS WSS / /api /ws auth SQL invites voice /admin-api /livekit · signalling Twirp: list · remove webhook dedup reconcile every frame: Envelope { version, type, seq, payload } · High: state + membership, never silently dropped · Low: TYPING, VOICE_ACTIVITY · reliable voice frames: seq + ACK
Scroll sideways to explore the diagram →

One click, four boundaries

What “join voice” actually means.

Voice is not a direct browser-to-room shortcut. Kergit makes authorization and ownership explicit before media starts.

  1. 01
    VOICE_JOIN →

    Request

    The active browser session asks to enter a specific voice channel.

  2. 02
    AUTHZ ✓

    Authorize

    The C++ core validates membership and assigns voice ownership to one session.

  3. 03
    TOKEN ←

    Issue

    A narrow LiveKit token names the room, participant, permissions, and selected node.

  4. 04
    RECONCILE ↻

    Converge

    Webhooks, reconnect grace, and resume paths bring media and application state back together.

Engineering decisions

Hard paths made visible.

Kergit is a systems project disguised as a community app. These are the choices that make the prototype interesting beyond its interface.

01 load control

Backpressure is product behavior.

Per-connection outboxes and priority classes isolate slow consumers. Repairable signals can be dropped; authoritative mutations cannot.

HIGHstate + membership
HIGHvoice · seq + ACK
LOWactivity · droppable
LOWtyping · droppable
02 protocol surface

One envelope, different recovery semantics.

message Envelope {
  uint32 version = 1;
  Type   type    = 3;
  bytes  payload = 100;
}

STATE_DELTA  durable
RT_SIGNAL    transient
VOICE_JOIN   authorized
Read the protocol
03 voice ownership

A user can have many tabs. Voice has one owner.

tab Achat
tab Bvoice owner
mobilepresence
user / bilal

Takeover and resume revoke the previous owner deliberately instead of letting tabs race.

04 recovery

Disconnect is evidence, not truth.

A dropped WebSocket does not instantly erase a healthy media participant.

socket lostt + 0
grace windowt + 5s
resume or cleanupevidence

Honest boundary

The system is real. The page demo is deliberately not.

The repository contains the working backend, web and admin clients, Docker stack, metrics, tests, and voice lifecycle. This public page replaces live infrastructure with local UI behavior so anyone can explore it safely.

Read the architecture notes
CapabilityRepositoryThis page
Text channels + chat implementedsimulated
Voice authorization implementedexplained
LiveKit media integratednot connected
Session recovery implementedvisualized
Persistent data PostgreSQLnone

Built across the boundary

One project. The whole path.

Open source

The demo ends here. The implementation doesn’t.

Trace the protocol, inspect the queues, run the stack, or follow the voice lifecycle from request to reconciliation.