# s3ansh33p/unilan architecture

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

- Interactive diagram: https://gitdiagram.com/s3ansh33p/unilan
- Repository: https://github.com/s3ansh33p/unilan

## Overview

UniLAN Panel runs CS2 server instances and provides LAN users with live server control, event scheduling, and tournament management. The principal workflow is an admin launch/control request through the protected web handler to Docker, then server broadcast data flows through the CSTV relay and tracker into live status and tournament scores. Tournament setup, registration, seeding, match/game configuration, veto, and score recording are distinct stages backed by SQLite. README documents additional public/admin views and real-time updates; routes, handlers, and tracker excerpts establish representative wiring, while unsampled subsystem links are kept conservative.

Main entry points: [`panel/internal/web/handler.go`](https://github.com/s3ansh33p/unilan/blob/main/panel/internal/web/handler.go) (Web handlers), [`panel/internal/web/routes.go`](https://github.com/s3ansh33p/unilan/blob/main/panel/internal/web/routes.go) (HTTP routes), [`panel/internal/db/db.go`](https://github.com/s3ansh33p/unilan/blob/main/panel/internal/db/db.go) (SQLite data), [`panel/internal/games/cs2/tracker/tracker.go`](https://github.com/s3ansh33p/unilan/blob/main/panel/internal/games/cs2/tracker/tracker.go) (Game tracker)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_web["Web and access"]
  node_routes["HTTP routes<br/>[routes.go]"]
  node_auth["Session auth<br/>[auth.go]"]
  node_handlers["Web handlers<br/>[handler.go]"]
  node_realtime["WebSocket hub<br/>[wshub.go]"]
  node_ui["Panel UI<br/>[admin.js]"]
  node_publicui["Public UI<br/>[app.js]"]
end

subgraph group_servers["Server operations"]
  node_docker["Container manager<br/>[docker.go]"]
  node_launcher["Launch config<br/>[launch.go]"]
  node_rcon["RCON control<br/>[rcon.go]"]
  node_cs2web["CS2 endpoints<br/>[cs2web.go]"]
end

subgraph group_live["Live game data"]
  node_relay["CSTV relay<br/>[relay.go]"]
  node_tracker["Game tracker<br/>[tracker.go]"]
end

subgraph group_events["Events and tournaments"]
  node_database[("SQLite data<br/>[db.go]")]
  node_schedule["Event schedule<br/>[schedule.go]"]
  node_tournament["Tournament setup<br/>[tournament.go]"]
  node_teams["Team registration<br/>[teams.go]"]
  node_bracket["Bracket / scoring<br/>[bracket.go]"]
  node_games["Match games<br/>[games.go]"]
  node_veto["Map veto<br/>[veto.go]"]
end

node_admin(("Event admin"))
node_player(("Player / viewer"))
node_cs2server{{"CS2 server"}}

node_admin -->|"uses"| node_routes
node_player -->|"browses"| node_routes
node_routes -->|"guards"| node_auth
node_routes -->|"dispatches"| node_handlers
node_handlers -->|"manages servers"| node_docker
node_handlers -->|"sends commands"| node_rcon
node_handlers -->|"reads/writes"| node_database
node_handlers -->|"publishes updates"| node_realtime
node_ui -->|"requests"| node_routes
node_publicui -->|"requests"| node_routes
node_docker -->|"starts/stops"| node_cs2server
node_cs2server -->|"posts fragments"| node_relay
node_routes -->|"serves streams"| node_relay
node_tracker -->|"reads broadcast"| node_relay
node_handlers -->|"reads live state"| node_tracker
node_tracker -->|"emits game updates"| node_realtime
node_handlers -->|"manages schedule"| node_schedule
node_handlers -->|"manages tournaments"| node_tournament
node_handlers -->|"manages teams"| node_teams
node_handlers -->|"seeds/records results"| node_bracket
node_handlers -->|"configures games"| node_games
node_handlers -->|"manages veto"| node_veto
node_games -->|"links server tracking"| node_tracker
node_tracker -->|"records scores"| node_bracket
node_realtime -->|"streams updates"| node_ui
node_realtime -->|"streams updates"| node_publicui
node_tournament -->|"persists"| node_database
node_teams -->|"persists"| node_database
node_bracket -->|"persists"| node_database
node_games -->|"persists"| node_database
node_veto -->|"persists"| node_database
node_schedule -->|"persists"| node_database

click node_routes "https://github.com/s3ansh33p/unilan/blob/main/panel/internal/web/routes.go"
click node_auth "https://github.com/s3ansh33p/unilan/blob/main/panel/internal/auth/auth.go"
click node_handlers "https://github.com/s3ansh33p/unilan/blob/main/panel/internal/web/handler.go"
click node_realtime "https://github.com/s3ansh33p/unilan/blob/main/panel/internal/web/wshub.go"
click node_ui "https://github.com/s3ansh33p/unilan/blob/main/panel/web/static/admin.js"
click node_publicui "https://github.com/s3ansh33p/unilan/blob/main/panel/web/static/app.js"
click node_docker "https://github.com/s3ansh33p/unilan/blob/main/panel/internal/docker/docker.go"
click node_launcher "https://github.com/s3ansh33p/unilan/blob/main/panel/internal/docker/launch.go"
click node_rcon "https://github.com/s3ansh33p/unilan/blob/main/panel/internal/games/cs2/rcon/rcon.go"
click node_cs2web "https://github.com/s3ansh33p/unilan/blob/main/panel/internal/games/cs2/web/cs2web.go"
click node_relay "https://github.com/s3ansh33p/unilan/blob/main/panel/internal/games/cs2/cstv/relay.go"
click node_tracker "https://github.com/s3ansh33p/unilan/blob/main/panel/internal/games/cs2/tracker/tracker.go"
click node_database "https://github.com/s3ansh33p/unilan/blob/main/panel/internal/db/db.go"
click node_schedule "https://github.com/s3ansh33p/unilan/blob/main/panel/internal/db/schedule.go"
click node_tournament "https://github.com/s3ansh33p/unilan/blob/main/panel/internal/db/tournament.go"
click node_teams "https://github.com/s3ansh33p/unilan/blob/main/panel/internal/db/teams.go"
click node_bracket "https://github.com/s3ansh33p/unilan/blob/main/panel/internal/db/bracket.go"
click node_games "https://github.com/s3ansh33p/unilan/blob/main/panel/internal/db/games.go"
click node_veto "https://github.com/s3ansh33p/unilan/blob/main/panel/internal/db/veto.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_routes,node_auth,node_handlers,node_realtime,node_ui,node_publicui,node_player toneBlue
class node_docker,node_launcher,node_rcon,node_cs2web toneAmber
class node_relay,node_tracker,node_cs2server toneMint
class node_database,node_schedule,node_tournament,node_teams,node_bracket,node_games,node_veto toneRose
class node_admin toneIndigo
```

## Components

### Web and access

- [HTTP routes](https://github.com/s3ansh33p/unilan/blob/main/panel/internal/web/routes.go): `panel/internal/web/routes.go`
- [Session auth](https://github.com/s3ansh33p/unilan/blob/main/panel/internal/auth/auth.go): `panel/internal/auth/auth.go`
- [Web handlers](https://github.com/s3ansh33p/unilan/blob/main/panel/internal/web/handler.go): `panel/internal/web/handler.go`
- [WebSocket hub](https://github.com/s3ansh33p/unilan/blob/main/panel/internal/web/wshub.go): `panel/internal/web/wshub.go`
- [Panel UI](https://github.com/s3ansh33p/unilan/blob/main/panel/web/static/admin.js): `panel/web/static/admin.js`
- [Public UI](https://github.com/s3ansh33p/unilan/blob/main/panel/web/static/app.js): `panel/web/static/app.js`

### Server operations

- [Container manager](https://github.com/s3ansh33p/unilan/blob/main/panel/internal/docker/docker.go): `panel/internal/docker/docker.go`
- [Launch config](https://github.com/s3ansh33p/unilan/blob/main/panel/internal/docker/launch.go): `panel/internal/docker/launch.go`
- [RCON control](https://github.com/s3ansh33p/unilan/blob/main/panel/internal/games/cs2/rcon/rcon.go): `panel/internal/games/cs2/rcon/rcon.go`
- [CS2 endpoints](https://github.com/s3ansh33p/unilan/blob/main/panel/internal/games/cs2/web/cs2web.go): `panel/internal/games/cs2/web/cs2web.go`

### Live game data

- [CSTV relay](https://github.com/s3ansh33p/unilan/blob/main/panel/internal/games/cs2/cstv/relay.go): `panel/internal/games/cs2/cstv/relay.go`
- [Game tracker](https://github.com/s3ansh33p/unilan/blob/main/panel/internal/games/cs2/tracker/tracker.go): `panel/internal/games/cs2/tracker/tracker.go`

### Events and tournaments

- [SQLite data](https://github.com/s3ansh33p/unilan/blob/main/panel/internal/db/db.go): `panel/internal/db/db.go`
- [Event schedule](https://github.com/s3ansh33p/unilan/blob/main/panel/internal/db/schedule.go): `panel/internal/db/schedule.go`
- [Tournament setup](https://github.com/s3ansh33p/unilan/blob/main/panel/internal/db/tournament.go): `panel/internal/db/tournament.go`
- [Team registration](https://github.com/s3ansh33p/unilan/blob/main/panel/internal/db/teams.go): `panel/internal/db/teams.go`
- [Bracket / scoring](https://github.com/s3ansh33p/unilan/blob/main/panel/internal/db/bracket.go): `panel/internal/db/bracket.go`
- [Match games](https://github.com/s3ansh33p/unilan/blob/main/panel/internal/db/games.go): `panel/internal/db/games.go`
- [Map veto](https://github.com/s3ansh33p/unilan/blob/main/panel/internal/db/veto.go): `panel/internal/db/veto.go`

### Other components

- **Event admin**
- **Player / viewer**
- **CS2 server**

## Connections

- Event admin → HTTP routes: uses
- Player / viewer → HTTP routes: browses
- HTTP routes → Session auth: guards
- HTTP routes → Web handlers: dispatches
- Web handlers → Container manager: manages servers
- Web handlers → RCON control: sends commands
- Web handlers → SQLite data: reads/writes
- Web handlers → WebSocket hub: publishes updates
- Panel UI → HTTP routes: requests
- Public UI → HTTP routes: requests
- Container manager → CS2 server: starts/stops
- CS2 server → CSTV relay: posts fragments
- HTTP routes → CSTV relay: serves streams
- Game tracker → CSTV relay: reads broadcast
- Web handlers → Game tracker: reads live state
- Game tracker → WebSocket hub: emits game updates
- Web handlers → Event schedule: manages schedule
- Web handlers → Tournament setup: manages tournaments
- Web handlers → Team registration: manages teams
- Web handlers → Bracket / scoring: seeds/records results
- Web handlers → Match games: configures games
- Web handlers → Map veto: manages veto
- Match games → Game tracker: links server tracking
- Game tracker → Bracket / scoring: records scores
- WebSocket hub → Panel UI: streams updates
- WebSocket hub → Public UI: streams updates
- Tournament setup → SQLite data: persists
- Team registration → SQLite data: persists
- Bracket / scoring → SQLite data: persists
- Match games → SQLite data: persists
- Map veto → SQLite data: persists
- Event schedule → SQLite data: persists
