How naniorion/rugby-controller works
1. What this repo is
- A local desktop app for controlling a rugby broadcast in OBS.
- It is built as an Electron shell with a React + TypeScript renderer and a live browser-source overlay for OBS.
- There is no remote backend in the architecture; the app is centered on local state and local file import/export.
2. Top-level runtime boundary
- The Electron main process (electron/main.ts) owns desktop concerns: app startup, window creation, and serving the local UI.
- The renderer is the React app under src/, which provides both the operator dashboard and the graphics overlay.
- electron/preload.ts is the bridge boundary for safe IPC exposure, and electron/timer.ts suggests timer logic that may live outside the UI layer.
3. Primary UI split: control plane vs broadcast plane
- src/pages/Dashboard.tsx is the operator control panel: where the user edits match data, scores, timer, cards, lineups, labels, and presentation assets.
- src/pages/Overlay.tsx is the broadcast output: the visual layer rendered in OBS via Browser Source.
- This split is important for diagrams: one side is input/control, the other is presentation/output.
4. Central state model
- src/context/MatchContext.tsx is the main application state hub.
- It likely holds the full match model: teams, score, timer state, cards, substitutions, lineups, presentation data, logs, and overlay visibility/animations.
- Most components appear to be thin UI controls that read/write through this context rather than managing their own isolated state.
5. Match operations and live scoring
- The core match workflow is driven by score and event actions: try, conversion, penalty, drop, and automated score calculation.
- src/components/ActionLog.tsx records the chronological event feed that feeds both the dashboard and overlay summary views.
- src/components/SubstitutionControl.tsx and card-related logic support live match events and time-based consequences.
6. Timekeeping and discipline
- The app includes a match clock with first/second half control, pause/stop, and manual adjustment.
- Yellow card and red-card variants are supported, including a 20-minute red with a separate countdown and differentiated notification behavior.
- This suggests a timer subsystem that is time-sensitive and likely coupled to the central match state rather than treated as a standalone widget.
7. Team, lineup, and roster management
- src/components/LineupEditor.tsx, PlayerSelectorModal.tsx, and LabelManager.tsx support preparing the match roster and on-screen labels.
- The roster flow includes bulk import/paste from Excel or notes, manual editing, and real-time substitutions.
- These features feed both the dashboard controls and overlay lineup/statistics presentation.
8. Presentation assets and graphics
- The app manages team names, initials, colors, logos, plus extra broadcast assets such as sponsor images, league logos, posters, referees, stadium info, and commentators.
- src/components/LabelManager.tsx indicates reusable lower-third style or informational graphics.
- src/pages/Overlay.css and src/index.css imply the overlay is heavily styled as a broadcast graphic rather than a generic app page.
9. Overlay rendering contract
- The overlay is meant to be loaded by OBS from a local URL such as http://localhost:3000/#/overlay.
- The overlay consumes the same live match state as the dashboard and renders score, timer, lineup views, stats comparisons, match presentation, and animated transitions.
- In architecture terms, OBS is an external consumer of the app’s render output, not a collaborator with business logic.
10. Persistence and portability
- The app supports export/import of full match configuration as JSON for reuse across matches.
- Assets such as logos and posters are likely kept as local file references or embedded data managed from the dashboard.
- This makes the app stateful locally, but portable through user-generated config files rather than a database.
11. Socket/synchronization layer
- src/hooks/useSocket.ts suggests a communication hook, likely used to propagate live updates across the dashboard/overlay boundary or to coordinate real-time updates.
- Even if the app is mostly single-process, this hook indicates a dedicated synchronization abstraction rather than ad hoc prop drilling.
- For a diagram, treat it as the live-update transport between control state and broadcast rendering.
12. Tooling and packaging
- The project uses Vite for the renderer build and TypeScript throughout.
- package.json, vite.config.ts, and tsconfig.json define the web build toolchain, while Electron packages it as a desktop application.
- docs/ and public/ are supporting static assets; they are not part of the core runtime path.
13. Overall data flow
- User actions in the Dashboard update the MatchContext.
- The context drives timer changes, score updates, lineup edits, and event logging.
- The Overlay reads that shared state and renders broadcast graphics.
- OBS consumes the overlay through the browser source URL, while JSON import/export lets the operator persist and reload the match setup.
Main entry points: MatchContext.tsx Match state · Overlay.tsx Overlay · App.tsx App shell · Dashboard.tsx Dashboard
Components 21
Electron runtime
Desktop process boundary and IPC bridge
- Main process · Starts the desktop app, creates windows, and serves the local UI
electron/main.ts - Preload bridge · Safe IPC surface between main and renderer
electron/preload.ts - Timer runtime · Timer logic that may run outside the React UI layer
electron/timer.ts
Renderer app
React application that powers control and overlay views
- App shell · Top-level renderer composition and route wiring
src/App.tsx - Renderer entry · Bootstraps the React renderer into the page
src/main.tsx - Match state · Central match model for score, timer, cards, lineups, assets, and overlay state
src/context/MatchContext.tsx - Sync hook · Abstraction for propagating live updates across the app
src/hooks/useSocket.ts - Dashboard · Operator workspace for editing match data and live actions
src/pages/Dashboard.tsx - Overlay · Browser-source graphics rendered in OBS
src/pages/Overlay.tsx - Action log · Chronological record of match events and operator actions
src/components/ActionLog.tsx - Lineup editor · Edits team lineups and player availability
src/components/LineupEditor.tsx - Substitutions · Controls live substitutions and related match events
src/components/SubstitutionControl.tsx - Label manager · Maintains reusable broadcast labels and lower-third style assets
src/components/LabelManager.tsx - Player picker · Selects and assigns players into roster and lineup workflows
src/components/PlayerSelectorModal.tsx - Overlay CSS · Broadcast-specific overlay styling
src/pages/Overlay.css - Global CSS · Shared application styling
src/index.css
Static assets
Local files and public resources used by the app
- Public assets · Packaged local assets such as icons and other public files
public/icons - Docs site · Static documentation and published pages
docs/index.html
Tooling
Build and packaging configuration
- Package config · Dependencies, scripts, and app packaging metadata
package.json - Vite config · Renderer build configuration
vite.config.ts - TS config · TypeScript compilation settings
tsconfig.json
Connections 22
- Main process → Preload bridge: exposes IPC · Main process publishes a safe bridge to the renderer
- Main process → Renderer entry: hosts UI · Desktop shell serves the renderer application
- Renderer entry → App shell: mounts · Renderer entry mounts the React shell
- App shell → Dashboard: routes to · Operator control view
- App shell → Overlay: routes to · Broadcast output view
- Dashboard → Match state: reads/writes · Dashboard edits the central match model
- Overlay → Match state: reads · Overlay renders from shared live state
- Match state → Action log: feeds · State changes are recorded as match events
- Match state → Lineup editor: drives · Roster and lineup data are synchronized from context
- Match state → Substitutions: drives · Live substitution state and actions flow through context
- Match state → Label manager: drives · Broadcast labels and presentation assets come from shared state
- Lineup editor → Player picker: opens · Lineup editing uses player selection
- Timer runtime → Match state: updates clock · Timer runtime feeds match time and discipline state
- Sync hook → Match state: syncs · Dedicated live-update abstraction keeps state coordinated
- Sync hook → Overlay: broadcasts · Live updates reach the overlay rendering path
- Overlay → Overlay CSS: uses · Overlay-specific visual styling
- Dashboard → Global CSS: uses · Shared styling for the control UI
- Public assets → Overlay: supplies assets · Local graphics and icons used in the app
- Docs site → Package config: supported by · Documentation and static site are part of the project package
- Vite config → Renderer entry: builds · Vite bundles the renderer application
- TS config → App shell: types · TypeScript config governs the app codebase
- Package config → Main process: packages · Desktop app distribution and scripts center on Electron