# screwedinger/scoring-system architecture

> Architecture diagram of the GitHub repository screwedinger/scoring-system, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-08-18). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/screwedinger/scoring-system
- Repository: https://github.com/screwedinger/scoring-system

## Overview

#### Purpose and Entry Points
A browser-only, offline-capable live scoring system for Pounce & Bounce quiz events. The operator dashboard controls timing, pounces, bounce allocation, score commits, round rotation, and audit history; a separate projector view mirrors audience-safe state. App startup is `src/main.tsx`, mounting the primary React UI in `src/App.tsx`. The detached display is implemented by `src/projector.tsx`.

#### React Application Shell
`src/App.tsx` is the operator-facing orchestration layer and likely owns workflow screens/modals, keyboard interaction, and phase-driven rendering. Styling is split between application styles and global defaults:
- `src/App.tsx`
- `src/App.css`
- `src/index.css`

The Vite HTML entry is `index.html`; Vite configuration in `vite.config.ts` supplies the development/build boundary.

#### Central Stateful Quiz Engine
`src/store.ts` is the architectural core: a Zustand store with persisted browser state. It holds teams, scores, current round/question/turn, active workflow phase, pounce records, bounce selections/splits, timer state, and history/audit entries. Store actions enforce state transitions such as logging secret pounces, locking bounce eligibility, committing score deltas, advancing turns, and applying special rounds.
- `src/store.ts`
- `src/types.ts`

Persistence uses Zustand’s `localStorage` middleware, so the system has no server-side database or API dependency.

#### Question Lifecycle and Scoring Boundary
The main control flow is a staged question transaction:
1. Start/pause the pounce timer and record hidden pounce submissions.
2. Enter bounce mode, excluding teams that pounced.
3. Assign zero, one, or multiple bounce recipients and editable point splits.
4. Reveal and grade pounces only after bounce resolution.
5. Commit pounce outcomes, append ledger records, rotate the turn, and begin the next question.

The boundary between active scoring and committed scores is important: pounce intent is collected before its score impact is applied, preventing disclosure during the live question.
- `src/App.tsx`
- `src/store.ts`
- `src/types.ts`

#### Turn Rotation and Round Operations
Round progression is state-driven rather than dependent on a backend scheduler. The engine supports ordered direct-question turns and direction changes across rounds, while special rounds apply batch score deltas outside the normal question sequence. The same store should be treated as the source of truth for both score totals and the question-by-question audit trail.
- `src/store.ts`
- `src/types.ts`
- `src/App.tsx`

#### Projector Synchronization
The audience display is a separate browser-window runtime, rendered by `src/projector.tsx`. Operator and projector synchronize via the native `BroadcastChannel` API (`quiz_display_channel` per README), avoiding network infrastructure, WebSockets, or a server. This is an explicit presentation boundary: projector state should expose standings/current public context but not secret pounce data before resolution.
- `src/projector.tsx`
- `src/App.tsx`
- `src/store.ts`

#### Runtime and External Dependencies
The repository is a React 18 + TypeScript single-page application built and served with Vite. Browser platform services—`localStorage` and `BroadcastChannel`—provide persistence and inter-window communication. UI feedback uses `lucide-react` icons and `canvas-confetti`; deployment is compatible with static hosts such as Vercel. Dependency and script definitions are in `package.json`.
- `package.json`
- `vite.config.ts`
- `src/main.tsx`

Main entry points: [`src/store.ts`](https://github.com/screwedinger/scoring-system/blob/main/src/store.ts) (Quiz state store), [`src/App.tsx`](https://github.com/screwedinger/scoring-system/blob/main/src/App.tsx) (Operator dashboard), [`src/main.tsx`](https://github.com/screwedinger/scoring-system/blob/main/src/main.tsx) (React bootstrap), [`vite.config.ts`](https://github.com/screwedinger/scoring-system/blob/main/vite.config.ts) (Vite build/runtime)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_operator["Operator app"]
  node_main["React bootstrap<br/>entry point<br/>[main.tsx]"]
  node_app["Operator dashboard<br/>React orchestration<br/>[App.tsx]"]
  node_app_css["Application styles<br/>[App.css]"]
  node_global_css["Global styles<br/>[index.css]"]
end

subgraph group_engine["Quiz engine"]
  node_store[("Quiz state store<br/>Zustand store<br/>[store.ts]")]
  node_types["Quiz domain types<br/>TypeScript types<br/>[types.ts]"]
  node_pounce["Pounce transaction<br/>scoring workflow"]
  node_bounce["Bounce allocation<br/>scoring workflow"]
  node_rounds["Turn and round engine<br/>progression workflow"]
end

subgraph group_display["Audience display"]
  node_projector["Projector view<br/>React display runtime<br/>[projector.tsx]"]
end

subgraph group_platform["Browser platform"]
  node_vite{{"Vite build/runtime<br/>build tool<br/>[vite.config.ts]"}}
  node_html["HTML entry<br/>document<br/>[index.html]"]
  node_local_storage[("Persisted quiz state<br/>localStorage")]
  node_channel["Display channel<br/>BroadcastChannel"]
  node_dependencies["Dependencies and scripts<br/>package manifest<br/>[package.json]"]
end

node_dependencies -->|"defines"| node_vite
node_vite -->|"serves/builds"| node_html
node_html -->|"loads"| node_main
node_main -->|"mounts"| node_app
node_app -.->|"uses"| node_app_css
node_main -.->|"loads"| node_global_css
node_app -->|"drives actions and renders state"| node_store
node_store -->|"uses"| node_types
node_store -->|"records and grades"| node_pounce
node_pounce -->|"resolves before reveal"| node_bounce
node_bounce -->|"commits score deltas"| node_store
node_store -->|"applies progression"| node_rounds
node_store -->|"persists via middleware"| node_local_storage
node_app -->|"publishes public state"| node_channel
node_channel -->|"synchronizes"| node_projector
node_store -.->|"projects audience-safe state"| node_projector

click node_vite "https://github.com/screwedinger/scoring-system/blob/main/vite.config.ts"
click node_html "https://github.com/screwedinger/scoring-system/blob/main/index.html"
click node_main "https://github.com/screwedinger/scoring-system/blob/main/src/main.tsx"
click node_app "https://github.com/screwedinger/scoring-system/blob/main/src/App.tsx"
click node_app_css "https://github.com/screwedinger/scoring-system/blob/main/src/App.css"
click node_global_css "https://github.com/screwedinger/scoring-system/blob/main/src/index.css"
click node_store "https://github.com/screwedinger/scoring-system/blob/main/src/store.ts"
click node_types "https://github.com/screwedinger/scoring-system/blob/main/src/types.ts"
click node_projector "https://github.com/screwedinger/scoring-system/blob/main/src/projector.tsx"
click node_dependencies "https://github.com/screwedinger/scoring-system/blob/main/package.json"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_main,node_app,node_app_css,node_global_css toneBlue
class node_store,node_types,node_pounce,node_bounce,node_rounds toneAmber
class node_projector toneMint
class node_vite,node_html,node_local_storage,node_channel,node_dependencies toneRose
```

## Components

### Operator app

- [React bootstrap](https://github.com/screwedinger/scoring-system/blob/main/src/main.tsx): entry point · `src/main.tsx`
- [Operator dashboard](https://github.com/screwedinger/scoring-system/blob/main/src/App.tsx): React orchestration · Controls workflow phases, scoring, and operator interactions. · `src/App.tsx`
- [Application styles](https://github.com/screwedinger/scoring-system/blob/main/src/App.css): styles · `src/App.css`
- [Global styles](https://github.com/screwedinger/scoring-system/blob/main/src/index.css): styles · `src/index.css`

### Quiz engine

- [Quiz state store](https://github.com/screwedinger/scoring-system/blob/main/src/store.ts): Zustand store · Authoritative state, transitions, scores, and audit history. · `src/store.ts`
- [Quiz domain types](https://github.com/screwedinger/scoring-system/blob/main/src/types.ts): TypeScript types · `src/types.ts`
- **Pounce transaction**: scoring workflow · Collects hidden pounces before their score impact is committed.
- **Bounce allocation**: scoring workflow · Excludes pouncers and assigns recipients with point splits.
- **Turn and round engine**: progression workflow · Rotates direct turns, changes direction, and applies special rounds.

### Audience display

- [Projector view](https://github.com/screwedinger/scoring-system/blob/main/src/projector.tsx): React display runtime · Renders audience-safe standings and public question context. · `src/projector.tsx`

### Browser platform

- [Vite build/runtime](https://github.com/screwedinger/scoring-system/blob/main/vite.config.ts): build tool · `vite.config.ts`
- [HTML entry](https://github.com/screwedinger/scoring-system/blob/main/index.html): document · `index.html`
- **Persisted quiz state**: localStorage
- **Display channel**: BroadcastChannel · quiz_display_channel synchronizes separate browser windows.
- [Dependencies and scripts](https://github.com/screwedinger/scoring-system/blob/main/package.json): package manifest · `package.json`

## Connections

- Dependencies and scripts → Vite build/runtime: defines
- Vite build/runtime → HTML entry: serves/builds
- HTML entry → React bootstrap: loads
- React bootstrap → Operator dashboard: mounts
- Operator dashboard → Application styles: uses
- React bootstrap → Global styles: loads
- Operator dashboard → Quiz state store: drives actions and renders state
- Quiz state store → Quiz domain types: uses
- Quiz state store → Pounce transaction: records and grades
- Pounce transaction → Bounce allocation: resolves before reveal
- Bounce allocation → Quiz state store: commits score deltas
- Quiz state store → Turn and round engine: applies progression
- Quiz state store → Persisted quiz state: persists via middleware
- Operator dashboard → Display channel: publishes public state
- Display channel → Projector view: synchronizes
- Quiz state store → Projector view: projects audience-safe state
