# agame7k/freezy-arena architecture

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

- Interactive diagram: https://gitdiagram.com/agame7k/freezy-arena
- Repository: https://github.com/agame7k/freezy-arena

## Overview

Freesy Arena is a Go field-management system for running robotics competitions, with browser-based controls and displays, live match scoring, tournament scheduling, and optional field/network hardware integrations. The external trigger is an event operator launching the `cheesy-arena` executable; staff and display users then interact through a browser, while driver stations and field devices connect over network protocols. Startup constructs the arena, starts the web server, and runs the arena state machine.

Components

**Application startup and control**
- **Executable startup** — `main.go`: parses the development-network flag, creates the arena, starts the web interface in a goroutine, and runs the arena loop.
- **Arena runtime and match coordination** — `field/arena.go`: owns live event and match state, initializes hardware/notifiers, and coordinates match loading, timers, scoring inputs, and tournament updates.
- **Driver-station protocol** — `field/driver_station_connection.go`: accepts driver-station TCP connections, assigns stations, exchanges control/game-data packets, and tracks connections.

**Operator, browser, and live updates**
- **HTTP operator interface** — `web/web.go`: implements the web server entry point and route setup; the README documents browser-based human interaction.
- **Match review and score editing** — `web/match_review.go`: serves match-result editing, calculates summaries, and commits edits through the web arena.
- **Reports and exports** — `web/reports.go`: generates event reports in CSV/PDF and includes judging-schedule reporting.
- **Browser displays and controls** — `static/js/audience_display.js`: a representative browser display; the README documents browser clients using WebSockets for commands and updates.
- **WebSocket transport and notification** — `websocket/websocket.go`: provides WebSocket handling; `websocket/notifier.go` implements notifier behavior for connected clients.

**Event state and competition logic**
- **Persistent event database** — `model/database.go`: opens Bolt storage and registers tables for event settings, teams, matches, results, rankings, and related records.
- **Game rules and scoring** — `game/score.go`: calculates match scores; `game/rule.go`: defines scoring rules. Score summaries and ranking calculations are additional game responsibilities.
- **Qualification and judging schedules** — `tournament/judging_schedule.go`: schedules judging slots against qualification matches and breaks, saving slots to the database.
- **Playoff brackets** — `playoff/double_elimination.go`: constructs double-elimination bracket matchups and timing specifications; the README also highlights small-team double eliminations.
- **Event and match model types** — `model/match.go`: defines match data used by event workflows.

**Hardware and external services**
- **PLC field I/O** — `plc/plc.go`: polls a Modbus PLC, reads inputs, and writes output coils; `field/arena.go` consumes field I/O in match control.
- **Wireless access-point management** — `network/access_point.go`: configures team Wi-Fi and polls connection status through the access point HTTP API.
- **LED control** — `led/controller.go`: implements LED controller behavior; the README documents support for Advatek controllers and field LED hardware.
- **External event publishing** — `partner/tba.go`: retrieves and publishes event, match, alliance, and related data through The Blue Alliance API; the README documents schedule, results, and rankings publishing.
- **Competition lighting and show control** — `partner/blackmagic.go`: represents the Blackmagic integration; `partner/companion.go`: implements Companion integration. Specific runtime wiring is not established by the excerpts.

Relationships

- **Event operator -> Executable startup**: launches the application; evidence: `README.md`.
- **Executable startup -> Arena runtime and match coordination**: creates the arena and runs its state machine; evidence: `main.go`.
- **Executable startup -> HTTP operator interface**: constructs the web interface and starts its server in a goroutine; evidence: `main.go`.
- **Browser user -> HTTP operator interface**: interacts with the application through a browser; evidence: `README.md`.
- **HTTP operator interface -> Match review and score editing**: route registration is not shown in the sampled excerpt; evidence: none (inferred from documented web application and handler responsibility).
- **Match review and score editing -> Persistent event database**: reads stored match results for non-current matches; evidence: `web/match_review.go`.
- **Match review and score editing -> Game rules and scoring**: imports game scoring types and uses rules for editing and summary workflows; evidence: `web/match_review.go`.
- **Arena runtime and match coordination -> PLC field I/O**: creates PLC implementations and processes PLC input/output; evidence: `field/arena.go`.
- **Arena runtime and match coordination -> Driver-station protocol**: the arena manages alliance stations and the driver-station code operates on arena state; evidence: `field/driver_station_connection.go`.
- **PLC field I/O -> WebSocket transport and notification**: PLC code imports the WebSocket package to send I/O change messages; evidence: `plc/plc.go`.
- **Arena runtime and match coordination -> Playoff brackets**: reconstructs and updates the playoff tournament; evidence: `field/arena.go`.
- **Tournament scheduling -> Persistent event database**: loads qualification matches and schedule blocks, then saves judging slots; evidence: `tournament/judging_schedule.go`.
- **External event service (The Blue Alliance) -> External event publishing**: receives API requests for event data; evidence: `partner/tba.go`.
- **Browser displays and controls -> WebSocket transport and notification**: clients use WebSockets for commands and updates; evidence: `README.md`.
- **Arena runtime and match coordination -> External event publishing**: event-triggered client call sites are not fully visible in the excerpt; evidence: none (inferred from arena’s partner references and TBA integration).

Coverage limits: Several central modules are sampled only partially, and many web routes, notifier implementations, model types, and partner integrations are not excerpted. The README establishes product-level behavior, but the exact runtime wiring for several displays, integrations, and publication triggers could not be verified.

Main entry points: [`field/arena.go`](https://github.com/agame7k/freezy-arena/blob/main/field/arena.go) (Arena runtime), [`main.go`](https://github.com/agame7k/freezy-arena/blob/main/main.go) (Executable startup), [`web/match_review.go`](https://github.com/agame7k/freezy-arena/blob/main/web/match_review.go) (Match review), [`web/web.go`](https://github.com/agame7k/freezy-arena/blob/main/web/web.go) (HTTP operator interface)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_runtime["Application Runtime"]
  node_startup["Executable startup<br/>Application entry point"]
  node_arena["Arena runtime<br/>Match coordinator"]
  node_driver_station["Driver-station protocol<br/>TCP protocol"]
end

subgraph group_web["Browser Interface"]
  node_http["HTTP operator interface<br/>Web server"]
  node_match_review["Match review<br/>Score editing"]
  node_reports["Reports and exports<br/>Reporting"]
  node_browser_display["Browser displays<br/>Browser client"]
  node_websocket["WebSocket notifier<br/>Live updates"]
end

subgraph group_competition["Competition Logic"]
  node_database[("Event database<br/>Persistent storage")]
  node_scoring["Game scoring<br/>Scoring rules"]
  node_judging["Judging schedules<br/>Tournament scheduling"]
  node_playoffs["Playoff brackets<br/>Tournament logic"]
end

subgraph group_integrations["External Integrations"]
  node_plc["PLC field I/O<br/>Field hardware"]
  node_access_point["Wireless access point<br/>Network hardware"]
  node_led["LED controller<br/>Field hardware"]
  node_tba_publisher["Event publisher<br/>External API integration"]
end

node_operator(("Event operator<br/>External actor"))
node_browser_user(("Browser user<br/>External actor"))
node_tba_api(("Blue Alliance API<br/>External service"))

node_operator -->|"launches"| node_startup
node_startup -->|"creates and runs"| node_arena
node_startup -->|"starts server"| node_http
node_browser_user -->|"interacts through"| node_http
node_http -.->|"routes to"| node_match_review
node_match_review -->|"reads results"| node_database
node_match_review -->|"uses rules"| node_scoring
node_arena -->|"processes field I/O"| node_plc
node_arena -->|"manages stations"| node_driver_station
node_plc -->|"sends I/O changes"| node_websocket
node_arena -->|"updates bracket"| node_playoffs
node_judging -->|"loads and saves"| node_database
node_tba_api -->|"receives requests"| node_tba_publisher
node_browser_display -->|"uses for updates"| node_websocket
node_arena -.->|"publishes event updates"| node_tba_publisher

click node_startup "https://github.com/agame7k/freezy-arena/blob/main/main.go"
click node_arena "https://github.com/agame7k/freezy-arena/blob/main/field/arena.go"
click node_driver_station "https://github.com/agame7k/freezy-arena/blob/main/field/driver_station_connection.go"
click node_http "https://github.com/agame7k/freezy-arena/blob/main/web/web.go"
click node_match_review "https://github.com/agame7k/freezy-arena/blob/main/web/match_review.go"
click node_reports "https://github.com/agame7k/freezy-arena/blob/main/web/reports.go"
click node_browser_display "https://github.com/agame7k/freezy-arena/blob/main/static/js/audience_display.js"
click node_websocket "https://github.com/agame7k/freezy-arena/blob/main/websocket/websocket.go"
click node_database "https://github.com/agame7k/freezy-arena/blob/main/model/database.go"
click node_scoring "https://github.com/agame7k/freezy-arena/blob/main/game/score.go"
click node_judging "https://github.com/agame7k/freezy-arena/blob/main/tournament/judging_schedule.go"
click node_playoffs "https://github.com/agame7k/freezy-arena/blob/main/playoff/double_elimination.go"
click node_plc "https://github.com/agame7k/freezy-arena/blob/main/plc/plc.go"
click node_access_point "https://github.com/agame7k/freezy-arena/blob/main/network/access_point.go"
click node_led "https://github.com/agame7k/freezy-arena/blob/main/led/controller.go"
click node_tba_publisher "https://github.com/agame7k/freezy-arena/blob/main/partner/tba.go"

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_startup,node_arena,node_driver_station,node_browser_user toneBlue
class node_http,node_match_review,node_reports,node_browser_display,node_websocket toneAmber
class node_database,node_scoring,node_judging,node_playoffs,node_tba_api toneMint
class node_plc,node_access_point,node_led,node_tba_publisher toneRose
class node_operator toneIndigo
```

## Components

### Application Runtime

Startup, arena coordination, and driver-station communication.

- [Executable startup](https://github.com/agame7k/freezy-arena/blob/main/main.go): Application entry point · `main.go`
- [Arena runtime](https://github.com/agame7k/freezy-arena/blob/main/field/arena.go): Match coordinator · `field/arena.go`
- [Driver-station protocol](https://github.com/agame7k/freezy-arena/blob/main/field/driver_station_connection.go): TCP protocol · `field/driver_station_connection.go`

### Browser Interface

Operator workflows, browser displays, and live WebSocket updates.

- [HTTP operator interface](https://github.com/agame7k/freezy-arena/blob/main/web/web.go): Web server · `web/web.go`
- [Match review](https://github.com/agame7k/freezy-arena/blob/main/web/match_review.go): Score editing · `web/match_review.go`
- [Reports and exports](https://github.com/agame7k/freezy-arena/blob/main/web/reports.go): Reporting · `web/reports.go`
- [Browser displays](https://github.com/agame7k/freezy-arena/blob/main/static/js/audience_display.js): Browser client · `static/js/audience_display.js`
- [WebSocket notifier](https://github.com/agame7k/freezy-arena/blob/main/websocket/websocket.go): Live updates · `websocket/websocket.go`

### Competition Logic

Event persistence, scoring, schedules, and playoff brackets.

- [Event database](https://github.com/agame7k/freezy-arena/blob/main/model/database.go): Persistent storage · `model/database.go`
- [Game scoring](https://github.com/agame7k/freezy-arena/blob/main/game/score.go): Scoring rules · `game/score.go`
- [Judging schedules](https://github.com/agame7k/freezy-arena/blob/main/tournament/judging_schedule.go): Tournament scheduling · `tournament/judging_schedule.go`
- [Playoff brackets](https://github.com/agame7k/freezy-arena/blob/main/playoff/double_elimination.go): Tournament logic · `playoff/double_elimination.go`

### External Integrations

Field hardware and external event publishing.

- [PLC field I/O](https://github.com/agame7k/freezy-arena/blob/main/plc/plc.go): Field hardware · `plc/plc.go`
- [Wireless access point](https://github.com/agame7k/freezy-arena/blob/main/network/access_point.go): Network hardware · `network/access_point.go`
- [LED controller](https://github.com/agame7k/freezy-arena/blob/main/led/controller.go): Field hardware · `led/controller.go`
- [Event publisher](https://github.com/agame7k/freezy-arena/blob/main/partner/tba.go): External API integration · `partner/tba.go`

### Other components

- **Event operator**: External actor
- **Browser user**: External actor
- **Blue Alliance API**: External service

## Connections

- Event operator → Executable startup: launches (evidence: `README.md`)
- Executable startup → Arena runtime: creates and runs (evidence: `main.go`)
- Executable startup → HTTP operator interface: starts server (evidence: `main.go`)
- Browser user → HTTP operator interface: interacts through (evidence: `README.md`)
- HTTP operator interface → Match review: routes to · Inferred; not shown in the code that was read.
- Match review → Event database: reads results (evidence: `web/match_review.go`)
- Match review → Game scoring: uses rules (evidence: `web/match_review.go`)
- Arena runtime → PLC field I/O: processes field I/O (evidence: `field/arena.go`)
- Arena runtime → Driver-station protocol: manages stations (evidence: `field/driver_station_connection.go`)
- PLC field I/O → WebSocket notifier: sends I/O changes (evidence: `plc/plc.go`)
- Arena runtime → Playoff brackets: updates bracket (evidence: `field/arena.go`)
- Judging schedules → Event database: loads and saves (evidence: `tournament/judging_schedule.go`)
- Blue Alliance API → Event publisher: receives requests (evidence: `partner/tba.go`)
- Browser displays → WebSocket notifier: uses for updates (evidence: `README.md`)
- Arena runtime → Event publisher: publishes event updates · Inferred; not shown in the code that was read.
