How leoyuku/rcas works
1. Repository shape
This is a TypeScript monorepo for RCAS, an automated playout/control system. The active runtime lives in packages/backend, packages/frontend, and packages/core-lib. There is also a large gcloudignore/reference/sofie-core tree, which is a vendored reference copy of Sofie Core used as architectural inspiration and source material, not the primary application runtime.
2. Shared contract layer
packages/core-lib is the only intentional shared dependency between backend and frontend. It defines the canonical data models for rundowns, parts, pieces, timelines, and socket/event contracts. This enforces the repo’s boundary: backend and frontend do not depend on each other directly, only on shared contracts.
3. Backend top-level composition
packages/backend is the system brain. Its src/index.ts boots one of two execution styles: a monolith entrypoint or a microservice entrypoint. The backend also has adapters for local in-memory execution and gRPC, which suggests the same domain code can run either in-process or across process boundaries.
4. Backend shared infrastructure
packages/backend/src/shared centralizes cross-cutting concerns: configuration loading, structured logging, startup checks, shared event bus, and startup health validation. This keeps runtime environment handling out of the domain layers.
5. MOS/NCS connectivity boundary
modules/1_mos_connection is the protocol ingress layer. It handles MOS socket connections, XML/message parsing, and profile-specific MOS behavior, especially the supported profiles 0, 2, and 4. Its job is to accept newsroom/NCS updates and normalize them into the system’s internal ingest representation.
6. Ingest transformation
modules/2_ingest is the translation layer from MOS running orders into the internal rundown model. The main file, mos-to-rundown.ts, is a pure conversion boundary between editorial input and the domain engine. This is where inbound MOS structure becomes RCAS/IRundown data.
7. Domain engine and state machine
modules/3_domain_engine is the core of the architecture. It contains:
- a store for rundown state, socket serving, JSON persistence, and MOS caching
- an engine for rundown lifecycle, state loop, PartInstance management, timeline building, resolver/diff logic, and runtime crash recovery
This is the layer that implements the repo’s “single source of truth” concept: models plus time produce desired system state.
8. Timeline and diff pipeline
The engine is explicitly state-driven. Rundown/part data is turned into timeline objects, then resolved into a desired device state, then diffed against the last sent state to generate device commands. That makes the architecture predictive and reconstructable: current model + current time should be enough to rebuild the correct output state.
9. Playout control layer
modules/4_playout_controllers adapts abstract playout intent into device-specific commands. Today the concrete implementation is for Blackmagic Tricaster, via a client/driver pair that sends commands over WebSocket and retries with backoff. The abstraction also includes device config, execution strategy resolution, runtime overrides, and a pluggable device interface for future drivers.
10. Frontend role
packages/frontend is a React/Vite UI with Zustand state management. It presents rundown and playout control views such as preview/on-air/next, source cards, timing panels, and configuration screens. The frontend consumes backend contracts from core-lib and is primarily an operator console, not a source of business truth.
11. External integration points
The important external systems are MOS/NCS on the ingest side and Tricaster on the playout side. The repo also contains hooks for gRPC-based backend deployment, implying the system can be split into services later without rewriting the domain model.
12. Persistence and recovery
The backend persists rundown JSON, runtime snapshots, and config history under packages/backend/config-history. Crash recovery is part of the architecture, not an afterthought: runtime state is designed to be rebuilt from persisted rundown data plus current time. That is a key diagram boundary between ephemeral runtime state and durable state.
13. Support tooling
tools/quick-mos and tools/quick-mos-patch are validation and conversion utilities for MOS samples and diffs. They are not part of the runtime path, but they matter because they validate the MOS translation layer and help test protocol compatibility.
14. Operational identity
The repo is not a generic CRUD app. It is a deterministic, time-driven control system with a strict pipeline: protocol ingest → model translation → timeline/state resolution → device diff/dispatch → operator UI feedback. Any architecture diagram should emphasize those one-way data flows and the clear separation between editorial data, runtime state, and physical device control.
Main entry points: index.ts Backend entry · src Frontend app · mosModel MOS parser · mos-to-rundown.ts Ingest translate
Components 18
Active runtime
Primary RCAS application packages that make up the live system.
- Backend entry · Starts monolith or microservice execution styles and wires backend composition.
packages/backend/src/index.ts - Shared infra · Cross-cutting backend services for config, logging, startup checks, and event bus.
packages/backend/src/shared - Service adapters · Execution adapters that let backend domain logic run in-process or across process boundaries.
packages/backend/src/adapters - MOS ingress · Accepts MOS/NCS socket traffic and normalizes external newsroom updates.
packages/backend/src/modules/1_mos_connection - MOS parser · Parses MOS sockets, XML payloads, and profile-specific message behavior.
packages/backend/src/modules/1_mos_connection/helper/mosModel - Ingest translate · Pure boundary that converts MOS running orders into the internal rundown model.
packages/backend/src/modules/2_ingest/mos-to-rundown.ts - Domain store · Holds rundown state, JSON persistence, socket serving, and MOS caching.
packages/backend/src/modules/3_domain_engine/store - Engine core · Runs rundown lifecycle, state loop, PartInstance management, and crash recovery.
packages/backend/src/modules/3_domain_engine/engine - Timeline flow · Turns model state into timelines, resolves desired device state, and diffs against last sent state.
packages/backend/src/modules/3_domain_engine/engine/timeline-builder.ts - Playout ctrl · Converts abstract playout intent into device-specific commands and execution strategy.
packages/backend/src/modules/4_playout_controllers/playout-controller.ts - Tricaster driver · Concrete Blackmagic Tricaster integration using WebSocket commands and retry logic.
packages/backend/src/modules/4_playout_controllers/tricaster - Core lib · Canonical models and socket/event contracts shared by backend and frontend.
packages/core-lib/src - Frontend app · Operator console for rundown and playout views using backend-shared contracts.
packages/frontend/src - UI state · Client-side state management for rundown and playout interface behavior.
packages/frontend/src/store/useRCASStore.ts - UI panels · Major operator-facing components such as rundown rows, source cards, timing, and control panels.
packages/frontend/src/components
Vendored reference
Sofie Core copy kept as architectural reference, not the main runtime.
- Sofie Core · Large reference copy of Sofie Core used for architectural inspiration and comparison.
.gcloudignore/reference/sofie-core
Connections 19
- Backend entry → Shared infra: uses · Backend startup relies on shared config, logging, and health checks.
- Backend entry → Service adapters: selects · Entrypoint chooses in-memory or gRPC-oriented execution style.
- Backend entry → MOS ingress: boots · Backend can start the MOS ingress boundary as part of runtime composition.
- MOS ingress → MOS parser: parses · Socket traffic is normalized through MOS message and XML parsing.
- MOS parser → Ingest translate: feeds · Parsed MOS data is translated into internal rundown structures.
- Ingest translate → Domain store: loads · Translated rundown data is stored and cached for the domain engine.
- Domain store → Engine core: serves · The engine consumes persisted and live rundown state from the store.
- Engine core → Timeline flow: builds · Lifecycle state is transformed into timelines and desired device state.
- Timeline flow → Playout ctrl: diffs to · Resolved state is diffed into device-facing control actions.
- Playout ctrl → Tricaster driver: implements · Tricaster is the concrete device driver behind the playout abstraction.
- Shared infra → Core lib: shares · Shared backend services rely on canonical domain and event contracts.
- Frontend app → Core lib: consumes · Frontend uses the shared models and socket/event contracts.
- Frontend app → UI state: manages · UI state is coordinated through the client store.
- Frontend app → UI panels: renders · Operator screens are composed from the main UI panels.
- UI panels → UI state: reads · Panels subscribe to the client store for rundown and playout state.
- Backend entry → Sofie Core: inspired by · Vendored Sofie Core provides reference architecture and patterns.
- MOS parser → Quick MOS: validated by · MOS sample tooling helps validate parser and translation compatibility.
- Ingest translate → MOS patch: validated by · Patch tooling exercises MOS-to-rundown conversion behavior.
- Playout ctrl → Sofie Core: inspired by · Playout controller design is informed by the reference Sofie Core tree.