# cndaqiang/autowzry architecture

> Architecture diagram of the GitHub repository cndaqiang/autowzry, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-11-09). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/cndaqiang/autowzry
- Repository: https://github.com/cndaqiang/autowzry

## Overview

##### Project type and purpose
- From the README and project metadata, this is an open-source automation tool (“自动化农活演示”) built in Python on top of the Airtest framework.
- It orchestrates an Android emulator running the mobile game (Honor of Kings), performs image-recognition, simulates touch events, auto-updates the game, runs battles, and collects in-game rewards in a 24×7 unattended fashion.

##### (minimal) file structure and inferred modules
- Although the provided tree only shows .github, LICENSE, README, the README refers to multiple logical modules:
- Emulator launcher & manager
- Game update downloader
- Image‐recognition engine
- Touch‐input simulator
- Workflow/orchestrator (battle logic, gift-claim logic)
- Logging & monitoring
- Configuration & scheduling

##### README for architecture clues
- Built on top of airtest-mobileauto
- Works via “图像识别” (screenshots) + “模拟点击” (simulated taps)
- Modules: 启动模拟器, 更新游戏, 自动对战, 礼包领取
- 7×24h 无人值守自动化架构

##### Main components & relationships
a. Components
1) Orchestrator / Scheduler
2) Emulator Controller (Nox, MEmu, etc.)
3) Screen Capture & Image Recognition Engine
4) Input Simulator (tap/swipe)
5) Update Manager (downloads game patches)
6) Module Library (battle logic, gift-claim flows)
7) Config & CLI/GUI Interface
8) Logger / Metrics / Storage
9) External Dependencies (Airtest library, Android emulator, game servers)
b. Interactions
- Scheduler triggers Orchestrator at configured intervals
- Orchestrator calls Emulator Controller to start/stop emulator
- Emulator streams screen frames → Image Recognition extracts UI state
- Orchestrator picks next step (e.g., “start battle” or “claim gift”) from Module Library
- Input Simulator injects taps into emulator
- Update Manager periodically fetches patches via network → applies via Emulator Controller
- All actions and errors logged to Logger/Storage
c. Architectural patterns/design principles
- Modular “plugin”-style modules for each game action (battle, gift)
- Separation of concerns: capture → analysis → command → logging
- Scheduler + event loop for 24×7 unattended operation
- External dependencies isolated behind controller/adapter interfaces
d. Key technologies/frameworks
- Python + airtest-mobileauto
- Android emulator (e.g., NoxPlayer, MEmu)
- OpenCV or Airtest’s image-matching engine
- Standard logging, file I/O, HTTP for updates

## Diagram (Mermaid)

```mermaid
graph TB
    subgraph "External Systems"
        Emulator["Android Emulator"]:::external
        GameServers["Game Servers / Update Server"]:::external
    end

    Scheduler["Scheduler (24×7 Trigger)"]:::core
    Orchestrator["Orchestrator\n(Core Control Loop)"]:::core
    EmuController["Emulator Controller\n(Start/Stop/Apply)"]:::core
    ModuleLib["Module Library\n(Battle, Gift Services)"]:::core

    Capture["Screen Capture"]:::perception
    Recognition["Image Recognition Engine"]:::perception

    InputSim["Input Simulator\n(Tap/Swipe)"]:::action
    UpdateMgr["Update Manager\n(Downloads & Applies Patches)"]:::action

    Logger["Logger / Storage\n(Actions & Metrics)"]:::datastore

    Scheduler -->|triggers| Orchestrator
    Orchestrator -->|selects module| ModuleLib
    ModuleLib -->|executes| Orchestrator

    Orchestrator -->|start / stop| EmuController
    EmuController -->|controls| Emulator

    Emulator -->|screenshots| Capture
    Capture -->|frames| Recognition
    Recognition -->|ui-state| Orchestrator

    Orchestrator -->|commands| InputSim
    InputSim -->|touch events| Emulator

    Orchestrator -->|checks updates| UpdateMgr
    UpdateMgr -->|fetch patches| GameServers
    GameServers -->|patch data| UpdateMgr
    UpdateMgr -->|apply patches| EmuController

    Scheduler --> Logger
    Orchestrator --> Logger
    EmuController --> Logger
    Capture --> Logger
    Recognition --> Logger
    InputSim --> Logger
    UpdateMgr --> Logger
    ModuleLib --> Logger

    classDef core fill:#cce5ff,stroke:#0062cc
    classDef perception fill:#d4edda,stroke:#155724
    classDef action fill:#fff3cd,stroke:#856404
    classDef external fill:#e2e3e5,stroke:#6c757d
    classDef datastore fill:#f8f9fa,stroke:#343a40,stroke-dasharray:5 5
```
