# githao3/dsh-pet-desktop architecture

> Architecture diagram of the GitHub repository githao3/dsh-pet-desktop, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-09-30). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/githao3/dsh-pet-desktop
- Repository: https://github.com/githao3/dsh-pet-desktop

## Overview

dsh-pet-desktop is an independent Windows desktop-pet application built from the dsh-pet plugin. Its main user flow is launching the standalone Electron app, loading pet configuration and animation assets, then rendering interactive pets; configuration and animation behavior are shared with the browser/plugin client. The README also documents optional conversation, notification, status, and balance features, plus a reproducible video-to-animation content pipeline. Some runtime wiring and several documented subsystems were not sampled, so uncertain links are omitted.

Main entry points: [`dsh-pet/src/host/index.ts`](https://github.com/githao3/dsh-pet-desktop/blob/master/dsh-pet/src/host/index.ts) (Host routes), [`dsh-pet/runtime/electron-helper/main.js`](https://github.com/githao3/dsh-pet-desktop/blob/master/dsh-pet/runtime/electron-helper/main.js) (Electron main), [`dsh-pet/src/client/pet.ts`](https://github.com/githao3/dsh-pet-desktop/blob/master/dsh-pet/src/client/pet.ts) (Pet interaction), [`dsh-pet/src/client/app.ts`](https://github.com/githao3/dsh-pet-desktop/blob/master/dsh-pet/src/client/app.ts) (Client assembly)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_shell["Desktop runtime"]
  node_electron["Electron main<br/>[main.js]"]
  node_mini["Mini host<br/>[mini-host.js]"]
  node_renderer["Window renderer<br/>[renderer.js]"]
end

subgraph group_pet["Pet experience"]
  node_sprite["Pet sprite view<br/>[sprite.js]"]
  node_clientapp["Client assembly<br/>[app.ts]"]
  node_petui["Pet interaction<br/>[pet.ts]"]
  node_settings["Pet settings<br/>[settings.ts]"]
  node_petassets["Pet animation assets"]
end

subgraph group_host["Host services"]
  node_hostentry["Standalone host"]
  node_hostapi["Host routes<br/>[index.ts]"]
  node_config["Config loading<br/>[config.ts]"]
  node_storage["User storage<br/>[storage-paths.ts]"]
  node_helper["Electron management<br/>[helper-process.ts]"]
  node_chat["Chat and memes<br/>[chat.ts]"]
  node_reasoning["Model reasoning<br/>[llm-reasoning.ts]"]
  node_whisper["Whisper service<br/>[whisper.ts]"]
  node_work["Work status<br/>[work-status.ts]"]
  node_balancehost["Balance service<br/>[balance.ts]"]
  node_notifyevents["Notification events<br/>[notify-events.ts]"]
end

subgraph group_shared["Shared behavior"]
  node_physics["Motion physics<br/>[physics.ts]"]
  node_menu["Action menus<br/>[menu.ts]"]
  node_balance["Balance display<br/>[balance.ts]"]
  node_types["Pet configuration model<br/>[types.ts]"]
end

subgraph group_assets["Animation pipeline"]
  node_video["Source video"]
  node_watermark["Watermark masking"]
  node_chroma["Green-screen keying<br/>[chroma_step02.py]"]
  node_normalize["Frame normalization"]
  node_encode["WebM encoding<br/>[pet.ts]"]
end

node_user(("Desktop user"))

node_user -->|"launches"| node_electron
node_electron -->|"opens windows"| node_renderer
node_electron -.->|"bridges host"| node_mini
node_renderer -->|"renders pet"| node_sprite
node_electron -->|"starts standalone"| node_hostentry
node_hostentry -.->|"starts routes"| node_hostapi
node_hostapi -->|"loads config"| node_config
node_hostapi -->|"uses paths"| node_storage
node_hostapi -->|"manages Electron"| node_helper
node_hostapi -->|"routes chat"| node_chat
node_chat -->|"checks model"| node_reasoning
node_hostapi -->|"routes whispers"| node_whisper
node_hostapi -->|"routes status"| node_work
node_hostapi -->|"routes balance"| node_balancehost
node_hostapi -->|"routes events"| node_notifyevents
node_clientapp -->|"assembles UI"| node_petui
node_clientapp -->|"registers settings"| node_settings
node_petui -->|"uses motion"| node_physics
node_petui -->|"uses menus"| node_menu
node_petui -->|"fetches balance"| node_balance
node_settings -->|"saves config"| node_hostapi
node_hostapi -.->|"serves client"| node_clientapp
node_config -->|"uses model"| node_types
node_video -->|"masks source"| node_watermark
node_watermark -->|"keys frames"| node_chroma
node_chroma -->|"normalizes frames"| node_normalize
node_normalize -->|"encodes variants"| node_encode
node_encode -.->|"produces animation"| node_petassets
node_petassets -->|"plays assets"| node_sprite

click node_electron "https://github.com/githao3/dsh-pet-desktop/blob/master/dsh-pet/runtime/electron-helper/main.js"
click node_mini "https://github.com/githao3/dsh-pet-desktop/blob/master/dsh-pet/runtime/electron-helper/mini-host.js"
click node_renderer "https://github.com/githao3/dsh-pet-desktop/blob/master/dsh-pet/runtime/electron-helper/renderer.js"
click node_sprite "https://github.com/githao3/dsh-pet-desktop/blob/master/dsh-pet/runtime/electron-helper/sprite.js"
click node_hostentry "https://github.com/githao3/dsh-pet-desktop/blob/master/dsh-pet/src/host/standalone-entry.ts"
click node_hostapi "https://github.com/githao3/dsh-pet-desktop/blob/master/dsh-pet/src/host/index.ts"
click node_config "https://github.com/githao3/dsh-pet-desktop/blob/master/dsh-pet/src/host/config.ts"
click node_storage "https://github.com/githao3/dsh-pet-desktop/blob/master/dsh-pet/src/host/storage-paths.ts"
click node_helper "https://github.com/githao3/dsh-pet-desktop/blob/master/dsh-pet/src/host/helper-process.ts"
click node_chat "https://github.com/githao3/dsh-pet-desktop/blob/master/dsh-pet/src/host/chat.ts"
click node_reasoning "https://github.com/githao3/dsh-pet-desktop/blob/master/dsh-pet/src/host/llm-reasoning.ts"
click node_whisper "https://github.com/githao3/dsh-pet-desktop/blob/master/dsh-pet/src/host/whisper.ts"
click node_work "https://github.com/githao3/dsh-pet-desktop/blob/master/dsh-pet/src/host/work-status.ts"
click node_balancehost "https://github.com/githao3/dsh-pet-desktop/blob/master/dsh-pet/src/host/balance.ts"
click node_notifyevents "https://github.com/githao3/dsh-pet-desktop/blob/master/dsh-pet/src/host/notify-events.ts"
click node_clientapp "https://github.com/githao3/dsh-pet-desktop/blob/master/dsh-pet/src/client/app.ts"
click node_petui "https://github.com/githao3/dsh-pet-desktop/blob/master/dsh-pet/src/client/pet.ts"
click node_settings "https://github.com/githao3/dsh-pet-desktop/blob/master/dsh-pet/src/client/settings.ts"
click node_physics "https://github.com/githao3/dsh-pet-desktop/blob/master/dsh-pet/src/shared/physics.ts"
click node_menu "https://github.com/githao3/dsh-pet-desktop/blob/master/dsh-pet/src/shared/menu.ts"
click node_balance "https://github.com/githao3/dsh-pet-desktop/blob/master/dsh-pet/src/shared/balance.ts"
click node_types "https://github.com/githao3/dsh-pet-desktop/blob/master/dsh-pet/src/shared/types.ts"
click node_watermark "https://github.com/githao3/dsh-pet-desktop/blob/master/scripts/watermark_step01.py"
click node_chroma "https://github.com/githao3/dsh-pet-desktop/blob/master/scripts/chroma_step02.py"
click node_normalize "https://github.com/githao3/dsh-pet-desktop/blob/master/scripts/normalize_step03.py"
click node_encode "https://github.com/githao3/dsh-pet-desktop/blob/master/dsh-pet/src/client/pet.ts"

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_electron,node_mini,node_renderer,node_user toneBlue
class node_sprite,node_clientapp,node_petui,node_settings,node_petassets toneAmber
class node_hostentry,node_hostapi,node_config,node_storage,node_helper,node_chat,node_reasoning,node_whisper,node_work,node_balancehost,node_notifyevents toneMint
class node_physics,node_menu,node_balance,node_types toneRose
class node_video,node_watermark,node_chroma,node_normalize,node_encode toneIndigo
```

## Components

### Desktop runtime

- [Electron main](https://github.com/githao3/dsh-pet-desktop/blob/master/dsh-pet/runtime/electron-helper/main.js): `dsh-pet/runtime/electron-helper/main.js`
- [Mini host](https://github.com/githao3/dsh-pet-desktop/blob/master/dsh-pet/runtime/electron-helper/mini-host.js): `dsh-pet/runtime/electron-helper/mini-host.js`
- [Window renderer](https://github.com/githao3/dsh-pet-desktop/blob/master/dsh-pet/runtime/electron-helper/renderer.js): `dsh-pet/runtime/electron-helper/renderer.js`

### Pet experience

- [Pet sprite view](https://github.com/githao3/dsh-pet-desktop/blob/master/dsh-pet/runtime/electron-helper/sprite.js): `dsh-pet/runtime/electron-helper/sprite.js`
- [Client assembly](https://github.com/githao3/dsh-pet-desktop/blob/master/dsh-pet/src/client/app.ts): `dsh-pet/src/client/app.ts`
- [Pet interaction](https://github.com/githao3/dsh-pet-desktop/blob/master/dsh-pet/src/client/pet.ts): `dsh-pet/src/client/pet.ts`
- [Pet settings](https://github.com/githao3/dsh-pet-desktop/blob/master/dsh-pet/src/client/settings.ts): `dsh-pet/src/client/settings.ts`
- **Pet animation assets**

### Host services

- [Standalone host](https://github.com/githao3/dsh-pet-desktop/blob/master/dsh-pet/src/host/standalone-entry.ts): `dsh-pet/src/host/standalone-entry.ts`
- [Host routes](https://github.com/githao3/dsh-pet-desktop/blob/master/dsh-pet/src/host/index.ts): `dsh-pet/src/host/index.ts`
- [Config loading](https://github.com/githao3/dsh-pet-desktop/blob/master/dsh-pet/src/host/config.ts): `dsh-pet/src/host/config.ts`
- [User storage](https://github.com/githao3/dsh-pet-desktop/blob/master/dsh-pet/src/host/storage-paths.ts): `dsh-pet/src/host/storage-paths.ts`
- [Electron management](https://github.com/githao3/dsh-pet-desktop/blob/master/dsh-pet/src/host/helper-process.ts): `dsh-pet/src/host/helper-process.ts`
- [Chat and memes](https://github.com/githao3/dsh-pet-desktop/blob/master/dsh-pet/src/host/chat.ts): `dsh-pet/src/host/chat.ts`
- [Model reasoning](https://github.com/githao3/dsh-pet-desktop/blob/master/dsh-pet/src/host/llm-reasoning.ts): `dsh-pet/src/host/llm-reasoning.ts`
- [Whisper service](https://github.com/githao3/dsh-pet-desktop/blob/master/dsh-pet/src/host/whisper.ts): `dsh-pet/src/host/whisper.ts`
- [Work status](https://github.com/githao3/dsh-pet-desktop/blob/master/dsh-pet/src/host/work-status.ts): `dsh-pet/src/host/work-status.ts`
- [Balance service](https://github.com/githao3/dsh-pet-desktop/blob/master/dsh-pet/src/host/balance.ts): `dsh-pet/src/host/balance.ts`
- [Notification events](https://github.com/githao3/dsh-pet-desktop/blob/master/dsh-pet/src/host/notify-events.ts): `dsh-pet/src/host/notify-events.ts`

### Shared behavior

- [Motion physics](https://github.com/githao3/dsh-pet-desktop/blob/master/dsh-pet/src/shared/physics.ts): `dsh-pet/src/shared/physics.ts`
- [Action menus](https://github.com/githao3/dsh-pet-desktop/blob/master/dsh-pet/src/shared/menu.ts): `dsh-pet/src/shared/menu.ts`
- [Balance display](https://github.com/githao3/dsh-pet-desktop/blob/master/dsh-pet/src/shared/balance.ts): `dsh-pet/src/shared/balance.ts`
- [Pet configuration model](https://github.com/githao3/dsh-pet-desktop/blob/master/dsh-pet/src/shared/types.ts): `dsh-pet/src/shared/types.ts`

### Animation pipeline

- **Source video**
- [Watermark masking](https://github.com/githao3/dsh-pet-desktop/blob/master/scripts/watermark_step01.py): `scripts/watermark_step01.py`
- [Green-screen keying](https://github.com/githao3/dsh-pet-desktop/blob/master/scripts/chroma_step02.py): `scripts/chroma_step02.py`
- [Frame normalization](https://github.com/githao3/dsh-pet-desktop/blob/master/scripts/normalize_step03.py): `scripts/normalize_step03.py`
- [WebM encoding](https://github.com/githao3/dsh-pet-desktop/blob/master/dsh-pet/src/client/pet.ts): `dsh-pet/src/client/pet.ts`

### Other components

- **Desktop user**

## Connections

- Desktop user → Electron main: launches
- Electron main → Window renderer: opens windows (evidence: `dsh-pet/runtime/electron-helper/main.js`)
- Electron main → Mini host: bridges host (evidence: `dsh-pet/runtime/electron-helper/main.js`)
- Window renderer → Pet sprite view: renders pet
- Electron main → Standalone host: starts standalone
- Standalone host → Host routes: starts routes
- Host routes → Config loading: loads config (evidence: `dsh-pet/src/host/index.ts`)
- Host routes → User storage: uses paths (evidence: `dsh-pet/src/host/storage-paths.ts`)
- Host routes → Electron management: manages Electron (evidence: `dsh-pet/src/host/index.ts`)
- Host routes → Chat and memes: routes chat (evidence: `dsh-pet/src/host/index.ts`)
- Chat and memes → Model reasoning: checks model (evidence: `dsh-pet/src/host/chat.ts`)
- Host routes → Whisper service: routes whispers (evidence: `dsh-pet/src/host/index.ts`)
- Host routes → Work status: routes status (evidence: `dsh-pet/src/host/index.ts`)
- Host routes → Balance service: routes balance (evidence: `dsh-pet/src/host/index.ts`)
- Host routes → Notification events: routes events (evidence: `dsh-pet/src/host/index.ts`)
- Client assembly → Pet interaction: assembles UI (evidence: `dsh-pet/src/client/app.ts`)
- Client assembly → Pet settings: registers settings (evidence: `dsh-pet/src/client/app.ts`)
- Pet interaction → Motion physics: uses motion (evidence: `dsh-pet/src/client/pet.ts`)
- Pet interaction → Action menus: uses menus (evidence: `dsh-pet/src/client/pet.ts`)
- Pet interaction → Balance display: fetches balance (evidence: `dsh-pet/src/client/pet.ts`)
- Pet settings → Host routes: saves config (evidence: `dsh-pet/src/client/settings.ts`)
- Host routes → Client assembly: serves client
- Config loading → Pet configuration model: uses model
- Source video → Watermark masking: masks source
- Watermark masking → Green-screen keying: keys frames
- Green-screen keying → Frame normalization: normalizes frames
- Frame normalization → WebM encoding: encodes variants
- WebM encoding → Pet animation assets: produces animation
- Pet animation assets → Pet sprite view: plays assets
