# tanjeffreyz/auto-maple architecture

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

- Interactive diagram: https://gitdiagram.com/tanjeffreyz/auto-maple
- Repository: https://github.com/tanjeffreyz/auto-maple

## Overview

Main Components to Include:

##### Core System Components
- Input Processing System
- Computer Vision System
- Bot Logic System
- GUI System
- Command Execution System

##### Key Architectural Elements

a) Vision Processing Pipeline:
- Screen Capture Module
- OpenCV Template Matching
- TensorFlow Model (for rune detection)
- Minimap Processing
- Tracking

b) Command System:
- Command Book Manager
- Command Interpreter
- Key Press Simulator

c) Routine System:
- Routine Parser
- Component Executor
- Layout Manager (with Quadtree)
- A* Pathfinding

##### Use a layered architecture approach with these levels
- ┌─ User Interface Layer ─────────────┐
- GUI Components                   │
- Settings Interface               │
- Routine Editor                   │
- Application Layer ────────────────┤
- Bot Logic                        │
- Command Processing               │
- Routine Execution                │
- Core Services Layer ──────────────┤
- Computer Vision Processing       │
- Position Tracking                │
- Pathfinding                      │
- Infrastructure Layer ─────────────┤
- Screen Capture                   │
- Key Simulation                   │
- File System Operations           │
- ┘

##### Component Relationships
- Data flow between components
- Command execution path
- Event triggers
- Feedback loops

- ┌─ Computer Vision Pipeline ────────┐
- Screen Capture → Preprocessing    │
- ↓                         │
- Template Matching → TF Model      │
- ↓                         │
- Position Detection → Minimap      │
- ┘

- ┌─ Command Processing ──────────────┐
- Command Book → Interpreter        │
- ↓                           │
- Routine Parser → Component Queue  │
- ↓                           │
- Execution Engine → Key Simulation │
- ┘

##### External Dependencies
- TensorFlow
- OpenCV
- Python Runtime
- Game Interface

##### Data Stores
- Command Books
- Routines
- Layout Files
- Settings

Important Notes for Implementation:

##### Maintain clear separation between
- Vision processing components
- Command execution logic
- User interface elements
- Bot control flow

##### Integration points
- Between CV system and bot logic
- Between command interpreter and execution
- Between GUI and core systems

##### Error handling and feedback loops
- Vision processing validation
- Command execution verification
- Tracking updates

##### Monitoring and control flows
- Status updates
- Error reporting
- Performance metrics

## Diagram (Mermaid)

```mermaid
graph TB
    %% Styles and classes
    classDef ui fill:#3498db,stroke:#2980b9,color:white
    classDef process fill:#2ecc71,stroke:#27ae60,color:white
    classDef data fill:#f1c40f,stroke:#f39c12,color:black
    classDef external fill:#e74c3c,stroke:#c0392b,color:white
    classDef ml fill:#9b59b6,stroke:#8e44ad,color:white
    
    subgraph User_Interface_Layer
        GUI["GUI System"]:::ui
        Settings["Settings Interface"]:::ui
        RoutineEditor["Routine Editor"]:::ui
        MinimapView["Minimap View"]:::ui
        StatusDisplay["Status Display"]:::ui
    end

    subgraph Application_Layer
        BotLogic["Bot Logic System"]:::process
        CommandProc["Command Processing"]:::process
        RoutineExec["Routine Execution"]:::process
    end

    subgraph Core_Services_Layer
        CVSystem["Computer Vision System"]:::ml
        PosTracker["Position Tracking"]:::process
        Pathfinding["A* Pathfinding"]:::process
    end

    subgraph Infrastructure_Layer
        ScreenCapture["Screen Capture"]:::external
        KeySim["Key Simulator"]:::external
        FileOps["File System Operations"]:::process
    end

    subgraph Vision_Pipeline
        direction TB
        Capture["Screen Capture Module"]:::process
        TFModel["TensorFlow Model"]:::ml
        OpenCV["OpenCV Processing"]:::ml
        MinimapProc["Minimap Processing"]:::process
    end

    subgraph Command_System
        direction TB
        CmdBook["Command Book Manager"]:::process
        CmdInterp["Command Interpreter"]:::process
        InputProc["Input Processing"]:::process
    end

    subgraph Routine_System
        direction TB
        RoutineParser["Routine Parser"]:::process
        CompExec["Component Executor"]:::process
        LayoutMgr["Layout Manager"]:::process
    end

    %% Relationships
    GUI --> BotLogic
    GUI --> Settings
    GUI --> RoutineEditor
    GUI --> MinimapView
    GUI --> StatusDisplay
    BotLogic --> CommandProc
    BotLogic --> RoutineExec
    CommandProc --> CmdBook
    CommandProc --> CmdInterp
    RoutineExec --> RoutineParser
    RoutineExec --> CompExec
    CVSystem --> OpenCV
    CVSystem --> TFModel
    CVSystem --> MinimapProc
    PosTracker --> MinimapProc
    ScreenCapture --> Capture
    KeySim --> InputProc
    
    %% Click events
    click BotLogic "https://github.com/tanjeffreyz/auto-maple/blob/main/src/modules/bot.py"
    click CVSystem "https://github.com/tanjeffreyz/auto-maple/blob/main/src/detection/detection.py"
    click Capture "https://github.com/tanjeffreyz/auto-maple/blob/main/src/modules/capture.py"
    click CmdBook "https://github.com/tanjeffreyz/auto-maple/blob/main/src/command_book/command_book.py"
    click InputProc "https://github.com/tanjeffreyz/auto-maple/blob/main/src/modules/listener.py"
    click KeySim "https://github.com/tanjeffreyz/auto-maple/blob/main/src/common/vkeys.py"
    click RoutineParser "https://github.com/tanjeffreyz/auto-maple/blob/main/src/routine/routine.py"
    click LayoutMgr "https://github.com/tanjeffreyz/auto-maple/blob/main/src/routine/layout.py"
    click CompExec "https://github.com/tanjeffreyz/auto-maple/blob/main/src/routine/components.py"
    click GUI "https://github.com/tanjeffreyz/auto-maple/blob/main/src/gui/view/main.py"
    click Settings "https://github.com/tanjeffreyz/auto-maple/blob/main/src/gui/settings/main.py"
    click RoutineEditor "https://github.com/tanjeffreyz/auto-maple/blob/main/src/gui/edit/routine.py"
    click MinimapView "https://github.com/tanjeffreyz/auto-maple/blob/main/src/gui/view/minimap.py"
    click StatusDisplay "https://github.com/tanjeffreyz/auto-maple/blob/main/src/gui/view/status.py"
    click TFModel "https://github.com/tanjeffreyz/auto-maple/blob/main/assets/label_map.pbtxt"

    %% Legend
    subgraph Legend
        UI["User Interface"]:::ui
        PROC["Processing Module"]:::process
        DATA["Data Storage"]:::data
        EXT["External Interface"]:::external
        ML["ML/CV Component"]:::ml
    end
```
