# bitsnbytes25/warlock architecture

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

- Interactive diagram: https://gitdiagram.com/bitsnbytes25/warlock
- Repository: https://github.com/bitsnbytes25/warlock

## Overview

Warlock is a web-based manager for game servers distributed across Linux hosts. An administrator signs in, registers SSH-reachable hosts, selects a game to install, then manages its services, configuration, files, firewall, backups, and scheduled work through the interface. The server resolves application and host state, runs commands locally or over SSH, and stores account and historical metric data. The README documents several product capabilities whose route implementations were not excerpted; those branches are included as documented features, while detailed internal links are limited to relationships visible in the supplied source evidence.

Main entry points: [`app.js`](https://github.com/bitsnbytes25/warlock/blob/main/app.js) (Web application), [`libs/cmd_runner.mjs`](https://github.com/bitsnbytes25/warlock/blob/main/libs/cmd_runner.mjs) (Command execution), [`routes/application_install.js`](https://github.com/bitsnbytes25/warlock/blob/main/routes/application_install.js) (Game installation), [`routes/service_configure.js`](https://github.com/bitsnbytes25/warlock/blob/main/routes/service_configure.js) (Service management)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_access["Web access"]
  node_web_app["Web application<br/>[app.js]"]
  node_session_auth["Session validation"]
  node_install_ui["Game installation"]
  node_host_ui["Host management<br/>[host_add.js]"]
  node_service_ui["Service management"]
  node_files_api["File management<br/>[file.js]"]
  node_firewall_api["Firewall and ports<br/>[firewall.js]"]
  node_backup_routes["Backups and restore"]
end

subgraph group_catalog["Applications and hosts"]
  node_catalog_lookup["Application catalog"]
  node_host_state["Host state<br/>[host_data.mjs]"]
  node_app_validator["Host application validation"]
  node_service_validator["Host service validation"]
end

subgraph group_remote["Remote operations"]
  node_ssh_commands["Command execution<br/>[cmd_runner.mjs]"]
  node_command_stream["Command streaming<br/>[cmd_streamer.mjs]"]
  node_cache["Command cache<br/>[cache.mjs]"]
  node_cron_jobs["Scheduled jobs<br/>[cron.mjs]"]
end

subgraph group_observability["Metrics and persistence"]
  node_metrics_poll["Service metrics polling<br/>[metrics_poll.mjs]"]
  node_host_poll["Host metrics polling"]
  node_metrics_merge["Metric aggregation<br/>[metrics_merge.mjs]"]
  node_metric_queries["Service metrics"]
  node_diff_objects["Metric change detection<br/>[diff_objects.mjs]"]
  node_database[("SQLite data store<br/>[db.js]")]
  node_profiler["Command profiler<br/>[cmd_profiler.mjs]"]
  node_logger["Logging<br/>[logger.mjs]"]
  node_analytics["Usage analytics<br/>[push_analytics.mjs]"]
end

subgraph group_game_runtime["Game runtime"]
  node_game_service["Game service runtime<br/>[base_service.py]"]
  node_game_app["Game application base<br/>[base_app.py]"]
  node_service_config["Game configuration<br/>[base_config.py]"]
  node_service_templates["Service templates<br/>[http_service.py]"]
end

node_admin(("Administrator"))
node_external_host(("Managed Linux host"))

node_admin -->|"uses"| node_web_app
node_web_app -->|"protects routes"| node_session_auth
node_web_app -->|"routes requests"| node_install_ui
node_web_app -->|"routes requests"| node_host_ui
node_web_app -->|"routes requests"| node_service_ui
node_install_ui -.->|"installs games"| node_catalog_lookup
node_host_ui -.->|"manages hosts"| node_host_state
node_service_ui -->|"validates service"| node_service_validator
node_service_validator -->|"looks up apps"| node_catalog_lookup
node_service_validator -->|"loads host"| node_host_state
node_install_ui -->|"validates install"| node_app_validator
node_app_validator -->|"looks up apps"| node_catalog_lookup
node_install_ui -->|"streams install"| node_command_stream
node_install_ui -->|"runs commands"| node_ssh_commands
node_service_ui -->|"runs commands"| node_ssh_commands
node_files_api -.->|"manages files"| node_external_host
node_firewall_api -.->|"manages firewall"| node_external_host
node_backup_routes -.->|"stores backups"| node_external_host
node_ssh_commands -->|"executes remotely"| node_external_host
node_ssh_commands -->|"checks host"| node_database
node_ssh_commands -->|"caches results"| node_cache
node_ssh_commands -->|"records timings"| node_profiler
node_web_app -->|"starts polling"| node_metrics_poll
node_web_app -->|"starts aggregation"| node_metrics_merge
node_metrics_poll -->|"loads applications"| node_catalog_lookup
node_metrics_poll -->|"collects metrics"| node_metric_queries
node_metrics_merge -->|"writes metrics"| node_database
node_metric_queries -->|"collects remotely"| node_ssh_commands
node_metric_queries -->|"reads metrics"| node_database
node_service_ui -->|"checks changes"| node_diff_objects
node_diff_objects -.->|"compares metrics"| node_metric_queries
node_web_app -->|"initializes schema"| node_database
node_web_app -->|"records usage"| node_analytics
node_service_ui -->|"clears schedules"| node_cron_jobs
node_game_service -->|"uses base"| node_game_app
node_game_service -->|"controls systemd"| node_external_host
node_game_service -.->|"applies config"| node_service_config
node_service_templates -->|"extends runtime"| node_game_service

click node_web_app "https://github.com/bitsnbytes25/warlock/blob/main/app.js"
click node_session_auth "https://github.com/bitsnbytes25/warlock/blob/main/libs/validate_session.mjs"
click node_install_ui "https://github.com/bitsnbytes25/warlock/blob/main/routes/application_install.js"
click node_host_ui "https://github.com/bitsnbytes25/warlock/blob/main/routes/host_add.js"
click node_service_ui "https://github.com/bitsnbytes25/warlock/blob/main/routes/service_configure.js"
click node_files_api "https://github.com/bitsnbytes25/warlock/blob/main/routes/api/file.js"
click node_firewall_api "https://github.com/bitsnbytes25/warlock/blob/main/routes/api/firewall.js"
click node_backup_routes "https://github.com/bitsnbytes25/warlock/blob/main/routes/application_backups.js"
click node_catalog_lookup "https://github.com/bitsnbytes25/warlock/blob/main/libs/get_all_applications.mjs"
click node_host_state "https://github.com/bitsnbytes25/warlock/blob/main/libs/host_data.mjs"
click node_app_validator "https://github.com/bitsnbytes25/warlock/blob/main/libs/validate_host_application.mjs"
click node_service_validator "https://github.com/bitsnbytes25/warlock/blob/main/libs/validate_host_service.mjs"
click node_ssh_commands "https://github.com/bitsnbytes25/warlock/blob/main/libs/cmd_runner.mjs"
click node_command_stream "https://github.com/bitsnbytes25/warlock/blob/main/libs/cmd_streamer.mjs"
click node_cache "https://github.com/bitsnbytes25/warlock/blob/main/libs/cache.mjs"
click node_cron_jobs "https://github.com/bitsnbytes25/warlock/blob/main/libs/cron.mjs"
click node_metrics_poll "https://github.com/bitsnbytes25/warlock/blob/main/tasks/metrics_poll.mjs"
click node_host_poll "https://github.com/bitsnbytes25/warlock/blob/main/tasks/host_metrics_poll.mjs"
click node_metrics_merge "https://github.com/bitsnbytes25/warlock/blob/main/tasks/metrics_merge.mjs"
click node_metric_queries "https://github.com/bitsnbytes25/warlock/blob/main/libs/get_application_metrics.mjs"
click node_diff_objects "https://github.com/bitsnbytes25/warlock/blob/main/libs/diff_objects.mjs"
click node_database "https://github.com/bitsnbytes25/warlock/blob/main/db.js"
click node_profiler "https://github.com/bitsnbytes25/warlock/blob/main/libs/cmd_profiler.mjs"
click node_logger "https://github.com/bitsnbytes25/warlock/blob/main/libs/logger.mjs"
click node_analytics "https://github.com/bitsnbytes25/warlock/blob/main/libs/push_analytics.mjs"
click node_game_service "https://github.com/bitsnbytes25/warlock/blob/main/scriptlets/warlock/base_service.py"
click node_game_app "https://github.com/bitsnbytes25/warlock/blob/main/scriptlets/warlock/base_app.py"
click node_service_config "https://github.com/bitsnbytes25/warlock/blob/main/scriptlets/warlock/base_config.py"
click node_service_templates "https://github.com/bitsnbytes25/warlock/blob/main/scriptlets/warlock/http_service.py"

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_web_app,node_session_auth,node_install_ui,node_host_ui,node_service_ui,node_files_api,node_firewall_api,node_backup_routes toneBlue
class node_catalog_lookup,node_host_state,node_app_validator,node_service_validator toneAmber
class node_ssh_commands,node_command_stream,node_cache,node_cron_jobs toneMint
class node_metrics_poll,node_host_poll,node_metrics_merge,node_metric_queries,node_diff_objects,node_database,node_profiler,node_logger,node_analytics toneRose
class node_game_service,node_game_app,node_service_config,node_service_templates,node_admin,node_external_host toneIndigo
```

## Components

### Web access

- [Web application](https://github.com/bitsnbytes25/warlock/blob/main/app.js): `app.js`
- [Session validation](https://github.com/bitsnbytes25/warlock/blob/main/libs/validate_session.mjs): `libs/validate_session.mjs`
- [Game installation](https://github.com/bitsnbytes25/warlock/blob/main/routes/application_install.js): `routes/application_install.js`
- [Host management](https://github.com/bitsnbytes25/warlock/blob/main/routes/host_add.js): `routes/host_add.js`
- [Service management](https://github.com/bitsnbytes25/warlock/blob/main/routes/service_configure.js): `routes/service_configure.js`
- [File management](https://github.com/bitsnbytes25/warlock/blob/main/routes/api/file.js): `routes/api/file.js`
- [Firewall and ports](https://github.com/bitsnbytes25/warlock/blob/main/routes/api/firewall.js): `routes/api/firewall.js`
- [Backups and restore](https://github.com/bitsnbytes25/warlock/blob/main/routes/application_backups.js): `routes/application_backups.js`

### Applications and hosts

- [Application catalog](https://github.com/bitsnbytes25/warlock/blob/main/libs/get_all_applications.mjs): `libs/get_all_applications.mjs`
- [Host state](https://github.com/bitsnbytes25/warlock/blob/main/libs/host_data.mjs): `libs/host_data.mjs`
- [Host application validation](https://github.com/bitsnbytes25/warlock/blob/main/libs/validate_host_application.mjs): `libs/validate_host_application.mjs`
- [Host service validation](https://github.com/bitsnbytes25/warlock/blob/main/libs/validate_host_service.mjs): `libs/validate_host_service.mjs`

### Remote operations

- [Command execution](https://github.com/bitsnbytes25/warlock/blob/main/libs/cmd_runner.mjs): `libs/cmd_runner.mjs`
- [Command streaming](https://github.com/bitsnbytes25/warlock/blob/main/libs/cmd_streamer.mjs): `libs/cmd_streamer.mjs`
- [Command cache](https://github.com/bitsnbytes25/warlock/blob/main/libs/cache.mjs): `libs/cache.mjs`
- [Scheduled jobs](https://github.com/bitsnbytes25/warlock/blob/main/libs/cron.mjs): `libs/cron.mjs`

### Metrics and persistence

- [Service metrics polling](https://github.com/bitsnbytes25/warlock/blob/main/tasks/metrics_poll.mjs): `tasks/metrics_poll.mjs`
- [Host metrics polling](https://github.com/bitsnbytes25/warlock/blob/main/tasks/host_metrics_poll.mjs): `tasks/host_metrics_poll.mjs`
- [Metric aggregation](https://github.com/bitsnbytes25/warlock/blob/main/tasks/metrics_merge.mjs): `tasks/metrics_merge.mjs`
- [Service metrics](https://github.com/bitsnbytes25/warlock/blob/main/libs/get_application_metrics.mjs): `libs/get_application_metrics.mjs`
- [Metric change detection](https://github.com/bitsnbytes25/warlock/blob/main/libs/diff_objects.mjs): `libs/diff_objects.mjs`
- [SQLite data store](https://github.com/bitsnbytes25/warlock/blob/main/db.js): `db.js`
- [Command profiler](https://github.com/bitsnbytes25/warlock/blob/main/libs/cmd_profiler.mjs): `libs/cmd_profiler.mjs`
- [Logging](https://github.com/bitsnbytes25/warlock/blob/main/libs/logger.mjs): `libs/logger.mjs`
- [Usage analytics](https://github.com/bitsnbytes25/warlock/blob/main/libs/push_analytics.mjs): `libs/push_analytics.mjs`

### Game runtime

- [Game service runtime](https://github.com/bitsnbytes25/warlock/blob/main/scriptlets/warlock/base_service.py): `scriptlets/warlock/base_service.py`
- [Game application base](https://github.com/bitsnbytes25/warlock/blob/main/scriptlets/warlock/base_app.py): `scriptlets/warlock/base_app.py`
- [Game configuration](https://github.com/bitsnbytes25/warlock/blob/main/scriptlets/warlock/base_config.py): `scriptlets/warlock/base_config.py`
- [Service templates](https://github.com/bitsnbytes25/warlock/blob/main/scriptlets/warlock/http_service.py): `scriptlets/warlock/http_service.py`

### Other components

- **Administrator**
- **Managed Linux host**

## Connections

- Administrator → Web application: uses (evidence: `README.md`)
- Web application → Session validation: protects routes (evidence: `app.js`)
- Web application → Game installation: routes requests (evidence: `app.js`)
- Web application → Host management: routes requests (evidence: `app.js`)
- Web application → Service management: routes requests (evidence: `app.js`)
- Game installation → Application catalog: installs games (evidence: `README.md`)
- Host management → Host state: manages hosts (evidence: `README.md`)
- Service management → Host service validation: validates service (evidence: `routes/service_configure.js`)
- Host service validation → Application catalog: looks up apps (evidence: `libs/validate_host_service.mjs`)
- Host service validation → Host state: loads host (evidence: `libs/validate_host_service.mjs`)
- Game installation → Host application validation: validates install
- Host application validation → Application catalog: looks up apps (evidence: `libs/validate_host_application.mjs`)
- Game installation → Command streaming: streams install
- Game installation → Command execution: runs commands
- Service management → Command execution: runs commands
- File management → Managed Linux host: manages files (evidence: `README.md`)
- Firewall and ports → Managed Linux host: manages firewall (evidence: `README.md`)
- Backups and restore → Managed Linux host: stores backups (evidence: `README.md`)
- Command execution → Managed Linux host: executes remotely (evidence: `libs/cmd_runner.mjs`)
- Command execution → SQLite data store: checks host (evidence: `libs/cmd_runner.mjs`)
- Command execution → Command cache: caches results (evidence: `libs/cmd_runner.mjs`)
- Command execution → Command profiler: records timings (evidence: `libs/cmd_runner.mjs`)
- Web application → Service metrics polling: starts polling (evidence: `app.js`)
- Web application → Metric aggregation: starts aggregation (evidence: `app.js`)
- Service metrics polling → Application catalog: loads applications (evidence: `tasks/metrics_poll.mjs`)
- Service metrics polling → Service metrics: collects metrics (evidence: `tasks/metrics_poll.mjs`)
- Metric aggregation → SQLite data store: writes metrics (evidence: `tasks/metrics_merge.mjs`)
- Service metrics → Command execution: collects remotely (evidence: `libs/get_application_metrics.mjs`)
- Service metrics → SQLite data store: reads metrics (evidence: `libs/get_application_metrics.mjs`)
- Service management → Metric change detection: checks changes
- Metric change detection → Service metrics: compares metrics
- Web application → SQLite data store: initializes schema (evidence: `app.js`)
- Web application → Usage analytics: records usage (evidence: `app.js`)
- Service management → Scheduled jobs: clears schedules
- Game service runtime → Game application base: uses base (evidence: `scriptlets/warlock/base_service.py`)
- Game service runtime → Managed Linux host: controls systemd (evidence: `scriptlets/warlock/base_service.py`)
- Game service runtime → Game configuration: applies config
- Service templates → Game service runtime: extends runtime (evidence: `scriptlets/warlock/http_service.py`)
