How 000hen/justhostmc works
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: grpc gRPC API · App.xaml.cs App shell · DaemonClient.cs Core bridge · serverservice.go Server lifecycle
Components 21
WinUI client
C# desktop shell and shared client bridge
- App shell · Main desktop application and navigation shell
app/JustHostMC.App/App.xaml.cs - Views · Primary pages and dialogs for servers, console, metrics, players, scripts, backups, settings, and shop
app/JustHostMC.App/Views - Controls · Reusable panels, templates, and adaptive presentation controls
app/JustHostMC.App/Controls - ViewModels · Presentation logic and page-level state coordination
app/JustHostMC.App/ViewModels - Client services · Localization, startup, tray, permissions, rendering, and UI-side helpers
app/JustHostMC.App/Services - Core bridge · Shared connection, host, and daemon client layer for the frontend
app/JustHostMC.Core/DaemonClient.cs - Core 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 · 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 · Backend process bootstrap and adapter wiring
engine/cmd/engine/main.go - gRPC API · Engine-facing RPC services surfaced to the client over the pipe boundary
engine/internal/grpc - Server lifecycle · Start, stop, restart, update, and crash handling for server processes
engine/internal/grpc/serverservice.go - Isolation · Per-server process containment using Windows Job Objects or Docker
engine/internal/isolation/isolation.go - Providers · Artifact and metadata providers for runtimes, mods, plugins, and shop sources
engine/internal/provider/provider.go - Downloads · HTTP cache and artifact retrieval for server dependencies and assets
engine/internal/dl/dl.go - Persistence · Application state, settings, and local data persistence
engine/internal/store/sqlite.go - Console stream · Bidirectional console service and buffered log streaming
engine/internal/console/hub.go - Metrics & players · Metrics collection and player tracking services
engine/internal/grpc/metricsservice.go - Backups · Backup creation and restore workflow
engine/internal/backup/manager.go - Scripting · Builtin and user-defined automation, parsers, shops, and permissions
engine/internal/scripting/automation/automation.go - Settings · Engine-owned configuration and runtime settings management
engine/internal/settings/settings.go
Build and packaging
Cross-language build, installer, and distribution tooling
- Packaging · Build scripts, targets, and installer packaging for distribution
build.ps1
Connections 22
- 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