-
Couldn't load subscription status.
- Fork 0
Developer Documentation
JLangisch edited this page Apr 1, 2025
·
2 revisions
The Stationeers Server UI provides comprehensive management for Stationeers dedicated servers through both web and Discord interfaces. This documentation outlines the codebase architecture, components, and integration points for developers.
The system employs a layered architecture with clear separation of concerns:
flowchart TD
%% Core Systems with expanded subsystems
subgraph "Core Systems"
direction TB
subgraph "Configuration Manager"
Config["Config Manager<br>โข Config & Secrets<br>โข Environment Integration"]:::config
end
subgraph "Core Operations"
direction TB
ArgBuilder["Argument Builder<br>โข Command-line Construction<br>โข Platform-specific Args"]:::core
ProcMgmt["Process Management<br>โข Server Start/Stop<br>โข Process Lifecycle"]:::core
CoreMain["Core Main<br>โข Application Lifecycle<br>โข Component Orchestration"]:::core
subgraph "Log Collection"
direction LR
LogWin["Windows Log Collector<br>โข StdOut/StdErr Pipes"]:::core
LogLin["Linux Log Collector<br>โข Log File Tailing"]:::core
end
APIEndpoints["API Endpoints<br>โข HTTP Server<br>โข Request Handling"]:::core
ConfigAPI["Configuration API<br>โข Config Updates<br>โข Settings UI"]:::core
UIServing["UI Serving<br>โข Static Content<br>โข Template Rendering"]:::core
BackupMgmt["Backup Management<br>(Legacy System)"]:::core
end
Sec["Security Module<br>โข Authentication<br>โข Authorization<br>โข TLS Management"]:::security
end
%% Real-time Systems
subgraph "Real-time Systems"
direction TB
Det["Detection Module<br>โข Log Analysis<br>โข Event Classification<br>โข Pattern Management"]:::detector
subgraph "SSE Module"
direction LR
SSEMgr["SSE Manager<br>โข Connection Management"]:::sse
LogStream["Log Stream<br>โข Console Output"]:::sse
EventStream["Event Stream<br>โข Detection Events"]:::sse
end
end
%% Integration Systems
subgraph "Integration Systems"
direction TB
Disc["Discord Integration<br>โข Bot Management<br>โข Commands & Status<br>โข Internal Log Detection (Legacy)"]:::discord
Install["Installation & Auto-Updater<br>โข SteamCMD Integration<br>โข Updates"]:::installer
end
%% Frontend Layer
subgraph "Frontend Layer"
direction TB
AdminUI["Admin Interface<br>โข Dashboard<br>โข Server Controls"]:::frontend
ConfigUI["Configuration Editor<br>โข Server Settings"]:::frontend
DetectUI["Detection Manager<br>โข Pattern Editor"]:::frontend
ConsoleUI["Real-time Console<br>โข Log Viewer"]:::frontend
end
%% External Systems
subgraph "External Systems"
direction LR
DS["Discord Service"]:::external
GS["Game Server<br>(Stationeers)"]:::external
end
%% Deployment Layer
subgraph "Deployment"
Deploy["Containerization & Deployment"]:::deployment
end
%% Configuration Flows
Config -->|"Provides Secrets"| Sec
Config -->|"Loads Configuration"| ProcMgmt
Config -->|"Settings"| ArgBuilder
Config -->|"Server Options"| ConfigAPI
ConfigUI -->|"Updates"| Config
%% Core & Process Management Flows
CoreMain -->|"Controls"| ProcMgmt
ArgBuilder -->|"Builds Command Args"| ProcMgmt
ProcMgmt -->|"Platform Detection"| LogWin
ProcMgmt -->|"Platform Detection"| LogLin
ProcMgmt -->|"Manages Process"| GS
%% Log Collection Flows
GS -->|"Windows: Pipes Output"| LogWin
GS -->|"Linux: Writes File"| LogLin
LogWin -->|"Console Output"| LogStream
LogLin -->|"Console Output"| LogStream
%% API and UI Flows
APIEndpoints -->|"Routes Requests"| ProcMgmt
APIEndpoints -->|"Routes Requests"| ConfigAPI
APIEndpoints -->|"Routes Requests"| UIServing
UIServing -->|"Serves"| AdminUI
UIServing -->|"Serves"| ConfigUI
UIServing -->|"Serves"| DetectUI
UIServing -->|"Serves"| ConsoleUI
ConfigAPI -->|"Updates"| Config
%% SSE Flows
LogStream -->|"Broadcasts"| SSEMgr
SSEMgr -->|"Streams"| ConsoleUI
LogStream -->|"Forwards Logs"| Det
Det -->|"Publishes Events"| EventStream
EventStream -->|"Broadcasts"| SSEMgr
%% Security & Authentication
Sec -->|"Secures"| APIEndpoints
AdminUI -->|"Authenticates via"| Sec
%% Discord Integration
Disc <-->|"Bot Commands"| DS
Disc -->|"Internal Call"| ProcMgmt
LogStream -->|"Forwards Logs"| Disc
EventStream -->|"Forwards Events"| Disc
Disc -->|"Sends Logs & Events"| DS
%% Installation & Updates
CoreMain -->|"Triggers"| Install
Install -->|"Updates"| GS
%% Deployment
Deploy -->|"Runs Services"| Config
%% Frontend to Config Layer connections
AdminUI -->|"Reads/Updates"| Config
DetectUI -->|"Configures"| Det
%% Styling classes - Dark mode friendly colors
classDef config fill:#3a506b,stroke:#5bc0be,stroke-width:2px,color:#ffffff
classDef core fill:#1b263b,stroke:#778da9,stroke-width:2px,color:#ffffff
classDef detector fill:#415a77,stroke:#0d1b2a,stroke-width:2px,color:#ffffff
classDef discord fill:#7209b7,stroke:#f72585,stroke-width:2px,color:#ffffff
classDef installer fill:#4361ee,stroke:#4cc9f0,stroke-width:2px,color:#ffffff
classDef security fill:#7b2cbf,stroke:#c77dff,stroke-width:2px,color:#ffffff
classDef sse fill:#560bad,stroke:#f72585,stroke-width:2px,color:#ffffff
classDef frontend fill:#4d194d,stroke:#ff758f,stroke-width:2px,color:#ffffff
classDef external fill:#006400,stroke:#90ee90,stroke-width:2px,color:#ffffff
classDef deployment fill:#774936,stroke:#e09f3e,stroke-width:2px,color:#ffffff
flowchart LR
%% Core Systems
subgraph "Core Systems"
Config["Configuration Manager<br>โข Config & Secrets<br>โข Environment Integration"]:::config
Core["Core Operations<br>โข Process Management<br>โข Backup Handling<br>โข API Endpoints<br>โข Log Collection (serverlog.go)"]:::core
Sec["Security Module<br>โข Authentication<br>โข Authorization<br>โข TLS Management"]:::security
end
%% Real-time Systems
subgraph "Real-time Systems"
Det["Detection Module<br>โข Log Analysis<br>โข Event Classification<br>โข Pattern Management"]:::detector
SSE["SSE Module<br>โข Log Stream<br>โข Event Stream<br>โข Connection Management"]:::sse
end
%% Integration Systems
subgraph "Integration Systems"
Disc["Discord Integration<br>โข Bot Management<br>โข Commands & Status<br>โข Internal Log Detection (Legacy)"]:::discord
Install["Installation & Auto-Updater<br>โข SteamCMD Integration<br>โข Updates"]:::installer
end
%% Frontend Layer
subgraph "Frontend Layer"
UI["Web UI (UIMod)<br>โข Admin Interface<br>โข Real-time Console"]:::frontend
end
%% External Systems
subgraph "External Systems"
DS["Discord Service"]:::external
GS["Game Server<br>(Stationeers)"]:::external
end
%% Deployment Layer
subgraph "Deployment"
Deploy["Containerization & Deployment"]:::deployment
end
%% Primary Data Flows
Config -->|"Provides Secrets"| Sec
Config -->|"Loads Configuration"| Core
%% Core & Log Flow
Core -->|"Manages"| GS
GS -->|"Produces Logs"| Core
Core -->|"Broadcasts Logs"| SSE
SSE -->|"Forwards Logs"| Det
SSE -->|"Forwards Logs if Enabled"| Disc
%% Event Flow
Det -->|"Publishes Events"| SSE
%% User Interface Flows
Core -->|"Provides API"| UI
SSE -->|"Streams (Logs & Events)"| UI
%% Security & Authentication
Sec -->|"Secures"| Core
UI -->|"Authenticates via"| Sec
%% Discord Integration
Disc <-->|"Bot Commands"| DS
Core -->|"Status Updates"| Disc
%% Installation & Updates
Install -->|"Updates"| GS
Core -->|"Triggers"| Install
%% Deployment
Deploy -->|"Runs Services"| Core
%% Styling classes - Dark mode friendly colors
classDef config fill:#3a506b,stroke:#5bc0be,stroke-width:2px,color:#ffffff;
classDef core fill:#1b263b,stroke:#778da9,stroke-width:2px,color:#ffffff;
classDef detector fill:#415a77,stroke:#0d1b2a,stroke-width:2px,color:#ffffff;
classDef discord fill:#7209b7,stroke:#f72585,stroke-width:2px,color:#ffffff;
classDef installer fill:#4361ee,stroke:#4cc9f0,stroke-width:2px,color:#ffffff;
classDef security fill:#7b2cbf,stroke:#c77dff,stroke-width:2px,color:#ffffff;
classDef sse fill:#560bad,stroke:#f72585,stroke-width:2px,color:#ffffff;
classDef frontend fill:#4d194d,stroke:#ff758f,stroke-width:2px,color:#ffffff;
classDef external fill:#006400,stroke:#90ee90,stroke-width:2px,color:#ffffff;
classDef deployment fill:#774936,stroke:#e09f3e,stroke-width:2px,color:#ffffff;
%% Click Events for Component Mapping
click UI "https://github.com/jacksonthemaster/stationeersserverui/blob/main/UIMod/index.html" "Web UI code"
click Config "https://github.com/jacksonthemaster/stationeersserverui/blob/main/src/config/config.go" "Configuration code"
click Core "https://github.com/jacksonthemaster/stationeersserverui/blob/main/src/core/index.go" "Core operations code"
click Det "https://github.com/jacksonthemaster/stationeersserverui/blob/main/src/detection/detector.go" "Detection module code"
click SSE "https://github.com/jacksonthemaster/stationeersserverui/blob/main/src/ssestream/ssemanager.go" "SSE manager code"
click Disc "https://github.com/jacksonthemaster/stationeersserverui/blob/main/src/discord/discord.go" "Discord integration code"
click Install "https://github.com/jacksonthemaster/stationeersserverui/blob/main/src/install/install.go" "Installation code"
click Sec "https://github.com/jacksonthemaster/stationeersserverui/blob/main/src/security/auth.go" "Security module code"
click Deploy "https://github.com/jacksonthemaster/stationeersserverui/tree/main/Dockerfile" "Deployment files"
| Aspect | Details |
|---|---|
| Responsibilities | โข Centralized configuration โข Secrets handling โข Environment variable integration |
| Key Files | โข config.go: Main configuration structureโข secrets.go: Sensitive data handling |
| Key Features | โข JSON configuration with env overrides โข Automatic JWT key generation โข Config validation and defaults โข Debug mode logging |
| Aspect | Details |
|---|---|
| Responsibilities | โข Server process management โข Backup handling โข Configuration API endpoints โข HTTP server setup |
| Key Files | โข processmanagement.go: Process controlโข backups.go: Backup managementโข configuration.go: API handlersโข serverlog.go: Log streaming |
| Key Features | โข Cross-platform process management โข Intelligent backup rotation โข Configuration persistence โข Server argument building |
| Aspect | Details |
|---|---|
| Responsibilities | โข Real-time log analysis โข Event detection and classification โข Custom pattern management |
| Key Files | โข detector.go: Core detection engineโข handlers.go: Default event handlersโข customdetections.go: User-defined patternsโข logstream.go: Log processing pipeline |
| Key Features | โข Regex and keyword matching โข Custom detection rules โข Event classification system โข Extensible handler architecture |
| Aspect | Details |
|---|---|
| Responsibilities | โข Discord bot management โข Command processing โข Status updates โข Reaction-based controls |
| Key Files | โข discord.go: Bot initializationโข handleCommands.go: Command processingโข reactControl.go: Reaction interactionsโข sendMessage.go: Message distribution |
| Key Features | โข Rich Discord integration โข Interactive control panel โข Real-time status updates โข Comprehensive command set |
| Aspect | Details |
|---|---|
| Responsibilities | โข Initial setup โข SteamCMD integration โข Dependency management |
| Key Files | โข install.go: Main installation logicโข steamcmd.go: SteamCMD wrapperโข steamcmd-helper.go: SteamCMD utilities |
| Key Features | โข Automatic SteamCMD installation โข Cross-platform support โข Game server updates โข Dependency checking |
| Aspect | Details |
|---|---|
| Responsibilities | โข Authentication โข Authorization โข TLS management |
| Key Files | โข auth.go: JWT-based authenticationโข tls.go: Certificate management |
| Key Features | โข JWT authentication โข Secure cookie handling โข Automatic TLS certificate generation โข Role-based access control |
| Aspect | Details |
|---|---|
| Responsibilities | โข Real-time event streaming โข Connection management โข Message broadcasting |
| Key Files | โข ssemanager.go: Core SSE implementationโข sseutils.go: Utility functions |
| Key Features | โข Efficient message broadcasting โข Connection limits โข Non-blocking design โข Multiple stream types |
The web interface provides a user-friendly management console with:
- HTML/CSS/JS admin interface
- Configuration pages for server settings
- Detection manager for custom patterns
- Real-time console via SSE
- Error Handling: Comprehensive error checking and recovery
- Logging: Verbose logging in debug mode
- Concurrency: Careful use of mutexes for shared state
- Documentation: Extensive code comments
- Testing: Important areas have debug modes
- Go
- Git
- 10gb Hard disk space
- Clone the repository
- Run
go mod tidyto install dependencies - Build the application with
go run ./build.go
1. Add to detection.DefaultHandlers()
2. Define in detection.EventType
3. Add regex pattern in detector.go
1. Add route in main.go
2. Create http handler in core package
3. Add frontend integration if possible - all features should be available on the UI.
1. Add command handler in handleCommands.go
2. Define new reaction in reactControl.go
3. Add message formatting if needed
| Area | Consideration |
|---|---|
| Log Processing | Heavy regex can impact performance |
| Discord Rate Limits | Message batching implemented |
| Backup Operations | File operations are async where possible |
| Area | Implementation |
|---|---|
| Authentication | JWT with configurable expiration |
| TLS | Auto-generated certs with 90-day validity |
| Secrets | Environment variable fallbacks |
| Input Validation | Critical for commands and config |
- Advanced backup retention strategies
- rebuild Discord integration based on Detector (has own detection logic from v2, detector was rebuild generalized based on discord code in v4)
| Issue | Solution |
|---|---|
| SteamCMD Failures | Check dependencies in Wiki |
| Authentication Problems | Verify JWT key and your cookie settings |
| Backup Issues | Check filesystem permissions and folders. |
For specific implementation details, refer to the inline code comments and the user wiki for end-user documentation. Alternatively, create an issue and I will be more than happy to help.