SchizoFlipSchizoFlip/Docs/Architecture

Architecture

Architecture Updated 2026-10-16 · Audience: developers & operators

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.

Red line: single broadcast source, SSE fanout. Clients subscribe, they don't self-serve. This keeps all language channels perfectly in sync.

Broadcast & Sync

ConceptContract
Ref (sentence-internal)audio.currentTime or OA.elapsed + clock — always relative to the current sentence
Offsetreported by the renderer via api.setOffset(rr.at) — the sentence's start on the host axis
Sentence gapdefault 0.6s (SF_SENTENCE_GAP env, test override oa._SENTENCE_GAP=0.0)
Pausethe 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:

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.