# haixingtaohai/yys-auto architecture

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

- Interactive diagram: https://gitdiagram.com/haixingtaohai/yys-auto
- Repository: https://github.com/haixingtaohai/yys-auto

## Overview

YYS-AUTO is a Windows desktop automation tool for the Onmyoji mobile game. A user selects an emulator, configures a scene and challenge limit, then starts a device tab: its runner captures and recognizes the game screen, dispatches scene logic, and sends actions back through ADB. The graph also preserves documented configuration, settings, notifications, audio, and auxiliary automation. Relationships are grounded in README statements and shown source/index references; unsampled scene internals are represented by their documented subsystem paths.

Main entry points: [`ui/scene_runner.py`](https://github.com/haixingtaohai/yys-auto/blob/main/ui/scene_runner.py) (Scene runner), [`ui/device_tab.py`](https://github.com/haixingtaohai/yys-auto/blob/main/ui/device_tab.py) (Device controls), [`ui/app.py`](https://github.com/haixingtaohai/yys-auto/blob/main/ui/app.py) (Window and tabs), [`image_recognizer.py`](https://github.com/haixingtaohai/yys-auto/blob/main/image_recognizer.py) (Screen recognizer)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_interface["Desktop interface"]
  node_main["Application startup<br/>[main.py]"]
  node_app["Window and tabs<br/>[app.py]"]
  node_device_tab["Device controls<br/>[device_tab.py]"]
  node_settings["Settings controls<br/>[settings_tab.py]"]
end

subgraph group_automation["Automation runtime"]
  node_runner["Scene runner<br/>[scene_runner.py]"]
  node_recognizer["Screen recognizer"]
  node_accelerator["Recognition acceleration"]
  node_adb["ADB device management<br/>[adb.py]"]
  node_templates[("Screen templates")]
end

subgraph group_scenes["Gameplay scenes"]
  node_registry["Scene dispatch registry<br/>[registry.py]"]
  node_scene_contract["Scene context and results<br/>[scene_api.py]"]
  node_scene_helpers["Scene interaction helpers<br/>[scene_common.py]"]
  node_farm_scenes["Farming scenes"]
  node_coop_scenes["Co-op scenes"]
  node_tower_pvp_scenes["Tower and PvP scenes"]
  node_aux_scenes["Auxiliary automation"]
end

subgraph group_support["Persistence and feedback"]
  node_presets["Scene presets<br/>[presets.py]"]
  node_config[("Persistent configuration<br/>[config_store.py]")]
  node_paths["Resource paths<br/>[paths.py]"]
  node_notifications["System notifications<br/>[notification.py]"]
  node_sound["Completion audio<br/>[wav.py]"]
end

node_user(("Operator"))
node_emulator["Android emulator"]

node_user -->|"operates"| node_app
node_main -->|"starts"| node_app
node_main -->|"registers"| node_notifications
node_app -->|"creates tabs"| node_device_tab
node_app -->|"hosts settings"| node_settings
node_app -->|"persists settings"| node_config
node_device_tab -->|"lists devices"| node_adb
node_device_tab -->|"starts loop"| node_runner
node_device_tab -->|"configures"| node_recognizer
node_device_tab -->|"selects preset"| node_presets
node_runner -->|"captures and matches"| node_recognizer
node_recognizer -->|"runs commands"| node_adb
node_recognizer -->|"matches templates"| node_templates
node_recognizer -.->|"uses acceleration"| node_accelerator
node_runner -->|"dispatches scene"| node_registry
node_runner -->|"builds context"| node_scene_contract
node_registry -->|"resolves scenes"| node_farm_scenes
node_registry -->|"resolves scenes"| node_coop_scenes
node_registry -->|"resolves scenes"| node_tower_pvp_scenes
node_farm_scenes -->|"uses contract"| node_scene_contract
node_coop_scenes -->|"uses contract"| node_scene_contract
node_tower_pvp_scenes -->|"uses contract"| node_scene_contract
node_farm_scenes -->|"uses helpers"| node_scene_helpers
node_coop_scenes -->|"uses helpers"| node_scene_helpers
node_tower_pvp_scenes -->|"uses helpers"| node_scene_helpers
node_runner -->|"invokes handlers"| node_aux_scenes
node_settings -->|"configures pauses"| node_aux_scenes
node_settings -->|"restarts server"| node_adb
node_runner -->|"plays on stop"| node_sound
node_runner -->|"notifies completion"| node_notifications
node_adb -->|"controls device"| node_emulator
node_recognizer -->|"captures and taps"| node_emulator
node_app -->|"loads resources"| node_paths
node_device_tab -->|"saves tab state"| node_config

click node_main "https://github.com/haixingtaohai/yys-auto/blob/main/main.py"
click node_app "https://github.com/haixingtaohai/yys-auto/blob/main/ui/app.py"
click node_device_tab "https://github.com/haixingtaohai/yys-auto/blob/main/ui/device_tab.py"
click node_settings "https://github.com/haixingtaohai/yys-auto/blob/main/ui/settings_tab.py"
click node_runner "https://github.com/haixingtaohai/yys-auto/blob/main/ui/scene_runner.py"
click node_recognizer "https://github.com/haixingtaohai/yys-auto/blob/main/image_recognizer.py"
click node_accelerator "https://github.com/haixingtaohai/yys-auto/blob/main/image_accelerator.py"
click node_adb "https://github.com/haixingtaohai/yys-auto/blob/main/adb.py"
click node_templates "https://github.com/haixingtaohai/yys-auto/tree/main/png"
click node_registry "https://github.com/haixingtaohai/yys-auto/blob/main/scenes/registry.py"
click node_scene_contract "https://github.com/haixingtaohai/yys-auto/blob/main/scenes/scene_api.py"
click node_scene_helpers "https://github.com/haixingtaohai/yys-auto/blob/main/scenes/scene_common.py"
click node_farm_scenes "https://github.com/haixingtaohai/yys-auto/tree/main/scenes"
click node_coop_scenes "https://github.com/haixingtaohai/yys-auto/tree/main/scenes"
click node_tower_pvp_scenes "https://github.com/haixingtaohai/yys-auto/tree/main/scenes"
click node_aux_scenes "https://github.com/haixingtaohai/yys-auto/tree/main/scenes"
click node_presets "https://github.com/haixingtaohai/yys-auto/blob/main/presets.py"
click node_config "https://github.com/haixingtaohai/yys-auto/blob/main/ui/config_store.py"
click node_paths "https://github.com/haixingtaohai/yys-auto/blob/main/paths.py"
click node_notifications "https://github.com/haixingtaohai/yys-auto/blob/main/notification.py"
click node_sound "https://github.com/haixingtaohai/yys-auto/blob/main/wav.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_main,node_app,node_device_tab,node_settings toneBlue
class node_runner,node_recognizer,node_accelerator,node_adb,node_templates toneAmber
class node_registry,node_scene_contract,node_scene_helpers,node_farm_scenes,node_coop_scenes,node_tower_pvp_scenes,node_aux_scenes toneMint
class node_presets,node_config,node_paths,node_notifications,node_sound toneRose
class node_user,node_emulator toneIndigo
```

## Components

### Desktop interface

- [Application startup](https://github.com/haixingtaohai/yys-auto/blob/main/main.py): `main.py`
- [Window and tabs](https://github.com/haixingtaohai/yys-auto/blob/main/ui/app.py): `ui/app.py`
- [Device controls](https://github.com/haixingtaohai/yys-auto/blob/main/ui/device_tab.py): `ui/device_tab.py`
- [Settings controls](https://github.com/haixingtaohai/yys-auto/blob/main/ui/settings_tab.py): `ui/settings_tab.py`

### Automation runtime

- [Scene runner](https://github.com/haixingtaohai/yys-auto/blob/main/ui/scene_runner.py): `ui/scene_runner.py`
- [Screen recognizer](https://github.com/haixingtaohai/yys-auto/blob/main/image_recognizer.py): `image_recognizer.py`
- [Recognition acceleration](https://github.com/haixingtaohai/yys-auto/blob/main/image_accelerator.py): `image_accelerator.py`
- [ADB device management](https://github.com/haixingtaohai/yys-auto/blob/main/adb.py): `adb.py`
- [Screen templates](https://github.com/haixingtaohai/yys-auto/tree/main/png): `png`

### Gameplay scenes

- [Scene dispatch registry](https://github.com/haixingtaohai/yys-auto/blob/main/scenes/registry.py): `scenes/registry.py`
- [Scene context and results](https://github.com/haixingtaohai/yys-auto/blob/main/scenes/scene_api.py): `scenes/scene_api.py`
- [Scene interaction helpers](https://github.com/haixingtaohai/yys-auto/blob/main/scenes/scene_common.py): `scenes/scene_common.py`
- [Farming scenes](https://github.com/haixingtaohai/yys-auto/tree/main/scenes): `scenes`
- [Co-op scenes](https://github.com/haixingtaohai/yys-auto/tree/main/scenes): `scenes`
- [Tower and PvP scenes](https://github.com/haixingtaohai/yys-auto/tree/main/scenes): `scenes`
- [Auxiliary automation](https://github.com/haixingtaohai/yys-auto/tree/main/scenes): `scenes`

### Persistence and feedback

- [Scene presets](https://github.com/haixingtaohai/yys-auto/blob/main/presets.py): `presets.py`
- [Persistent configuration](https://github.com/haixingtaohai/yys-auto/blob/main/ui/config_store.py): `ui/config_store.py`
- [Resource paths](https://github.com/haixingtaohai/yys-auto/blob/main/paths.py): `paths.py`
- [System notifications](https://github.com/haixingtaohai/yys-auto/blob/main/notification.py): `notification.py`
- [Completion audio](https://github.com/haixingtaohai/yys-auto/blob/main/wav.py): `wav.py`

### Other components

- **Operator**
- **Android emulator**

## Connections

- Operator → Window and tabs: operates
- Application startup → Window and tabs: starts (evidence: `main.py`)
- Application startup → System notifications: registers (evidence: `main.py`)
- Window and tabs → Device controls: creates tabs (evidence: `ui/app.py`)
- Window and tabs → Settings controls: hosts settings (evidence: `ui/app.py`)
- Window and tabs → Persistent configuration: persists settings (evidence: `ui/app.py`)
- Device controls → ADB device management: lists devices (evidence: `ui/device_tab.py`)
- Device controls → Scene runner: starts loop (evidence: `ui/device_tab.py`)
- Device controls → Screen recognizer: configures (evidence: `ui/device_tab.py`)
- Device controls → Scene presets: selects preset (evidence: `ui/app.py`)
- Scene runner → Screen recognizer: captures and matches
- Screen recognizer → ADB device management: runs commands (evidence: `image_recognizer.py`)
- Screen recognizer → Screen templates: matches templates
- Screen recognizer → Recognition acceleration: uses acceleration (evidence: `image_recognizer.py`)
- Scene runner → Scene dispatch registry: dispatches scene (evidence: `ui/scene_runner.py`)
- Scene runner → Scene context and results: builds context (evidence: `ui/scene_runner.py`)
- Scene dispatch registry → Farming scenes: resolves scenes (evidence: `scenes/registry.py`)
- Scene dispatch registry → Co-op scenes: resolves scenes (evidence: `scenes/registry.py`)
- Scene dispatch registry → Tower and PvP scenes: resolves scenes (evidence: `scenes/registry.py`)
- Farming scenes → Scene context and results: uses contract (evidence: `scenes/dfw.py`)
- Co-op scenes → Scene context and results: uses contract (evidence: `scenes/sj.py`)
- Tower and PvP scenes → Scene context and results: uses contract (evidence: `scenes/dg.py`)
- Farming scenes → Scene interaction helpers: uses helpers (evidence: `scenes/dfw.py`)
- Co-op scenes → Scene interaction helpers: uses helpers (evidence: `scenes/sj.py`)
- Tower and PvP scenes → Scene interaction helpers: uses helpers (evidence: `scenes/dg.py`)
- Scene runner → Auxiliary automation: invokes handlers (evidence: `ui/scene_runner.py`)
- Settings controls → Auxiliary automation: configures pauses (evidence: `ui/settings_tab.py`)
- Settings controls → ADB device management: restarts server (evidence: `ui/settings_tab.py`)
- Scene runner → Completion audio: plays on stop (evidence: `ui/scene_runner.py`)
- Scene runner → System notifications: notifies completion
- ADB device management → Android emulator: controls device
- Screen recognizer → Android emulator: captures and taps
- Window and tabs → Resource paths: loads resources (evidence: `ui/app.py`)
- Device controls → Persistent configuration: saves tab state
