# aether-panel/panel architecture

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

- Interactive diagram: https://gitdiagram.com/aether-panel/panel
- Repository: https://github.com/aether-panel/panel

## Overview

#### Purpose and entry points
Aether Panel (internal SkyPanel) is a modular Go control plane for hosting and operating game servers, with a bundled Astro/React administration UI. The main executable and operational CLI live in `cmd/panel/main.go`, `cmd/panel/run.go`, and `cmd/panel/runservice.go`; database/user administration commands are adjacent in `cmd/panel/db*.go` and `cmd/panel/user.go`.

#### HTTP, API, and authentication boundary
Gin-based web loading separates public/authenticated API, OAuth2, daemon/node-facing endpoints, and Swagger documentation. Route domains include server lifecycle, nodes, templates, users, roles, databases, settings, and AI:
- `internal/web/loader.go`
- `internal/web/api/loader.go`
- `internal/web/auth/loader.go`
- `internal/web/daemon/server.go`
- `internal/web/oauth2/loader.go`

Middleware enforces database context, sessions/authentication, API-key access, decryption, and version constraints before handlers reach services: `internal/middleware/middleware.go`, `internal/middleware/auth.go`, `internal/middleware/api_key_auth.go`.

#### Domain services and persistence
Service-layer packages implement business operations for servers, users/permissions, sessions/tokens, backups, nodes, templates, SFTP, notifications, and integrations. GORM-backed models form the persistence contract, supporting SQLite, MySQL/MariaDB, PostgreSQL, and SQL Server. Database initialization and upgrades are centralized rather than embedded in handlers:
- `internal/services/server.go`
- `internal/services/user.go`
- `internal/services/templates.go`
- `internal/models/server.go`
- `internal/database/loader.go`
- `internal/database/upgrade.go`

#### Server lifecycle and execution backends
Server management loads template-defined operations, schedules work, tracks processes, and delegates execution through one of two isolation adapters: Docker containers or host TTY processes under Linux namespace isolation. This is the principal boundary between panel business logic and managed game workloads:
- `internal/servers/server.go`
- `internal/servers/server_loader.go`
- `internal/servers/scheduler.go`
- `internal/servers/docker/docker.go`
- `internal/servers/tty/tty.go`

Reusable execution contracts and operation/template structures are exposed in `pkg/skypanel/engine.go`, `pkg/skypanel/operation.go`, and `pkg/skypanel/server.go`. Concrete operations download runtimes/content, manipulate files, execute commands, and provision games; e.g. `internal/operations/command/command.go`, `internal/operations/dockerpull/dockerpull.go`, `internal/operations/steamgamedl/steamgamedl.go`.

#### Remote nodes, file access, and live control
The panel supports distributed Panel-plus-node deployments via daemon endpoints and node services. It provides integrated Go SSH/SFTP access and console/metrics-style live interfaces, while server connections support RCON, WebSocket RCON, and Telnet:
- `internal/services/node.go`
- `internal/web/daemon/root.go`
- `internal/sftp/server.go`
- `internal/connections/rcon.go`
- `internal/connections/rconws.go`

#### Frontend application
Astro pages host React feature views; shared providers/configuration and `api-client` define the UI-to-REST boundary. Server detail views expose console, files, editor, backups, databases, users, SFTP, settings, plugins, transfers, and metrics:
- `client/frontend/src/layouts/BaseLayout.astro`
- `client/frontend/src/lib/api-client.ts`
- `client/frontend/src/contexts/providers.tsx`
- `client/frontend/src/features/servers/[id]/page.tsx`
- `client/frontend/src/features/servers/[id]/console-view.tsx`
- `client/frontend/src/features/servers/[id]/file-manager-view.tsx`

#### External services and deployment
Notification adapters support SMTP, Mailgun, Mailjet, SendGrid, and Discord; email templates are embedded under `assets/email/`. Optional GenAI-backed assistance is represented at both API and frontend flow layers. Docker images/Compose configurations package the panel and game runtime variants; systemd assets support host installation:
- `internal/email/provider.go`
- `internal/services/discord.go`
- `internal/web/api/ai.go`
- `client/frontend/src/ai/genkit.ts`
- `Dockerfile`
- `docker-compose.yml`
- `internal/systemd/servicefiles/skypanel.service`

Main entry points: [`internal/services/server.go`](https://github.com/aether-panel/panel/blob/main/internal/services/server.go) (Domain services), [`internal/servers/server.go`](https://github.com/aether-panel/panel/blob/main/internal/servers/server.go) (Server manager), [`internal/middleware/middleware.go`](https://github.com/aether-panel/panel/blob/main/internal/middleware/middleware.go) (Security middleware), [`internal/web/api/loader.go`](https://github.com/aether-panel/panel/blob/main/internal/web/api/loader.go) (REST API)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_entry["Control Plane"]
  node_cli["Panel CLI<br/>Go executable<br/>[main.go]"]
  node_deployment["Container deployment<br/>deployment packaging<br/>[docker-compose.yml]"]
end

subgraph group_web["HTTP Boundary"]
  node_web_loader["Web loader<br/>Gin bootstrap<br/>[loader.go]"]
  node_api["REST API<br/>API routes<br/>[loader.go]"]
  node_auth["Auth &amp; OAuth2<br/>route domain<br/>[loader.go]"]
  node_daemon_api["Node daemon API<br/>daemon routes<br/>[root.go]"]
  node_middleware["Security middleware<br/>Gin middleware<br/>[middleware.go]"]
end

subgraph group_domain["Domain &amp; Persistence"]
  node_services["Domain services<br/>business layer<br/>[server.go]"]
  node_models["GORM models<br/>persistence contract<br/>[server.go]"]
  node_database[("Database lifecycle<br/>database bootstrap<br/>[loader.go]")]
  node_node_service["Remote node service<br/>distributed node control<br/>[node.go]"]
  node_notifications["Notifications<br/>external adapters<br/>[provider.go]"]
end

subgraph group_runtime["Server Runtime"]
  node_server_manager["Server manager<br/>lifecycle orchestration<br/>[server.go]"]
  node_scheduler["Operation scheduler<br/>job scheduler<br/>[scheduler.go]"]
  node_engine["Engine contracts<br/>public Go contracts<br/>[engine.go]"]
  node_operations["Concrete operations<br/>workload provisioning<br/>[command.go]"]
  node_docker{{"Docker backend<br/>isolation adapter<br/>[docker.go]"}}
  node_tty{{"TTY backend<br/>isolation adapter<br/>[tty.go]"}}
  node_live_access["Live access<br/>SFTP and game connections<br/>[server.go]"]
end

subgraph group_ui["Administration UI"]
  node_frontend["Astro/React admin UI<br/>web application<br/>[BaseLayout.astro]"]
  node_api_client["API client<br/>frontend REST boundary<br/>[api-client.ts]"]
end

node_cli -->|"starts"| node_web_loader
node_deployment -->|"packages"| node_cli
node_web_loader -->|"applies"| node_middleware
node_middleware -->|"guards"| node_api
node_middleware -->|"guards"| node_auth
node_middleware -->|"guards"| node_daemon_api
node_frontend -->|"uses"| node_api_client
node_api_client -->|"REST requests"| node_api
node_api -->|"invokes"| node_services
node_auth -->|"invokes"| node_services
node_daemon_api -->|"controls"| node_node_service
node_services -->|"persists through"| node_models
node_models -->|"stored in"| node_database
node_services -->|"orchestrates"| node_server_manager
node_services -->|"manages"| node_node_service
node_services -->|"sends"| node_notifications
node_server_manager -->|"schedules"| node_scheduler
node_scheduler -->|"runs"| node_operations
node_operations -->|"implements"| node_engine
node_server_manager -->|"executes via"| node_docker
node_server_manager -->|"executes via"| node_tty
node_server_manager -->|"exposes"| node_live_access
node_node_service -.->|"connects through"| node_daemon_api

click node_cli "https://github.com/aether-panel/panel/blob/main/cmd/panel/main.go"
click node_web_loader "https://github.com/aether-panel/panel/blob/main/internal/web/loader.go"
click node_api "https://github.com/aether-panel/panel/blob/main/internal/web/api/loader.go"
click node_auth "https://github.com/aether-panel/panel/blob/main/internal/web/auth/loader.go"
click node_daemon_api "https://github.com/aether-panel/panel/blob/main/internal/web/daemon/root.go"
click node_middleware "https://github.com/aether-panel/panel/blob/main/internal/middleware/middleware.go"
click node_services "https://github.com/aether-panel/panel/blob/main/internal/services/server.go"
click node_models "https://github.com/aether-panel/panel/blob/main/internal/models/server.go"
click node_database "https://github.com/aether-panel/panel/blob/main/internal/database/loader.go"
click node_server_manager "https://github.com/aether-panel/panel/blob/main/internal/servers/server.go"
click node_scheduler "https://github.com/aether-panel/panel/blob/main/internal/servers/scheduler.go"
click node_engine "https://github.com/aether-panel/panel/blob/main/pkg/skypanel/engine.go"
click node_operations "https://github.com/aether-panel/panel/blob/main/internal/operations/command/command.go"
click node_docker "https://github.com/aether-panel/panel/blob/main/internal/servers/docker/docker.go"
click node_tty "https://github.com/aether-panel/panel/blob/main/internal/servers/tty/tty.go"
click node_node_service "https://github.com/aether-panel/panel/blob/main/internal/services/node.go"
click node_live_access "https://github.com/aether-panel/panel/blob/main/internal/sftp/server.go"
click node_frontend "https://github.com/aether-panel/panel/blob/main/client/frontend/src/layouts/BaseLayout.astro"
click node_api_client "https://github.com/aether-panel/panel/blob/main/client/frontend/src/lib/api-client.ts"
click node_notifications "https://github.com/aether-panel/panel/blob/main/internal/email/provider.go"
click node_deployment "https://github.com/aether-panel/panel/blob/main/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_cli,node_deployment toneBlue
class node_web_loader,node_api,node_auth,node_daemon_api,node_middleware toneAmber
class node_services,node_models,node_database,node_node_service,node_notifications toneMint
class node_server_manager,node_scheduler,node_engine,node_operations,node_docker,node_tty,node_live_access toneRose
class node_frontend,node_api_client toneIndigo
```

## Components

### Control Plane

- [Panel CLI](https://github.com/aether-panel/panel/blob/main/cmd/panel/main.go): Go executable · Runs the panel and operational administration commands. · `cmd/panel/main.go`
- [Container deployment](https://github.com/aether-panel/panel/blob/main/docker-compose.yml): deployment packaging · `docker-compose.yml`

### HTTP Boundary

- [Web loader](https://github.com/aether-panel/panel/blob/main/internal/web/loader.go): Gin bootstrap · `internal/web/loader.go`
- [REST API](https://github.com/aether-panel/panel/blob/main/internal/web/api/loader.go): API routes · Public and authenticated management endpoints. · `internal/web/api/loader.go`
- [Auth & OAuth2](https://github.com/aether-panel/panel/blob/main/internal/web/auth/loader.go): route domain · `internal/web/auth/loader.go`
- [Node daemon API](https://github.com/aether-panel/panel/blob/main/internal/web/daemon/root.go): daemon routes · Node-facing remote control endpoints. · `internal/web/daemon/root.go`
- [Security middleware](https://github.com/aether-panel/panel/blob/main/internal/middleware/middleware.go): Gin middleware · Applies database context, sessions, API keys, decryption, and version checks. · `internal/middleware/middleware.go`

### Domain & Persistence

- [Domain services](https://github.com/aether-panel/panel/blob/main/internal/services/server.go): business layer · Manages servers, users, nodes, templates, backups, and integrations. · `internal/services/server.go`
- [GORM models](https://github.com/aether-panel/panel/blob/main/internal/models/server.go): persistence contract · `internal/models/server.go`
- [Database lifecycle](https://github.com/aether-panel/panel/blob/main/internal/database/loader.go): database bootstrap · Initializes and upgrades supported SQL databases. · `internal/database/loader.go`
- [Remote node service](https://github.com/aether-panel/panel/blob/main/internal/services/node.go): distributed node control · `internal/services/node.go`
- [Notifications](https://github.com/aether-panel/panel/blob/main/internal/email/provider.go): external adapters · Delivers email and Discord notifications through provider adapters. · `internal/email/provider.go`

### Server Runtime

- [Server manager](https://github.com/aether-panel/panel/blob/main/internal/servers/server.go): lifecycle orchestration · Loads servers and template-defined lifecycle work. · `internal/servers/server.go`
- [Operation scheduler](https://github.com/aether-panel/panel/blob/main/internal/servers/scheduler.go): job scheduler · `internal/servers/scheduler.go`
- [Engine contracts](https://github.com/aether-panel/panel/blob/main/pkg/skypanel/engine.go): public Go contracts · Defines reusable server, operation, and execution abstractions. · `pkg/skypanel/engine.go`
- [Concrete operations](https://github.com/aether-panel/panel/blob/main/internal/operations/command/command.go): workload provisioning · Downloads content, changes files, and runs provisioning commands. · `internal/operations/command/command.go`
- [Docker backend](https://github.com/aether-panel/panel/blob/main/internal/servers/docker/docker.go): isolation adapter · `internal/servers/docker/docker.go`
- [TTY backend](https://github.com/aether-panel/panel/blob/main/internal/servers/tty/tty.go): isolation adapter · Host processes isolated with Linux namespaces. · `internal/servers/tty/tty.go`
- [Live access](https://github.com/aether-panel/panel/blob/main/internal/sftp/server.go): SFTP and game connections · Provides SFTP plus RCON, WebSocket RCON, and Telnet control. · `internal/sftp/server.go`

### Administration UI

- [Astro/React admin UI](https://github.com/aether-panel/panel/blob/main/client/frontend/src/layouts/BaseLayout.astro): web application · Server views provide console, file, backup, database, and settings workflows. · `client/frontend/src/layouts/BaseLayout.astro`
- [API client](https://github.com/aether-panel/panel/blob/main/client/frontend/src/lib/api-client.ts): frontend REST boundary · `client/frontend/src/lib/api-client.ts`

## Connections

- Panel CLI → Web loader: starts
- Container deployment → Panel CLI: packages
- Web loader → Security middleware: applies
- Security middleware → REST API: guards
- Security middleware → Auth & OAuth2: guards
- Security middleware → Node daemon API: guards
- Astro/React admin UI → API client: uses
- API client → REST API: REST requests
- REST API → Domain services: invokes
- Auth & OAuth2 → Domain services: invokes
- Node daemon API → Remote node service: controls
- Domain services → GORM models: persists through
- GORM models → Database lifecycle: stored in
- Domain services → Server manager: orchestrates
- Domain services → Remote node service: manages
- Domain services → Notifications: sends
- Server manager → Operation scheduler: schedules
- Operation scheduler → Concrete operations: runs
- Concrete operations → Engine contracts: implements
- Server manager → Docker backend: executes via
- Server manager → TTY backend: executes via
- Server manager → Live access: exposes
- Remote node service → Node daemon API: connects through
