# fabian57fabian/archero_bot_57 architecture

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

- Interactive diagram: https://gitdiagram.com/fabian57fabian/archero_bot_57
- Repository: https://github.com/fabian57fabian/archero_bot_57

## Overview

##### Project type and purpose
- Archero Bot 57 is a desktop‐based automation tool (open‐source Python application) with a GUI front end that controls a mobile game (Archero) via adb (USB/Nox emulator). It uses MVC for its two main interfaces (GameController and TouchManager) plus a core “bot engine” that implements gameplay logic, screen analysis, and device commands.

##### Main components
a. User interfaces (MVC layers)
- GameController (GameControllerView, GameControllerController, GameControllerModel)
- TouchManager  (TouchManagerView, TouchManagerController, TouchManagerModel)
- QMyWidgets: custom Qt widgets shared by both UIs (e.g. QActionTap, QDarkButton)
b. Core bot engine
- src/ directory:
- GameScreenConnector – takes screenshots, reads pixels
- UsbConnector – adb wrapper, sends taps/swipes
- CaveDungeonEngine & BotStrategies – high‐level gameplay loops and decision logic
- GameChapters, StatisticsManager, LocalEngineSettingsManager, update_manager – auxiliary services
- WorkerThread – offloads long‐running tasks (screenshots, device commands)
c. Data layer
- datas/ folder: JSON templates for coordinates, abilities, tier lists, general templates
- DeveloperScripts/: offline utilities to extract/update coordinate dictionaries, ability templates, etc.
d. External interfaces
- ADB (USB connection or Nox emulator)
e. Testing
- tests/: unit tests for core engine modules (CaveDungeonEngine, Utils, settings manager)

##### Relationships and interactions
- User clicks “Start” in GameControllerView → GameControllerController invokes GameControllerModel.start()
- Model delegates to Bot engine:
- WorkerThread ↔ GameScreenConnector (capture screen → detect energy, level state)
- CaveDungeonEngine uses BotStrategies + GameScreenConnector + UsbConnector to decide next action and perform tap/swipe
- StatisticsManager logs results to datas/*.csv
- LocalEngineSettingsManager reads/writes user preferences
- TouchManager UI works similarly but focuses on coordinate‐checking flows: reading screenshots folder, allowing the user to adjust coordinate templates stored under datas/ and writing out updated JSON.
- DeveloperScripts operate offline: independent CLI tools that generate or verify datas/* files, called manually outside the MVC/bot runtime.

##### Architectural patterns and design principles
- MVC for both GUI apps (separate View/Controller/Model layers).
- Single‐process multi‐threading (WorkerThread) to keep UI responsive.
- Layered architecture:
1. Presentation (Qt UIs)
2. Application logic (controllers + models + engine)
3. Device abstraction (adb wrapper)
4. Data access (JSON templates, csv files)
- Dependency injection via constructor parameters (models receive engine, settings, etc.)
- Extensibility: DeveloperScripts and datas/ folder allow adding new templates or coordinate sets without changing code.

##### Essential elements to capture
- MVC separation and how engine services plug into the controllers/models

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% UI Layer - GameController App
    subgraph "GameController App"
        direction TB
        GCView["GameControllerView"]:::ui
        GCController["GameControllerController"]:::ui
        GCModel["GameControllerModel"]:::ui
    end

    %% UI Layer - TouchManager App
    subgraph "TouchManager App"
        direction TB
        TMView["TouchManagerView"]:::ui
        TMController["TouchManagerController"]:::ui
        TMModel["TouchManagerModel"]:::ui
    end

    %% Shared Widgets
    QMyWidgets["QMyWidgets"]:::widgets

    %% Core Bot Engine
    subgraph "Core Bot Engine"
        direction TB
        GSC["GameScreenConnector"]:::engine
        USB["UsbConnector"]:::engine
        CDE["CaveDungeonEngine"]:::engine
        BS["BotStrategies"]:::engine
        GMCh["GameChapters"]:::engine
        SM["StatisticsManager"]:::engine
        LESM["LocalEngineSettingsManager"]:::engine
        UM["update_manager"]:::engine
        WT["WorkerThread"]:::engine
        UT["Utils"]:::engine
    end

    %% Data Store
    DataStore["Data Store (datas/, JSON, CSV)"]:::data

    %% Developer Scripts
    DevScripts["DeveloperScripts"]:::data

    %% External Interface
    Device["Device / ADB"]:::external

    %% Interactions
    GCView -->|"user commands"| GCController
    GCController -->|"invokes start()"| GCModel
    GCModel -->|"run game loop"| CDE

    TMView -->|"user commands"| TMController
    TMController -->|"invokes actions"| TMModel
    TMModel -->|"coordinate flows"| GSC

    CDE -->|"capture screenshot"| GSC
    CDE -->|"use strategies"| BS
    CDE -->|"decision logic"| GMCh
    CDE -->|"tap/swipe commands"| USB
    WT <-->|"offload tasks"| GSC
    WT <-->|"offload tasks"| USB

    CDE -->|"log results"| SM
    CDE -->|"read/write prefs"| LESM
    CDE -->|"check updates"| UM

    CDE -->|"use utils"| UT

    CDE --> DataStore
    TMModel -->|"read/write templates"| DataStore
    DevScripts -->|"generate/update JSON"| DataStore

    USB -->|"ADB shell input/screenshot"| Device

    %% Shared Widgets usage
    GCView -.-> QMyWidgets
    TMView -.-> QMyWidgets

    %% Click events
    click GCView "https://github.com/fabian57fabian/archero_bot_57/blob/master/GameController/GameControllerView.py"
    click GCController "https://github.com/fabian57fabian/archero_bot_57/blob/master/GameController/GameControllerController.py"
    click GCModel "https://github.com/fabian57fabian/archero_bot_57/blob/master/GameController/GameControllerModel.py"
    click TMView "https://github.com/fabian57fabian/archero_bot_57/blob/master/TouchManager/TouchManagerView.py"
    click TMController "https://github.com/fabian57fabian/archero_bot_57/blob/master/TouchManager/TouchManagerController.py"
    click TMModel "https://github.com/fabian57fabian/archero_bot_57/blob/master/TouchManager/TouchManagerModel.py"
    click QMyWidgets "https://github.com/fabian57fabian/archero_bot_57/tree/master/QMyWidgets/"
    click GSC "https://github.com/fabian57fabian/archero_bot_57/blob/master/src/GameScreenConnector.py"
    click USB "https://github.com/fabian57fabian/archero_bot_57/blob/master/src/UsbConnector.py"
    click CDE "https://github.com/fabian57fabian/archero_bot_57/blob/master/src/CaveDungeonEngine.py"
    click BS "https://github.com/fabian57fabian/archero_bot_57/blob/master/src/BotStrategies.py"
    click GMCh "https://github.com/fabian57fabian/archero_bot_57/blob/master/src/GameChapters.py"
    click SM "https://github.com/fabian57fabian/archero_bot_57/blob/master/src/StatisticsManager.py"
    click LESM "https://github.com/fabian57fabian/archero_bot_57/blob/master/src/LocalEngineSettingsManager.py"
    click UM "https://github.com/fabian57fabian/archero_bot_57/blob/master/src/update_manager.py"
    click WT "https://github.com/fabian57fabian/archero_bot_57/blob/master/src/WorkerThread.py"
    click UT "https://github.com/fabian57fabian/archero_bot_57/blob/master/src/Utils.py"

    %% Styles
    classDef ui fill:#D0E8FF,stroke:#0366d6,stroke-width:2px
    classDef engine fill:#DFFFE0,stroke:#228B22,stroke-width:2px
    classDef data fill:#FFE0B2,stroke:#FF8C00,stroke-width:2px
    classDef external fill:#E0E0E0,stroke:#808080,stroke-width:2px
    classDef widgets fill:#F0E0FF,stroke:#800080,stroke-width:2px
```
