Architecture
Overview
SchizoFlip is built around one broadcast source + SSE fanout. A single orchestrator (onair) sequences segments; every channel is a thin client that renders the same stream. This is the architectural red line: clients never pull their own playlists.
Broadcast & Sync
| Concept | Contract |
|---|---|
| Ref (sentence-internal) | audio.currentTime or OA.elapsed + clock — always relative to the current sentence |
| Offset | reported by the renderer via api.setOffset(rr.at) — the sentence's start on the host axis |
| Sentence gap | default 0.6s (SF_SENTENCE_GAP env, test override oa._SENTENCE_GAP=0.0) |
| Pause | the local clock returns null → the sync engine freezes the frame (not a mute) |
SSE Event Stream
/events → {kind:"onair", item:{...}} sentence broadcast
{kind:"battle", target:[-1,1]} tug-of-war meter
{kind:"switch"|"topic", ...} topic change
{kind:"batch", events:[...]} batched fanout
Language Matrix
Each language is an independent product, not a translation. ZH is the clean base; EN and JA are forks with their own casts, voices, topics and deployments. New channels plug into the matrix via:
- Cast: per-language cast JSON (persona + voice mapping)
- Voices: language-aware defaults (
SF_LANG_DEF_VOICE) - Topics: language-filtered topic pools + real news feeds
- Deployment: independent service + domain per channel
Pluggable Renderer
The renderer is chosen by config (effects.renderer): jizura (default) / subtitle / mates. The TV contract is stable — tvRendererPush/Clock/Tick dispatch by renderer, so a new visual engine slots in without touching the stream.
Authentication
Standardized sign-in with Google / Discord / GitHub / Twitter (each an independent bool switch). PKCE + state, httpOnly cookie sessions, unified account model across channels. enabled=false → full anonymous mode.
BGM
Background music is a per-segment enhancement: a bgm.py store (mp3 + index), topic/cast/keyword matching, an admin library with drag-drop upload, and a per-viewer mute. MIDI is stored but needs a SoundFont to render.
SchizoFlip