# 000hen/justhostmc architecture

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

- Interactive diagram: https://gitdiagram.com/000hen/justhostmc
- Repository: https://github.com/000hen/justhostmc

## Overview

1. **Overall shape**
   - JustHostMC is a two-process Windows desktop system: a **WinUI 3 C# frontend** and a **Go backend engine**.
   - The frontend is the user-facing shell; the engine owns server lifecycle, downloads, process isolation, persistence, and automation.

2. **Primary boundary**
   - The key architectural boundary is **gRPC over a Windows Named Pipe**.
   - The app talks to the engine through generated contract code from `proto/mcmanager/v1/mcmanager.proto`; this proto layer is the single source of truth for both languages.

3. **Frontend responsibilities**
   - `app/JustHostMC.App` contains the WinUI 3 application, organized in MVVM: `Views/`, `ViewModels/`, `Models/`, `Services/`, and reusable `Controls/`.
   - It renders server pages, console, metrics, backups, scripts, players, mods, and settings; it does not directly manage Minecraft processes.

4. **Shared C# client layer**
   - `app/JustHostMC.Core` is the client-side bridge to the engine, containing the connection, host, daemon client, and engine entry abstractions.
   - `app/JustHostMC.Core.Tests` exercises cross-process behavior and validates the contract from the frontend side.

5. **Engine responsibilities**
   - `engine/` is the authoritative backend daemon.
   - It provisions servers, maintains state, coordinates downloads, supervises child processes, and exposes all functionality via gRPC services under `engine/internal/grpc`.

6. **Server lifecycle and isolation**
   - Server start/stop/restart and crash handling are managed in the engine’s server, launch, and isolation subsystems.
   - Isolation is an important architectural seam: Windows **Job Objects** are the default backend, with **Docker** as an opt-in alternative. This affects how per-server processes are launched and contained.

7. **Persistence and local state**
   - The engine persists app state in **SQLite** (`engine/internal/store`) and maintains supporting local data such as settings, app data paths, cached resources, and script data.
   - The app is intentionally thin on persistence; state ownership stays in the engine.

8. **External data sources and providers**
   - The engine downloads runtime dependencies and server artifacts on demand from multiple external providers: Mojang, PaperMC, Forge, NeoForge, Fabric, plus mod/plugin sources like CurseForge and Modrinth.
   - Provider selection, metadata parsing, and compatibility logic live in the engine’s provider/scripting layers, not in the UI.

9. **Scripting and extensibility**
   - The engine has a substantial Lua-based automation system under `engine/internal/scripting`, with built-in scripts for server types, parsers, shops, and user-defined extensions.
   - The frontend exposes those capabilities through pages for scripts, providers, and shop browsing, but the engine owns execution, permissions, and persistence of script state.

10. **Operational subsystems**
   - Console streaming is bidirectional through a dedicated gRPC console service and log buffer pipeline.
   - Monitoring is split into metrics, player tracking, backups, and log retention; these are separate backend services surfaced as distinct UI views.

11. **UI composition**
   - The app is structured around navigation plus server-specific panels: home, server detail, console, metrics, mods, players, config, backups, scripts, settings, and shop browser.
   - Custom controls and templates in `Controls/` support adaptive layouts, dialogs, sparklines, status indicators, and per-section presentation.

12. **Packaging and delivery**
   - The project is designed for **MSIX / Microsoft Store** distribution, with a full-trust desktop app model.
   - `installer/` provides MSI packaging, while `build.ps1`, `setup.ps1`, and `app/Engine.targets` automate codegen, Go build, .NET build, and packaging.

13. **Test and validation flow**
   - The repo’s test strategy spans Go unit/integration tests, C# tests, and end-to-end engine scenarios.
   - This reflects the architecture: most behavior lives in the engine, but correctness depends on the contract between the C# UI and the Go daemon.

14. **Diagram takeaway**
   - For an architecture diagram, draw three main layers: **WinUI 3 client**, **gRPC named-pipe boundary**, and **Go engine**.
   - Under the engine, split out server lifecycle, isolation, provider/downloads, persistence, console/logging, backups, metrics/players, and scripting as separate subsystems feeding the UI through gRPC.

Main entry points: [`engine/internal/grpc`](https://github.com/000hen/justhostmc/tree/master/engine/internal/grpc) (gRPC API), [`app/JustHostMC.App/App.xaml.cs`](https://github.com/000hen/justhostmc/blob/master/app/JustHostMC.App/App.xaml.cs) (App shell), [`app/JustHostMC.Core/DaemonClient.cs`](https://github.com/000hen/justhostmc/blob/master/app/JustHostMC.Core/DaemonClient.cs) (Core bridge), [`engine/internal/grpc/serverservice.go`](https://github.com/000hen/justhostmc/blob/master/engine/internal/grpc/serverservice.go) (Server lifecycle)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_client["WinUI client"]
  node_app_shell["App shell<br/>WinUI 3 app<br/>[App.xaml.cs]"]
  node_app_views["Views<br/>UI pages<br/>[Views]"]
  node_app_controls["Controls<br/>UI components<br/>[Controls]"]
  node_app_viewmodels["ViewModels<br/>MVVM state<br/>[ViewModels]"]
  node_app_services["Client services<br/>UI services<br/>[Services]"]
  node_core_bridge["Core bridge<br/>C# client SDK<br/>[DaemonClient.cs]"]
  node_core_tests["Core tests<br/>C# tests"]
end

subgraph group_boundary["IPC contract"]
  node_proto_contract["Proto contract<br/>gRPC proto<br/>[mcmanager.proto]"]
end

subgraph group_engine["Go engine"]
  node_engine_entry["Engine entry<br/>Go daemon<br/>[main.go]"]
  node_grpc_api["gRPC API<br/>service layer"]
  node_server_lifecycle["Server lifecycle<br/>orchestration<br/>[serverservice.go]"]
  node_isolation["Isolation<br/>containment<br/>[isolation.go]"]
  node_providers["Providers<br/>download/catalog<br/>[provider.go]"]
  node_downloads["Downloads<br/>fetch pipeline<br/>[dl.go]"]
  node_persistence[("Persistence<br/>SQLite store<br/>[sqlite.go]")]
  node_console["Console stream<br/>log pipeline<br/>[hub.go]"]
  node_monitoring["Metrics & players<br/>observability<br/>[metricsservice.go]"]
  node_backups["Backups<br/>snapshot service<br/>[manager.go]"]
  node_scripting["Scripting<br/>Lua automation<br/>[automation.go]"]
  node_settings["Settings<br/>config service<br/>[settings.go]"]
end

subgraph group_delivery["Build and packaging"]
  node_installer_pkg["Packaging<br/>build & installer<br/>[build.ps1]"]
end

node_app_shell -->|"navigates"| node_app_views
node_app_shell -->|"composes"| node_app_controls
node_app_shell -->|"binds"| node_app_viewmodels
node_app_viewmodels -->|"calls"| node_core_bridge
node_app_services -->|"supports"| node_core_bridge
node_core_bridge -->|"implements"| node_proto_contract
node_proto_contract -->|"defines"| node_grpc_api
node_core_tests -->|"validates"| node_core_bridge
node_engine_entry -->|"hosts"| node_grpc_api
node_grpc_api -->|"exposes"| node_server_lifecycle
node_server_lifecycle -->|"uses"| node_isolation
node_server_lifecycle -->|"resolves"| node_providers
node_providers -->|"fetches"| node_downloads
node_grpc_api -->|"streams"| node_console
node_grpc_api -->|"reports"| node_monitoring
node_grpc_api -->|"manages"| node_backups
node_grpc_api -->|"controls"| node_scripting
node_grpc_api -->|"reads/writes"| node_settings
node_grpc_api -->|"stores"| node_persistence
node_settings -->|"persists"| node_persistence
node_installer_pkg -->|"builds"| node_engine_entry
node_installer_pkg -->|"packages"| node_app_shell

click node_app_shell "https://github.com/000hen/justhostmc/blob/master/app/JustHostMC.App/App.xaml.cs"
click node_app_views "https://github.com/000hen/justhostmc/blob/master/app/JustHostMC.App/Views"
click node_app_controls "https://github.com/000hen/justhostmc/blob/master/app/JustHostMC.App/Controls"
click node_app_viewmodels "https://github.com/000hen/justhostmc/blob/master/app/JustHostMC.App/ViewModels"
click node_app_services "https://github.com/000hen/justhostmc/blob/master/app/JustHostMC.App/Services"
click node_core_bridge "https://github.com/000hen/justhostmc/blob/master/app/JustHostMC.Core/DaemonClient.cs"
click node_core_tests "https://github.com/000hen/justhostmc/blob/master/app/JustHostMC.Core.Tests/HealthIntegrationTests.cs"
click node_proto_contract "https://github.com/000hen/justhostmc/blob/master/proto/mcmanager/v1/mcmanager.proto"
click node_engine_entry "https://github.com/000hen/justhostmc/blob/master/engine/cmd/engine/main.go"
click node_grpc_api "https://github.com/000hen/justhostmc/tree/master/engine/internal/grpc"
click node_server_lifecycle "https://github.com/000hen/justhostmc/blob/master/engine/internal/grpc/serverservice.go"
click node_isolation "https://github.com/000hen/justhostmc/blob/master/engine/internal/isolation/isolation.go"
click node_providers "https://github.com/000hen/justhostmc/blob/master/engine/internal/provider/provider.go"
click node_downloads "https://github.com/000hen/justhostmc/blob/master/engine/internal/dl/dl.go"
click node_persistence "https://github.com/000hen/justhostmc/blob/master/engine/internal/store/sqlite.go"
click node_console "https://github.com/000hen/justhostmc/blob/master/engine/internal/console/hub.go"
click node_monitoring "https://github.com/000hen/justhostmc/blob/master/engine/internal/grpc/metricsservice.go"
click node_backups "https://github.com/000hen/justhostmc/blob/master/engine/internal/backup/manager.go"
click node_scripting "https://github.com/000hen/justhostmc/blob/master/engine/internal/scripting/automation/automation.go"
click node_settings "https://github.com/000hen/justhostmc/blob/master/engine/internal/settings/settings.go"
click node_installer_pkg "https://github.com/000hen/justhostmc/blob/master/build.ps1"

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_app_shell,node_app_views,node_app_controls,node_app_viewmodels,node_app_services,node_core_bridge,node_core_tests toneBlue
class node_proto_contract toneAmber
class node_engine_entry,node_grpc_api,node_server_lifecycle,node_isolation,node_providers,node_downloads,node_persistence,node_console,node_monitoring,node_backups,node_scripting,node_settings toneMint
class node_installer_pkg toneRose
```

## Components

### WinUI client

C# desktop shell and shared client bridge

- [App shell](https://github.com/000hen/justhostmc/blob/master/app/JustHostMC.App/App.xaml.cs): WinUI 3 app · Main desktop application and navigation shell · `app/JustHostMC.App/App.xaml.cs`
- [Views](https://github.com/000hen/justhostmc/blob/master/app/JustHostMC.App/Views): UI pages · Primary pages and dialogs for servers, console, metrics, players, scripts, backups, settings, and shop · `app/JustHostMC.App/Views`
- [Controls](https://github.com/000hen/justhostmc/blob/master/app/JustHostMC.App/Controls): UI components · Reusable panels, templates, and adaptive presentation controls · `app/JustHostMC.App/Controls`
- [ViewModels](https://github.com/000hen/justhostmc/blob/master/app/JustHostMC.App/ViewModels): MVVM state · Presentation logic and page-level state coordination · `app/JustHostMC.App/ViewModels`
- [Client services](https://github.com/000hen/justhostmc/blob/master/app/JustHostMC.App/Services): UI services · Localization, startup, tray, permissions, rendering, and UI-side helpers · `app/JustHostMC.App/Services`
- [Core bridge](https://github.com/000hen/justhostmc/blob/master/app/JustHostMC.Core/DaemonClient.cs): C# client SDK · Shared connection, host, and daemon client layer for the frontend · `app/JustHostMC.Core/DaemonClient.cs`
- [Core tests](https://github.com/000hen/justhostmc/blob/master/app/JustHostMC.Core.Tests/HealthIntegrationTests.cs): C# tests · Cross-process and contract-focused validation for the client bridge · `app/JustHostMC.Core.Tests/HealthIntegrationTests.cs`

### IPC contract

gRPC contract and named-pipe communication boundary

- [Proto contract](https://github.com/000hen/justhostmc/blob/master/proto/mcmanager/v1/mcmanager.proto): gRPC proto · Single source of truth for cross-process service and message definitions · `proto/mcmanager/v1/mcmanager.proto`

### Go engine

Backend daemon and server management subsystems

- [Engine entry](https://github.com/000hen/justhostmc/blob/master/engine/cmd/engine/main.go): Go daemon · Backend process bootstrap and adapter wiring · `engine/cmd/engine/main.go`
- [gRPC API](https://github.com/000hen/justhostmc/tree/master/engine/internal/grpc): service layer · Engine-facing RPC services surfaced to the client over the pipe boundary · `engine/internal/grpc`
- [Server lifecycle](https://github.com/000hen/justhostmc/blob/master/engine/internal/grpc/serverservice.go): orchestration · Start, stop, restart, update, and crash handling for server processes · `engine/internal/grpc/serverservice.go`
- [Isolation](https://github.com/000hen/justhostmc/blob/master/engine/internal/isolation/isolation.go): containment · Per-server process containment using Windows Job Objects or Docker · `engine/internal/isolation/isolation.go`
- [Providers](https://github.com/000hen/justhostmc/blob/master/engine/internal/provider/provider.go): download/catalog · Artifact and metadata providers for runtimes, mods, plugins, and shop sources · `engine/internal/provider/provider.go`
- [Downloads](https://github.com/000hen/justhostmc/blob/master/engine/internal/dl/dl.go): fetch pipeline · HTTP cache and artifact retrieval for server dependencies and assets · `engine/internal/dl/dl.go`
- [Persistence](https://github.com/000hen/justhostmc/blob/master/engine/internal/store/sqlite.go): SQLite store · Application state, settings, and local data persistence · `engine/internal/store/sqlite.go`
- [Console stream](https://github.com/000hen/justhostmc/blob/master/engine/internal/console/hub.go): log pipeline · Bidirectional console service and buffered log streaming · `engine/internal/console/hub.go`
- [Metrics & players](https://github.com/000hen/justhostmc/blob/master/engine/internal/grpc/metricsservice.go): observability · Metrics collection and player tracking services · `engine/internal/grpc/metricsservice.go`
- [Backups](https://github.com/000hen/justhostmc/blob/master/engine/internal/backup/manager.go): snapshot service · Backup creation and restore workflow · `engine/internal/backup/manager.go`
- [Scripting](https://github.com/000hen/justhostmc/blob/master/engine/internal/scripting/automation/automation.go): Lua automation · Builtin and user-defined automation, parsers, shops, and permissions · `engine/internal/scripting/automation/automation.go`
- [Settings](https://github.com/000hen/justhostmc/blob/master/engine/internal/settings/settings.go): config service · Engine-owned configuration and runtime settings management · `engine/internal/settings/settings.go`

### Build and packaging

Cross-language build, installer, and distribution tooling

- [Packaging](https://github.com/000hen/justhostmc/blob/master/build.ps1): build & installer · Build scripts, targets, and installer packaging for distribution · `build.ps1`

## Connections

- App shell → Views: navigates · Shell hosts the page and dialog surface
- App shell → Controls: composes · Shell uses reusable controls for presentation
- App shell → ViewModels: binds · Pages bind to viewmodels for state and commands
- ViewModels → Core bridge: calls · Viewmodels invoke engine operations through the client bridge
- Client services → Core bridge: supports · Services help the UI coordinate with the backend
- Core bridge → Proto contract: implements · Client bridge is generated and shaped by the proto contract
- Proto contract → gRPC API: defines · Shared contract defines engine RPC surface
- Core tests → Core bridge: validates · Tests exercise client connection and contract behavior
- Engine entry → gRPC API: hosts · Daemon bootstrap wires up RPC services
- gRPC API → Server lifecycle: exposes · Server management is surfaced as RPC operations
- Server lifecycle → Isolation: uses · Launch and supervision rely on containment backends
- Server lifecycle → Providers: resolves · Lifecycle depends on runtime and artifact metadata
- Providers → Downloads: fetches · Providers drive artifact retrieval and caching
- gRPC API → Console stream: streams · Console service exposes bidirectional log flow
- gRPC API → Metrics & players: reports · Metrics and player state are surfaced through services
- gRPC API → Backups: manages · Backup operations are exposed to the client
- gRPC API → Scripting: controls · Script execution and catalog operations are exposed via RPC
- gRPC API → Settings: reads/writes · Settings service persists configuration changes
- gRPC API → Persistence: stores · Backend owns durable app and server state
- Settings → Persistence: persists · Settings are stored in the engine-owned database
- Packaging → Engine entry: builds · Build scripts assemble the daemon binary
- Packaging → App shell: packages · Packaging also produces the desktop client
