# kenyu910645/maplestoryautolevelup architecture

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

- Interactive diagram: https://gitdiagram.com/kenyu910645/maplestoryautolevelup
- Repository: https://github.com/kenyu910645/maplestoryautolevelup

## Overview

##### Project type and purpose
- This is a desktop automation tool (no web server) written in Python for automating gameplay in MapleStory Artale using pure screen‐based Computer Vision (CV).
- It includes multiple command‐line utilities:
- mapleStoryAutoLevelUp.py – main auto‐leveling bot
- routeRecorder.py – custom route recorder
- mob_maker.py – auto‐download monster sprites
- AutoDiceRoller.py – auto‐roller for character creation
- It simulates keyboard input, captures/samples the game window, processes images (OpenCV), and sends keystrokes to the running game.

##### File structure
- Top‐level scripts: AutoDiceRoller.py, GameWindowCapturor*.py, HealthMonitor.py, KeyBoardController*.py, KeyBoardListener.py, routeRecorder.py, mob_maker.py, mapleStoryAutoLevelUp(.py/_legacy).
- config/: YAML config per map/key bindings + legacy configs
- maps/ & minimaps/: static assets for map recognition
- monster/: per‐monster image assets used for template‐matching
- tools/: helper (e.g., getPixeColorOnImg.py)
- logger.py & util.py: shared utilities
- requirements.txt: dependencies (OpenCV, etc.)

##### README for additional insights
- Core workflow:
1. Game window (GameWindowCapturor)
2. Detect minimap pattern & player nametag (CV templates from maps/, minimaps/, monster/)
3. Localize player, identify monsters in view
4. Compute movement/attack route (routeRecorder or built‐in patterns)
5. Send keystrokes to game (KeyBoardController)
6. Monitor health (HealthMonitor) and pause/continue (F1/F2)
- Additional utilities: mob_maker.py fetches assets from external API; AutoDiceRoller for dice automation.

##### Main components & relationships
- User CLI (python mapleStoryAutoLevelUp.py)
- Config Loader (config/*.yaml)
- Screen Capturer (GameWindowCapturor.py / Mac variant)
- CV Detector
- Minimap Detector (minimaps/)
- Nametag Detector (user‐provided name_tag.png)
- Monster Detector (monster/ assets)
- Route Planner (built into mapleStoryAutoLevelUp.py + routeRecorder.py)
- Keyboard Controller (KeyBoardController.py / listener)
- Health Monitor (HealthMonitor.py)
- Logger & Utils (logger.py, util.py)
- Data Assets (maps/, minimaps/, monster/, media/)
- External Services (MapleStory game window; maplestory.io API for mob_maker)
- CLI → Config Loader → CV Detector & Route Planner
- CV Detector → Route Planner → Keyboard Controller → Game Window
- CV Detector → Health Monitor → (pause/control)
- mob_maker CLI → External API → monster/ folder
- routeRecorder CLI ↔ Screen Capturer → saves screenshot & route
c. Architectural patterns / design principles
- Modular design: each concern in its own script/module
- Template‐matching CV pipeline (input: screenshot → detection → output: coordinates)
- Command‐line utilities share common components (utils, logger, config)
d. Key technologies & frameworks
- Python 3.12
- OpenCV 4.x for image processing
- PyAutoGUI or native keyboard hooks for input simulation
- YAML for configuration
- Requests (or urllib) for HTTP in mob_maker.py

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Core Modules
    subgraph "Core Modules"
        CLI["User CLI\n(mapleStoryAutoLevelUp.py)"]:::core
        CLI_legacy["Legacy User CLI\n(mapleStoryAutoLevelUp_legacy.py)"]:::core
        ScreenCapt["Screen Capturer\n(GameWindowCapturor)"]:::core
        CVDetector["CV Detector"]:::core
        RoutePlanner["Route Planner"]:::core
        KeyboardCtrl["Keyboard Controller"]:::core
        HealthMon["Health Monitor"]:::core
        LoggerUtils["Logger & Utilities"]:::core
    end

    %% CV Detector subcomponents
    subgraph "CV Detector Components"
        Minimap["Minimap Detector"]:::core
        Nametag["Nametag Detector"]:::core
        MonsterDet["Monster Detector"]:::core
    end

    %% Data Assets & Config
    subgraph "Configuration & Data Assets"
        ConfigLoader["Config Loader"]:::data
        Maps["Map Templates\n(maps/)"]:::data
        MinimapAssets["Minimap Templates\n(minimaps/)"]:::data
        MonsterAssets["Monster Assets\n(monster/)"]:::data
        Media["Other Static Assets\n(media/, numbers/, rune/)"]:::data
    end

    %% Utilities
    subgraph "Auxiliary Utilities"
        DiceRoller["Dice Roller\n(AutoDiceRoller.py)"]:::util
        MobMaker["Monster Asset Fetcher\n(mob_maker.py)"]:::util
        Recorder["Route Recorder\n(routeRecorder.py)"]:::util
    end

    %% External
    subgraph "External Systems"
        GameWin["MapleStory Game Window"]:::external
        API["maplestory.io API"]:::api
    end

    %% Dependencies
    Requirements["requirements.txt"]:::data

    %% Main Workflow
    CLI -->|loads| ConfigLoader
    CLI -->|uses| LoggerUtils
    ConfigLoader -->|provides configs| CVDetector
    ConfigLoader -->|provides configs| RoutePlanner
    ConfigLoader -->|provides configs| KeyboardCtrl

    ScreenCapt -->|captures screenshot| CVDetector
    CVDetector --> Minimap
    CVDetector --> Nametag
    CVDetector --> MonsterDet

    CVDetector -->|detections| RoutePlanner
    RoutePlanner -->|plans actions| KeyboardCtrl
    KeyboardCtrl -->|sends keystrokes| GameWin

    CVDetector -->|health data| HealthMon
    HealthMon -->|controls| KeyboardCtrl

    %% Recorder Flow
    Recorder -->|captures frames| ScreenCapt
    ScreenCapt -->|screenshots saved| Recorder

    %% Mob Maker Flow
    MobMaker -->|requests assets| API
    API -->|provides assets| MonsterAssets

    %% Asset Relationships
    Minimap --> MinimapAssets
    MonsterDet --> MonsterAssets
    MapTemplates["Maps Data"] --> Maps

    %% Link Logger & Utils
    LoggerUtils -->|used by| ScreenCapt
    LoggerUtils -->|used by| CVDetector
    LoggerUtils -->|used by| RoutePlanner
    LoggerUtils -->|used by| KeyboardCtrl
    LoggerUtils -->|used by| HealthMon

    %% Requirements
    Requirements -->|dependencies| CLI
    Requirements -->|dependencies| DiceRoller
    Requirements -->|dependencies| MobMaker
    Requirements -->|dependencies| Recorder

    %% Click Events
    click CLI "https://github.com/kenyu910645/maplestoryautolevelup/blob/main/mapleStoryAutoLevelUp.py"
    click CLI_legacy "https://github.com/kenyu910645/maplestoryautolevelup/blob/main/mapleStoryAutoLevelUp_legacy.py"
    click ConfigLoader "https://github.com/kenyu910645/maplestoryautolevelup/blob/main/config/config_default.yaml"
    click ConfigLoader "https://github.com/kenyu910645/maplestoryautolevelup/blob/main/config/config_edit_me.yaml"
    click ConfigLoader "https://github.com/kenyu910645/maplestoryautolevelup/blob/main/config/config_cleric.yaml"
    click ConfigLoader "https://github.com/kenyu910645/maplestoryautolevelup/blob/main/config/config_macOS.yaml"
    click ConfigLoader "https://github.com/kenyu910645/maplestoryautolevelup/blob/main/config/legacy/config.py"
    click ConfigLoader "https://github.com/kenyu910645/maplestoryautolevelup/blob/main/config/legacy/config_legacy.py"
    click ScreenCapt "https://github.com/kenyu910645/maplestoryautolevelup/blob/main/GameWindowCapturor.py"
    click ScreenCapt "https://github.com/kenyu910645/maplestoryautolevelup/blob/main/GameWindowCapturorForMac.py"
    click MinimapAssets "https://github.com/kenyu910645/maplestoryautolevelup/tree/main/minimaps/"
    click Nametag "https://github.com/kenyu910645/maplestoryautolevelup/tree/main/nametag/"
    click MonsterAssets "https://github.com/kenyu910645/maplestoryautolevelup/tree/main/monster/"
    click RoutePlanner "https://github.com/kenyu910645/maplestoryautolevelup/blob/main/routeRecorder.py"
    click RoutePlanner "https://github.com/kenyu910645/maplestoryautolevelup/blob/main/mapleStoryAutoLevelUp.py"
    click KeyboardCtrl "https://github.com/kenyu910645/maplestoryautolevelup/blob/main/KeyBoardController.py"
    click KeyboardCtrl "https://github.com/kenyu910645/maplestoryautolevelup/blob/main/KeyBoardController_legacy.py"
    click KeyboardCtrl "https://github.com/kenyu910645/maplestoryautolevelup/blob/main/KeyBoardListener.py"
    click HealthMon "https://github.com/kenyu910645/maplestoryautolevelup/blob/main/HealthMonitor.py"
    click LoggerUtils "https://github.com/kenyu910645/maplestoryautolevelup/blob/main/logger.py"
    click LoggerUtils "https://github.com/kenyu910645/maplestoryautolevelup/blob/main/util.py"
    click DiceRoller "https://github.com/kenyu910645/maplestoryautolevelup/blob/main/AutoDiceRoller.py"
    click MobMaker "https://github.com/kenyu910645/maplestoryautolevelup/blob/main/mob_maker.py"
    click Recorder "https://github.com/kenyu910645/maplestoryautolevelup/blob/main/routeRecorder.py"
    click MapTemplates "https://github.com/kenyu910645/maplestoryautolevelup/tree/main/maps/"
    click Requirements "https://github.com/kenyu910645/maplestoryautolevelup/blob/main/requirements.txt"
    click Recorder "https://github.com/kenyu910645/maplestoryautolevelup/blob/main/mapScanner_legacy.py"
    click ScreenCapt "https://github.com/kenyu910645/maplestoryautolevelup/blob/main/mapScanner_legacy.py"

    %% Styles
    classDef core fill:#D6EAF8,stroke:#2980B9,color:#1B4F72
    classDef data fill:#D5F5E3,stroke:#27AE60,color:#145A32
    classDef util fill:#FAD7A0,stroke:#D68910,color:#7E5109
    classDef external fill:#E8DAEF,stroke:#8E44AD,color:#512E5F
    classDef api fill:#F5CBA7,stroke:#B9770E,color:#6E2C00
```
