# wongywrongy/shuttleworks architecture

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

- Interactive diagram: https://gitdiagram.com/wongywrongy/shuttleworks
- Repository: https://github.com/wongywrongy/shuttleworks

## Overview

#### Purpose and deployable entry points
ShuttleWorks manages inter-school meets and bracket tournaments: configuration and entries, CP-SAT scheduling, live match operations, and public displays. Deployable applications are:
- FastAPI backend: `apps/api/src/core/main.py`
- Operator React SPA: `apps/console/src/main.tsx`, `apps/console/src/app/App.tsx`
- Public entrant SSR application under `/e/`: `apps/entrant/app/entry.server.tsx`, `apps/entrant/app/routes.ts`
- Worker/process entry points: `apps/api/src/worker.py`, `apps/api/src/shuttleworks/worker/main.py`

Local deployment uses Docker Compose with SQLite; cloud mode uses Postgres and standalone workers. Compose variants live in `infra/compose/docker-compose.yml` and `infra/compose/docker-compose.cloud.yml`.

#### Workspace control plane and UI products
A workspace is the tenancy and event-control boundary. It enables Meet, Bracket, Display, and Entries; Operations is always present. The console shell routes users into module surfaces and guards access:
- Shell/navigation: `apps/console/src/app/AppShell.tsx`, `apps/console/src/platform/product-shell/WorkspaceShell.tsx`
- Module dispatch: `apps/console/src/app/workspace/ModuleOutlet.tsx`
- Workspace/module backend services: `apps/api/src/workspaces/setup.py`, `apps/api/src/workspaces/workspace_modules.py`, `apps/api/src/workspaces/tournaments.py`

The console’s API clients, hooks, and Zustand stores mediate backend state, polling, optimistic UI, and client command queues: `apps/console/src/api/client.ts`, `apps/console/src/store/tournamentStore.ts`, `apps/console/src/hooks/useCommandQueue.ts`.

#### Scheduling engine and solve rail
`scheduler-core` is a pure-Python scheduling boundary: domain dataclasses and CP-SAT construction contain no HTTP or persistence concerns. It models court capacity, availability, rest, locks, freeze horizons, and optimization objectives:
- Engine boundary: `packages/scheduler-core/scheduler_core/engine/bridge.py`, `packages/scheduler-core/scheduler_core/engine/cpsat_backend.py`
- Constraints: `packages/scheduler-core/scheduler_core/engine/constraints/`
- Repair/live scheduling: `packages/scheduler-core/scheduler_core/engine/repair.py`, `packages/scheduler-core/scheduler_core/engine/live_ops.py`

The API adapts persisted tournament state to the engine, puts work on a DB-backed solve-job rail, and exposes proposals/suggestions and solver progress. Workers isolate solve execution from request handling: `apps/api/src/solve_rail/solve_jobs.py`, `apps/api/src/solve_rail/solve_worker.py`, `apps/api/src/meet/schedule_proposals.py`.

#### Meet, bracket, and operations flow
Meet produces schedules from rosters, venue configuration, constraints, and repair actions. Bracket produces draws/matches, advances results, and can schedule rounds through the same solver:
- Meet application/schedule layer: `apps/api/src/meet/schedule_application.py`, `apps/api/src/meet/schedule_director.py`
- Bracket domain and formats: `apps/api/src/bracket/application.py`, `apps/api/src/bracket/formats/`, `apps/api/src/bracket/advancement.py`
- Unified day-of operations: `apps/api/src/operations/commands.py`, `apps/api/src/operations/match_state_application.py`

Operations is the mutation boundary: browser actions become idempotent commands, update the match-state machine and authoritative persistence, then polling clients refresh projections. Bracket results use a parallel command route. Console surfaces are `apps/console/src/modules/operations/OperationsProduct.tsx`, `apps/console/src/modules/meet/MeetProduct.tsx`, and `apps/console/src/modules/bracket/BracketProduct.tsx`.

#### Persistence, authority, and synchronization
SQLAlchemy models and Alembic migrations support SQLite locally and Postgres in cloud mode:
- Persistence: `apps/api/src/db/models.py`, `apps/api/src/db/session.py`
- Schema evolution: `apps/api/src/alembic/versions/`
- Repository abstraction: `apps/api/src/repositories/base.py`, `apps/api/src/repositories/local.py`

Local event-node mode keeps SQLite as authoritative and avoids network writes. Cloud/event-node composition and sync are explicit boundaries, with compatibility and quarantine handling: `apps/api/src/core/composition/cloud.py`, `apps/api/src/core/composition/event_node.py`, `apps/api/src/sync/service.py`.

#### Public, identity, and operational boundaries
The entrant frontend is independently SSR-rendered and communicates same-origin with backend entry, account, and submission APIs; it shares only the design system with the console:
- Entrant routes: `apps/entrant/app/routes/enter.tsx`, `apps/entrant/app/routes/tournament.tsx`
- Entry lifecycle: `apps/api/src/entries/lifecycle.py`, `apps/api/src/entries/submissions.py`
- Identity/session/invites: `apps/api/src/identity/auth.py`, `apps/api/src/identity/invites.py`

Public displays are read-only capability-token projections, separate from authenticated operator access: `apps/api/src/display/display.py`, `apps/console/src/modules/display/DisplayProduct.tsx`. Security controls include cookie sessions, CSRF, throttling, Turnstile integration, and telemetry: `apps/api/src/core/form_csrf.py`, `apps/api/src/core/throttle.py`, `apps/api/src/core/telemetry/bootstrap.py`.

Main entry points: [`apps/api/src/core/main.py`](https://github.com/wongywrongy/shuttleworks/blob/main/apps/api/src/core/main.py) (FastAPI Backend), [`apps/api/src/operations/commands.py`](https://github.com/wongywrongy/shuttleworks/blob/main/apps/api/src/operations/commands.py) (Match Operations), [`apps/api/src/bracket/application.py`](https://github.com/wongywrongy/shuttleworks/blob/main/apps/api/src/bracket/application.py) (Bracket Domain), [`apps/api/src/solve_rail/solve_jobs.py`](https://github.com/wongywrongy/shuttleworks/blob/main/apps/api/src/solve_rail/solve_jobs.py) (Solve Job Rail)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_clients["Client products"]
  node_console["Operator Console<br/>React SPA<br/>[main.tsx]"]
  node_console_shell["Workspace Shell<br/>console routing<br/>[AppShell.tsx]"]
  node_entrant["Entrant App<br/>SSR application<br/>[entry.server.tsx]"]
  node_display["Public Displays<br/>read-only projection<br/>[DisplayProduct.tsx]"]
end

subgraph group_api["Backend control plane"]
  node_api_main["FastAPI Backend<br/>HTTP API<br/>[main.py]"]
  node_workspace["Workspace Control<br/>workspace services"]
  node_identity["Identity &amp; Invites<br/>session security<br/>[auth.py]"]
  node_entries["Entry Lifecycle<br/>entry service<br/>[lifecycle.py]"]
  node_meet["Meet Scheduling<br/>meet application"]
  node_bracket["Bracket Domain<br/>tournament service<br/>[application.py]"]
  node_operations["Match Operations<br/>command boundary<br/>[commands.py]"]
end

subgraph group_scheduling["Scheduling rail"]
  node_solve_jobs["Solve Job Rail<br/>DB-backed jobs<br/>[solve_jobs.py]"]
  node_solve_worker["Solve Worker<br/>worker process<br/>[solve_worker.py]"]
  node_scheduler["Scheduler Core<br/>pure Python CP-SAT<br/>[cpsat_backend.py]"]
end

subgraph group_data["Data and deployment"]
  node_persistence[("Authoritative Store<br/>SQLAlchemy database<br/>[models.py]")]
  node_repositories["Repository Abstraction<br/>data access<br/>[base.py]"]
  node_sync["Cloud/Event-node Sync<br/>synchronization service<br/>[service.py]"]
  node_deployment["Deployment Modes<br/>Docker Compose<br/>[docker-compose.yml]"]
end

node_console -->|"renders"| node_console_shell
node_console_shell -->|"workspace modules"| node_workspace
node_console -->|"commands, polling"| node_api_main
node_entrant -->|"same-origin APIs"| node_api_main
node_display -->|"read-only projections"| node_api_main
node_api_main -->|"authenticates"| node_identity
node_api_main -->|"entry APIs"| node_entries
node_api_main -->|"meet APIs"| node_meet
node_api_main -->|"bracket APIs"| node_bracket
node_api_main -->|"live command APIs"| node_operations
node_entries -->|"persists"| node_repositories
node_meet -->|"submits solves"| node_solve_jobs
node_bracket -->|"schedules rounds"| node_solve_jobs
node_solve_jobs -->|"claims jobs"| node_solve_worker
node_solve_worker -->|"executes"| node_scheduler
node_operations -->|"advances results"| node_bracket
node_operations -->|"updates match state"| node_repositories
node_repositories -->|"reads and writes"| node_persistence
node_sync -->|"synchronizes authority"| node_persistence
node_deployment -->|"runs API"| node_api_main
node_deployment -->|"runs standalone workers"| node_solve_worker

click node_console "https://github.com/wongywrongy/shuttleworks/blob/main/apps/console/src/main.tsx"
click node_console_shell "https://github.com/wongywrongy/shuttleworks/blob/main/apps/console/src/app/AppShell.tsx"
click node_entrant "https://github.com/wongywrongy/shuttleworks/blob/main/apps/entrant/app/entry.server.tsx"
click node_display "https://github.com/wongywrongy/shuttleworks/blob/main/apps/console/src/modules/display/DisplayProduct.tsx"
click node_api_main "https://github.com/wongywrongy/shuttleworks/blob/main/apps/api/src/core/main.py"
click node_workspace "https://github.com/wongywrongy/shuttleworks/blob/main/apps/api/src/workspaces/workspace_modules.py"
click node_identity "https://github.com/wongywrongy/shuttleworks/blob/main/apps/api/src/identity/auth.py"
click node_entries "https://github.com/wongywrongy/shuttleworks/blob/main/apps/api/src/entries/lifecycle.py"
click node_meet "https://github.com/wongywrongy/shuttleworks/blob/main/apps/api/src/meet/schedule_application.py"
click node_bracket "https://github.com/wongywrongy/shuttleworks/blob/main/apps/api/src/bracket/application.py"
click node_operations "https://github.com/wongywrongy/shuttleworks/blob/main/apps/api/src/operations/commands.py"
click node_solve_jobs "https://github.com/wongywrongy/shuttleworks/blob/main/apps/api/src/solve_rail/solve_jobs.py"
click node_solve_worker "https://github.com/wongywrongy/shuttleworks/blob/main/apps/api/src/solve_rail/solve_worker.py"
click node_scheduler "https://github.com/wongywrongy/shuttleworks/blob/main/packages/scheduler-core/scheduler_core/engine/cpsat_backend.py"
click node_persistence "https://github.com/wongywrongy/shuttleworks/blob/main/apps/api/src/db/models.py"
click node_repositories "https://github.com/wongywrongy/shuttleworks/blob/main/apps/api/src/repositories/base.py"
click node_sync "https://github.com/wongywrongy/shuttleworks/blob/main/apps/api/src/sync/service.py"
click node_deployment "https://github.com/wongywrongy/shuttleworks/blob/main/infra/compose/docker-compose.yml"

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_console,node_console_shell,node_entrant,node_display toneBlue
class node_api_main,node_workspace,node_identity,node_entries,node_meet,node_bracket,node_operations toneAmber
class node_solve_jobs,node_solve_worker,node_scheduler toneMint
class node_persistence,node_repositories,node_sync,node_deployment toneRose
```

## Components

### Client products

- [Operator Console](https://github.com/wongywrongy/shuttleworks/blob/main/apps/console/src/main.tsx): React SPA · Authenticated workspace control and live operations UI. · `apps/console/src/main.tsx`
- [Workspace Shell](https://github.com/wongywrongy/shuttleworks/blob/main/apps/console/src/app/AppShell.tsx): console routing · Guards access and dispatches enabled workspace modules. · `apps/console/src/app/AppShell.tsx`
- [Entrant App](https://github.com/wongywrongy/shuttleworks/blob/main/apps/entrant/app/entry.server.tsx): SSR application · Public entrant account, entry, and submission experience. · `apps/entrant/app/entry.server.tsx`
- [Public Displays](https://github.com/wongywrongy/shuttleworks/blob/main/apps/console/src/modules/display/DisplayProduct.tsx): read-only projection · Capability-token display views separate from operator access. · `apps/console/src/modules/display/DisplayProduct.tsx`

### Backend control plane

- [FastAPI Backend](https://github.com/wongywrongy/shuttleworks/blob/main/apps/api/src/core/main.py): HTTP API · Primary request boundary for workspace, public, and operational APIs. · `apps/api/src/core/main.py`
- [Workspace Control](https://github.com/wongywrongy/shuttleworks/blob/main/apps/api/src/workspaces/workspace_modules.py): workspace services · Tenancy boundary that enables Meet, Bracket, Entries, and Display modules. · `apps/api/src/workspaces/workspace_modules.py`
- [Identity & Invites](https://github.com/wongywrongy/shuttleworks/blob/main/apps/api/src/identity/auth.py): session security · Cookie sessions, authentication, and invitations. · `apps/api/src/identity/auth.py`
- [Entry Lifecycle](https://github.com/wongywrongy/shuttleworks/blob/main/apps/api/src/entries/lifecycle.py): entry service · Manages entrant submissions and entry state. · `apps/api/src/entries/lifecycle.py`
- [Meet Scheduling](https://github.com/wongywrongy/shuttleworks/blob/main/apps/api/src/meet/schedule_application.py): meet application · Builds schedule requests and manages proposals. · `apps/api/src/meet/schedule_application.py`
- [Bracket Domain](https://github.com/wongywrongy/shuttleworks/blob/main/apps/api/src/bracket/application.py): tournament service · Creates draws, advances results, and schedules rounds. · `apps/api/src/bracket/application.py`
- [Match Operations](https://github.com/wongywrongy/shuttleworks/blob/main/apps/api/src/operations/commands.py): command boundary · Idempotent live commands drive the authoritative match-state machine. · `apps/api/src/operations/commands.py`

### Scheduling rail

- [Solve Job Rail](https://github.com/wongywrongy/shuttleworks/blob/main/apps/api/src/solve_rail/solve_jobs.py): DB-backed jobs · Queues solve work and exposes solver progress. · `apps/api/src/solve_rail/solve_jobs.py`
- [Solve Worker](https://github.com/wongywrongy/shuttleworks/blob/main/apps/api/src/solve_rail/solve_worker.py): worker process · Isolates scheduling execution from HTTP handling. · `apps/api/src/solve_rail/solve_worker.py`
- [Scheduler Core](https://github.com/wongywrongy/shuttleworks/blob/main/packages/scheduler-core/scheduler_core/engine/cpsat_backend.py): pure Python CP-SAT · Models capacities, availability, rest, locks, freeze horizons, and objectives. · `packages/scheduler-core/scheduler_core/engine/cpsat_backend.py`

### Data and deployment

- [Authoritative Store](https://github.com/wongywrongy/shuttleworks/blob/main/apps/api/src/db/models.py): SQLAlchemy database · SQLite locally and Postgres in cloud mode. · `apps/api/src/db/models.py`
- [Repository Abstraction](https://github.com/wongywrongy/shuttleworks/blob/main/apps/api/src/repositories/base.py): data access · Decouples application services from local persistence implementation. · `apps/api/src/repositories/base.py`
- [Cloud/Event-node Sync](https://github.com/wongywrongy/shuttleworks/blob/main/apps/api/src/sync/service.py): synchronization service · Handles cloud composition, compatibility, and quarantine. · `apps/api/src/sync/service.py`
- [Deployment Modes](https://github.com/wongywrongy/shuttleworks/blob/main/infra/compose/docker-compose.yml): Docker Compose · Local SQLite composition and cloud Postgres plus standalone workers. · `infra/compose/docker-compose.yml`

## Connections

- Operator Console → Workspace Shell: renders
- Workspace Shell → Workspace Control: workspace modules
- Operator Console → FastAPI Backend: commands, polling
- Entrant App → FastAPI Backend: same-origin APIs
- Public Displays → FastAPI Backend: read-only projections
- FastAPI Backend → Identity & Invites: authenticates
- FastAPI Backend → Entry Lifecycle: entry APIs
- FastAPI Backend → Meet Scheduling: meet APIs
- FastAPI Backend → Bracket Domain: bracket APIs
- FastAPI Backend → Match Operations: live command APIs
- Entry Lifecycle → Repository Abstraction: persists
- Meet Scheduling → Solve Job Rail: submits solves
- Bracket Domain → Solve Job Rail: schedules rounds
- Solve Job Rail → Solve Worker: claims jobs
- Solve Worker → Scheduler Core: executes
- Match Operations → Bracket Domain: advances results
- Match Operations → Repository Abstraction: updates match state
- Repository Abstraction → Authoritative Store: reads and writes
- Cloud/Event-node Sync → Authoritative Store: synchronizes authority
- Deployment Modes → FastAPI Backend: runs API
- Deployment Modes → Solve Worker: runs standalone workers
