# scighost/starward architecture

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

- Interactive diagram: https://gitdiagram.com/scighost/starward
- Repository: https://github.com/scighost/starward

## Overview

#### Purpose and executable topology
Starward is a Windows third-party replacement launcher for HoYoverse PC games, with launcher, installation, account, game-data, gacha, screenshot, and play-time features. The primary GUI executable is the WPF/WinUI-style `Starward` app, entered through `src/Starward/Program.cs` and `src/Starward/App.xaml.cs`; its main shell is `src/Starward/Features/ViewHost/MainWindow.xaml`.

Supporting executables are a privileged/local RPC worker (`src/Starward.RPC/Program.cs`), an installer/updater (`src/Starward.Setup/Program.cs`), and a native launcher component (`src/Starward.Launcher/Starward.Launcher.cpp`).

#### Presentation, composition, and feature boundaries
The desktop client is organized by feature under `src/Starward/Features`. App configuration/service registration is centralized in `src/Starward/AppConfig.ServiceProvider.cs`, while navigation/window hosting lives in `src/Starward/Features/ViewHost/MainView.xaml.cs` and `src/Starward/Features/ViewHost/MainWindow.xaml.cs`.

Feature services own application orchestration; XAML pages/windows are presentation endpoints. Cross-feature state changes are represented by feature-local message classes, such as launch, navigation, and installation messages, rather than direct UI-to-UI coupling.

#### Game discovery, metadata, and launching
Game identity and shared HoYoverse contracts are modeled in Core: `src/Starward.Core/GameBiz.cs`, `src/Starward.Core/GameRegistry.cs`, and `src/Starward.Core/HoYoPlay/HoYoPlayClient.cs`. The client retrieves launcher/game package metadata, maps it to supported game variants, then surfaces selected-game state through `src/Starward/Features/GameSelector/GameSelector.xaml.cs`.

`src/Starward/Features/GameLauncher/GameLauncherService.cs` coordinates installation state, authentication/announcements, local game configuration, and process start actions. It is the boundary between UI workflows and local executable/game files.

#### Installation worker and IPC boundary
Potentially long-running or privileged game package operations are isolated in `Starward.RPC`. `src/Starward/Features/RPC/RpcService.cs` is the GUI-side bridge; `src/Starward.RPC/NamedPipesConnectionFactory.cs` and `src/Starward.RPC/RpcClientFactory.cs` establish local named-pipe RPC.

The worker exposes protobuf-defined environment and install operations (`src/Starward.RPC/Env/Env.proto`, `src/Starward.RPC/GameInstall/GameInstall.proto`) and executes stateful download, verification/assembly, install, and uninstall workflows through `src/Starward.RPC/GameInstall/GameInstallService.cs` and `src/Starward.RPC/GameInstall/GamePackageService.cs`. This process boundary protects UI responsiveness and separates disk/network package mutation from the desktop client.

#### HoYoverse online-data integrations
`Starward.Core` is the typed API client layer, with JSON contexts/converters and service-specific clients. Game record retrieval is centered on `src/Starward.Core/GameRecord/GameRecordClient.cs` and `src/Starward.Core/GameRecord/HoyolabClient.cs`; UI coordination is in `src/Starward/Features/GameRecord/GameRecordService.cs`.

Gacha acquisition is game-specific behind `src/Starward.Core/Gacha/GachaLogClient.cs`, then normalized, persisted/exported, and displayed by `src/Starward/Features/Gacha/GachaLogService.cs` and `src/Starward/Features/Gacha/UIGF/UIGFGachaService.cs`. These integrations depend on HoYoLAB/miHoYo and HoYoPlay endpoints; failure semantics are centralized by `src/Starward.Core/miHoYoApiException.cs`.

#### Local user data and auxiliary desktop capabilities
The GUI persists feature data through `src/Starward/Features/Database/DatabaseService.cs`, with gacha, accounts, play time, and screenshot features layering on it or local filesystem/game-process state. Key examples are `src/Starward/Features/GameAccount/GameAccountService.cs`, `src/Starward/Features/PlayTime/PlayTimeRecordService.cs`, and `src/Starward/Features/Screenshot/ScreenCaptureService.cs`.

`src/Starward/Features/Overlay/RunningGameService.cs` tracks running games for overlays and related lifecycle behavior. Native Windows integration also includes URL protocol handling (`src/Starward/Features/UrlProtocol/UrlProtocolService.cs`) and gamepad input (`src/Starward/Features/GamepadControl/GamepadController.cs`).

#### Distribution, updates, and runtime dependencies
The installer applies full/downloaded updates and HPatch deltas through `src/Starward.Setup/Services/InstallService.cs`, `src/Starward.Setup/Services/UpdateService.cs`, and native runtime libraries under `src/Starward.Setup/runtimes`. The app invokes update/setup workflows through `src/Starward/Features/Update/UpdateService.cs` and `src/Starward/Features/Update/SetupService.cs`.

The solution targets Windows 10+ and requires WebView2 and WebP support. Builds are .NET plus native C++/UWP toolchains (`Starward.slnx`); release artifacts are published via GitHub workflows, with GitHub Releases, Cloudflare CDN, and SignPath signing as distribution infrastructure.

Main entry points: [`src/Starward.Core/GameRegistry.cs`](https://github.com/scighost/starward/blob/main/src/Starward.Core/GameRegistry.cs) (Game identity & registry), [`src/Starward/Features/GameLauncher/GameLauncherService.cs`](https://github.com/scighost/starward/blob/main/src/Starward/Features/GameLauncher/GameLauncherService.cs) (Game launch orchestration), [`src/Starward.Core/HoYoPlay/HoYoPlayClient.cs`](https://github.com/scighost/starward/blob/main/src/Starward.Core/HoYoPlay/HoYoPlayClient.cs) (HoYoPlay metadata client), [`src/Starward/AppConfig.ServiceProvider.cs`](https://github.com/scighost/starward/blob/main/src/Starward/AppConfig.ServiceProvider.cs) (Service composition)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_desktop["Desktop client"]
  node_app["Starward app<br/>WPF desktop executable<br/>[Program.cs]"]
  node_composition["Service composition<br/>DI configuration"]
  node_shell["Main shell &amp; navigation<br/>window host<br/>[MainWindow.xaml]"]
  node_feature_messages["Feature messages<br/>cross-feature events"]
  node_game_selector["Game selection<br/>feature UI"]
  node_game_launcher["Game launch orchestration<br/>feature service"]
  node_rpc_bridge["RPC bridge<br/>GUI RPC service<br/>[RpcService.cs]"]
  node_user_data[("Feature data store<br/>database service<br/>[DatabaseService.cs]")]
  node_local_capabilities["Local game capabilities<br/>feature services"]
  node_update_client["Update workflow<br/>feature services<br/>[UpdateService.cs]"]
end

subgraph group_core["Core contracts &amp; APIs"]
  node_game_contracts["Game identity &amp; registry<br/>shared contracts<br/>[GameRegistry.cs]"]
  node_hoyoplay["HoYoPlay metadata client<br/>typed API client<br/>[HoYoPlayClient.cs]"]
  node_game_records["Game record client<br/>typed API client"]
  node_gacha_client["Gacha log client<br/>typed API client<br/>[GachaLogClient.cs]"]
  node_online_endpoints{{"HoYoverse endpoints<br/>external APIs"}}
end

subgraph group_rpc["Package worker"]
  node_rpc_worker["Starward.RPC worker<br/>local worker executable<br/>[Program.cs]"]
  node_named_pipes["Named-pipe RPC<br/>local transport"]
  node_rpc_contracts["Environment &amp; install contracts<br/>protobuf APIs<br/>[GameInstall.proto]"]
  node_package_workflows["Package workflows<br/>install service"]
end

subgraph group_distribution["Setup &amp; updates"]
  node_setup["Setup executable<br/>installer/updater<br/>[Program.cs]"]
  node_setup_updates["Install &amp; delta updates<br/>setup services<br/>[UpdateService.cs]"]
  node_release_infra{{"Release distribution<br/>external infrastructure"}}
end

node_app -->|"initializes"| node_composition
node_composition -->|"composes"| node_shell
node_shell -->|"routes workflows"| node_feature_messages
node_feature_messages -.->|"updates state"| node_game_selector
node_game_selector -->|"selects variant"| node_game_contracts
node_hoyoplay -->|"maps metadata"| node_game_contracts
node_hoyoplay -->|"retrieves metadata"| node_online_endpoints
node_game_launcher -->|"requests package operations"| node_rpc_bridge
node_game_launcher -->|"uses game identity"| node_game_contracts
node_rpc_bridge -->|"connects"| node_named_pipes
node_named_pipes -->|"hosts local RPC"| node_rpc_worker
node_rpc_worker -->|"exposes"| node_rpc_contracts
node_rpc_contracts -->|"drives"| node_package_workflows
node_package_workflows -->|"downloads packages"| node_online_endpoints
node_game_records -->|"retrieves records"| node_online_endpoints
node_gacha_client -->|"acquires logs"| node_online_endpoints
node_user_data -->|"persists normalized logs"| node_gacha_client
node_local_capabilities -->|"persists feature state"| node_user_data
node_update_client -->|"invokes"| node_setup
node_setup -->|"runs"| node_setup_updates
node_setup_updates -->|"fetches releases"| node_release_infra

click node_app "https://github.com/scighost/starward/blob/main/src/Starward/Program.cs"
click node_composition "https://github.com/scighost/starward/blob/main/src/Starward/AppConfig.ServiceProvider.cs"
click node_shell "https://github.com/scighost/starward/blob/main/src/Starward/Features/ViewHost/MainWindow.xaml"
click node_game_selector "https://github.com/scighost/starward/blob/main/src/Starward/Features/GameSelector/GameSelector.xaml.cs"
click node_game_launcher "https://github.com/scighost/starward/blob/main/src/Starward/Features/GameLauncher/GameLauncherService.cs"
click node_rpc_bridge "https://github.com/scighost/starward/blob/main/src/Starward/Features/RPC/RpcService.cs"
click node_user_data "https://github.com/scighost/starward/blob/main/src/Starward/Features/Database/DatabaseService.cs"
click node_local_capabilities "https://github.com/scighost/starward/blob/main/src/Starward/Features/GameAccount/GameAccountService.cs"
click node_update_client "https://github.com/scighost/starward/blob/main/src/Starward/Features/Update/UpdateService.cs"
click node_game_contracts "https://github.com/scighost/starward/blob/main/src/Starward.Core/GameRegistry.cs"
click node_hoyoplay "https://github.com/scighost/starward/blob/main/src/Starward.Core/HoYoPlay/HoYoPlayClient.cs"
click node_game_records "https://github.com/scighost/starward/blob/main/src/Starward.Core/GameRecord/GameRecordClient.cs"
click node_gacha_client "https://github.com/scighost/starward/blob/main/src/Starward.Core/Gacha/GachaLogClient.cs"
click node_rpc_worker "https://github.com/scighost/starward/blob/main/src/Starward.RPC/Program.cs"
click node_named_pipes "https://github.com/scighost/starward/blob/main/src/Starward.RPC/NamedPipesConnectionFactory.cs"
click node_rpc_contracts "https://github.com/scighost/starward/blob/main/src/Starward.RPC/GameInstall/GameInstall.proto"
click node_package_workflows "https://github.com/scighost/starward/blob/main/src/Starward.RPC/GameInstall/GameInstallService.cs"
click node_setup "https://github.com/scighost/starward/blob/main/src/Starward.Setup/Program.cs"
click node_setup_updates "https://github.com/scighost/starward/blob/main/src/Starward.Setup/Services/UpdateService.cs"

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,node_composition,node_shell,node_feature_messages,node_game_selector,node_game_launcher,node_rpc_bridge,node_user_data,node_local_capabilities,node_update_client toneBlue
class node_game_contracts,node_hoyoplay,node_game_records,node_gacha_client,node_online_endpoints toneAmber
class node_rpc_worker,node_named_pipes,node_rpc_contracts,node_package_workflows toneMint
class node_setup,node_setup_updates,node_release_infra toneRose
```

## Components

### Desktop client

- [Starward app](https://github.com/scighost/starward/blob/main/src/Starward/Program.cs): WPF desktop executable · Primary Windows launcher process. · `src/Starward/Program.cs`
- [Service composition](https://github.com/scighost/starward/blob/main/src/Starward/AppConfig.ServiceProvider.cs): DI configuration · `src/Starward/AppConfig.ServiceProvider.cs`
- [Main shell & navigation](https://github.com/scighost/starward/blob/main/src/Starward/Features/ViewHost/MainWindow.xaml): window host · `src/Starward/Features/ViewHost/MainWindow.xaml`
- **Feature messages**: cross-feature events · Feature-local messages decouple state changes from UI endpoints.
- [Game selection](https://github.com/scighost/starward/blob/main/src/Starward/Features/GameSelector/GameSelector.xaml.cs): feature UI · `src/Starward/Features/GameSelector/GameSelector.xaml.cs`
- [Game launch orchestration](https://github.com/scighost/starward/blob/main/src/Starward/Features/GameLauncher/GameLauncherService.cs): feature service · Coordinates game state, authentication, configuration, and process start. · `src/Starward/Features/GameLauncher/GameLauncherService.cs`
- [RPC bridge](https://github.com/scighost/starward/blob/main/src/Starward/Features/RPC/RpcService.cs): GUI RPC service · `src/Starward/Features/RPC/RpcService.cs`
- [Feature data store](https://github.com/scighost/starward/blob/main/src/Starward/Features/Database/DatabaseService.cs): database service · Persists gacha, accounts, play time, and related feature data. · `src/Starward/Features/Database/DatabaseService.cs`
- [Local game capabilities](https://github.com/scighost/starward/blob/main/src/Starward/Features/GameAccount/GameAccountService.cs): feature services · Accounts, play time, screenshots, running-game overlays, URL protocol, and gamepad control. · `src/Starward/Features/GameAccount/GameAccountService.cs`
- [Update workflow](https://github.com/scighost/starward/blob/main/src/Starward/Features/Update/UpdateService.cs): feature services · `src/Starward/Features/Update/UpdateService.cs`

### Core contracts & APIs

- [Game identity & registry](https://github.com/scighost/starward/blob/main/src/Starward.Core/GameRegistry.cs): shared contracts · `src/Starward.Core/GameRegistry.cs`
- [HoYoPlay metadata client](https://github.com/scighost/starward/blob/main/src/Starward.Core/HoYoPlay/HoYoPlayClient.cs): typed API client · `src/Starward.Core/HoYoPlay/HoYoPlayClient.cs`
- [Game record client](https://github.com/scighost/starward/blob/main/src/Starward.Core/GameRecord/GameRecordClient.cs): typed API client · `src/Starward.Core/GameRecord/GameRecordClient.cs`
- [Gacha log client](https://github.com/scighost/starward/blob/main/src/Starward.Core/Gacha/GachaLogClient.cs): typed API client · `src/Starward.Core/Gacha/GachaLogClient.cs`
- **HoYoverse endpoints**: external APIs · HoYoPlay, HoYoLAB, and miHoYo services.

### Package worker

- [Starward.RPC worker](https://github.com/scighost/starward/blob/main/src/Starward.RPC/Program.cs): local worker executable · Isolates privileged and long-running package mutations. · `src/Starward.RPC/Program.cs`
- [Named-pipe RPC](https://github.com/scighost/starward/blob/main/src/Starward.RPC/NamedPipesConnectionFactory.cs): local transport · `src/Starward.RPC/NamedPipesConnectionFactory.cs`
- [Environment & install contracts](https://github.com/scighost/starward/blob/main/src/Starward.RPC/GameInstall/GameInstall.proto): protobuf APIs · `src/Starward.RPC/GameInstall/GameInstall.proto`
- [Package workflows](https://github.com/scighost/starward/blob/main/src/Starward.RPC/GameInstall/GameInstallService.cs): install service · Downloads, verifies, assembles, installs, and uninstalls game packages. · `src/Starward.RPC/GameInstall/GameInstallService.cs`

### Setup & updates

- [Setup executable](https://github.com/scighost/starward/blob/main/src/Starward.Setup/Program.cs): installer/updater · `src/Starward.Setup/Program.cs`
- [Install & delta updates](https://github.com/scighost/starward/blob/main/src/Starward.Setup/Services/UpdateService.cs): setup services · Applies full downloads and HPatch deltas. · `src/Starward.Setup/Services/UpdateService.cs`
- **Release distribution**: external infrastructure · GitHub Releases, Cloudflare CDN, and SignPath signing.

## Connections

- Starward app → Service composition: initializes
- Service composition → Main shell & navigation: composes
- Main shell & navigation → Feature messages: routes workflows
- Feature messages → Game selection: updates state
- Game selection → Game identity & registry: selects variant
- HoYoPlay metadata client → Game identity & registry: maps metadata
- HoYoPlay metadata client → HoYoverse endpoints: retrieves metadata
- Game launch orchestration → RPC bridge: requests package operations
- Game launch orchestration → Game identity & registry: uses game identity
- RPC bridge → Named-pipe RPC: connects
- Named-pipe RPC → Starward.RPC worker: hosts local RPC
- Starward.RPC worker → Environment & install contracts: exposes
- Environment & install contracts → Package workflows: drives
- Package workflows → HoYoverse endpoints: downloads packages
- Game record client → HoYoverse endpoints: retrieves records
- Gacha log client → HoYoverse endpoints: acquires logs
- Feature data store → Gacha log client: persists normalized logs
- Local game capabilities → Feature data store: persists feature state
- Update workflow → Setup executable: invokes
- Setup executable → Install & delta updates: runs
- Install & delta updates → Release distribution: fetches releases
