# 1bananachicken/maante architecture

> Architecture diagram of the GitHub repository 1bananachicken/maante, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-07-19). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/1bananachicken/maante
- Repository: https://github.com/1bananachicken/maante

## Overview

#### Purpose and Runtime
MaaNTE is a Windows automation assistant for the game 《异环》, built on MaaFramework. It recognizes game UI/audio and simulates ordinary input; it does not modify game files. The primary runtime is Python plus MaaFramework pipeline resources, targeting a 1280×720 windowed game client. Dependencies are declared in `requirements.txt`; release/build orchestration begins at `build.py`.

#### Entry and Framework Boundary
`agent/main.py` is the Python agent entry point exposed to MaaFramework. It bridges declarative pipeline nodes to custom Python actions under `agent/custom/action/`. Shared runtime concerns—logging, localization, screen access, process/window focus, and environment handling—sit in:
- `agent/utils/logger.py`
- `agent/utils/i18n.py`
- `agent/utils/maafocus.py`

The framework executes task/pipeline definitions; Python code is invoked for behavior that needs state, decision logic, external input, or nonstandard recognition.

#### Declarative Automation Layer
Pipeline JSON defines recognition, actions, transitions, and scene/task flow. It is the main orchestration boundary between image assets and Python actions:
- `assets/resource/base/pipeline/`
- `assets/resource/tasks/`
- `assets/resource/tasks/preset/`

Tasks expose user-selectable automations and presets compose them into daily/AFK/realtime runs. Pipeline schemas in `deps/tools/pipeline.schema.json` and custom-action schemas constrain this contract.

#### Visual Recognition and Scene Control
Screen-driven flows use templates and model assets to detect UI state, then pipelines dispatch clicks, keys, or custom actions. Core scene definitions and shared button recognition are centralized in:
- `assets/resource/base/pipeline/SceneManager/`
- `assets/resource/base/pipeline/Common/Button/`
- `assets/resource/base/image/`

This separation lets feature pipelines reuse canonical world/login/menu/scenes and UI controls rather than embedding game-state detection in each feature.

#### Feature Action Modules
Feature implementations are modular Python action packages paired with pipeline/task definitions. Major domains include fishing, coffee, furniture, rewards, heist, Tetris, rhythm, piano, sound-triggered dodge, and realtime assistance:
- `agent/custom/action/AutoFish/`
- `agent/custom/action/AutoCoffee/`
- `agent/custom/action/PinkPawHeist/`

Each module consumes framework recognition/state and emits input or follow-up control decisions. Feature-specific assets and pipelines remain under corresponding `assets/resource/base/image/` and `assets/resource/base/pipeline/` subtrees.

#### Navigation and Movement Subsystem
Navigation is a distinct stateful subsystem: routes and map coordinates feed route planning, waypoint execution, local/online navigation actions, and an optional WebSocket service:
- `agent/custom/action/Navi/route_runner.py`
- `agent/custom/action/Navi/navigation_server.py`
- `agent/custom/action/Navi/route_websocket_service.py`

Persistent route data lives in `assets/resource/routes/`; teleport point metadata is in `assets/resource/base/map_teleport/`. Movement and teleport pipelines provide reusable lower-level execution boundaries.

#### Specialized Perception and Control
Not all automation is template-only. Audio dodge listens for sound cues and triggers dodge/counter input:
- `agent/custom/action/SoundTrigger/SoundListener.py`
- `agent/custom/action/SoundTrigger/SoundDodgeAction.py`
- `assets/resource/base/sounds/`

Game-playing features embed local decision engines, notably Tetris board/piece/scene analysis and rhythm detection:
- `agent/custom/action/Tetris/`
- `agent/custom/action/rhythm/`
- `agent/custom/action/auto_piano/`

#### Distribution, UI, and External Services
The repository supplies automation content rather than a standalone web application. MaaFramework and MXU provide the external automation/runtime/UI foundation; model/common assets are represented by `assets/MaaNTEModels` and `assets/MaaCommonAssets`. `assets/interface.json` defines the framework-facing interface. GitHub Actions handle installation, schema synchronization, i18n sync, releases, and documentation notification under `.github/workflows/`.

Main entry points: [`assets/resource/base/pipeline`](https://github.com/1bananachicken/maante/tree/dev/assets/resource/base/pipeline) (Base pipelines), [`agent/custom/action`](https://github.com/1bananachicken/maante/tree/dev/agent/custom/action) (Feature action modules), [`agent/custom/action/Navi/route_runner.py`](https://github.com/1bananachicken/maante/blob/dev/agent/custom/action/Navi/route_runner.py) (Route runner), [`agent/main.py`](https://github.com/1bananachicken/maante/blob/dev/agent/main.py) (Python agent entry)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_runtime["Agent Runtime"]
  node_entry["Python agent entry<br/>[main.py]"]
  node_runtime_utils["Runtime utilities<br/>shared services<br/>[logger.py]"]
  node_feature_actions["Feature action modules<br/>Python actions"]
end

subgraph group_resources["Automation Resources"]
  node_pipelines["Base pipelines<br/>pipeline definitions"]
  node_tasks["Tasks and presets<br/>task definitions"]
  node_scene_manager["Scene manager<br/>scene pipelines"]
  node_button_recognition["Shared button recognition<br/>UI pipelines"]
  node_image_assets[("Image and model assets<br/>visual assets")]
  node_pipeline_schema["Pipeline schema<br/>contract schema"]
end

subgraph group_navigation["Navigation"]
  node_routes[("Route data<br/>persistent routes")]
  node_teleport_metadata[("Teleport metadata<br/>map data")]
  node_route_runner["Route runner<br/>navigation action<br/>[route_runner.py]"]
  node_navigation_server["Navigation server<br/>navigation action"]
  node_route_websocket["Route WebSocket service"]
end

subgraph group_specialized["Specialized Control"]
  node_sound_control["Audio dodge control<br/>perception actions<br/>[SoundListener.py]"]
  node_sound_assets[("Sound assets<br/>audio assets")]
  node_gameplay_engines["Local gameplay engines<br/>decision actions"]
end

subgraph group_delivery["Integration &amp; Delivery"]
  node_interface["Framework interface<br/>interface definition<br/>[interface.json]"]
  node_build["Build orchestration<br/>build entry<br/>[build.py]"]
  node_workflows["GitHub workflows<br/>CI/CD<br/>[workflows]"]
  node_common_assets[("Shared Maa assets<br/>framework assets")]
end

node_maaframework{{"MaaFramework / MXU<br/>external runtime"}}

node_maaframework -->|"loads agent"| node_entry
node_maaframework -->|"executes"| node_pipelines
node_maaframework -->|"reads"| node_interface
node_entry -->|"dispatches"| node_feature_actions
node_entry -->|"uses"| node_runtime_utils
node_pipelines -->|"invokes custom actions"| node_feature_actions
node_tasks -->|"composes"| node_pipelines
node_pipelines -->|"reuses scenes"| node_scene_manager
node_pipelines -->|"reuses controls"| node_button_recognition
node_scene_manager -->|"recognizes with"| node_image_assets
node_button_recognition -->|"matches"| node_image_assets
node_pipeline_schema -.->|"validates"| node_pipelines
node_feature_actions -->|"includes"| node_route_runner
node_route_runner -->|"reads"| node_routes
node_route_runner -->|"uses"| node_teleport_metadata
node_navigation_server -->|"requests navigation"| node_route_runner
node_route_websocket -->|"serves requests"| node_navigation_server
node_feature_actions -->|"includes"| node_sound_control
node_sound_control -->|"listens for cues"| node_sound_assets
node_feature_actions -->|"includes"| node_gameplay_engines
node_build -.->|"supports delivery"| node_workflows
node_maaframework -->|"uses"| node_common_assets

click node_entry "https://github.com/1bananachicken/maante/blob/dev/agent/main.py"
click node_runtime_utils "https://github.com/1bananachicken/maante/blob/dev/agent/utils/logger.py"
click node_feature_actions "https://github.com/1bananachicken/maante/tree/dev/agent/custom/action"
click node_pipelines "https://github.com/1bananachicken/maante/tree/dev/assets/resource/base/pipeline"
click node_tasks "https://github.com/1bananachicken/maante/tree/dev/assets/resource/tasks"
click node_scene_manager "https://github.com/1bananachicken/maante/tree/dev/assets/resource/base/pipeline/SceneManager"
click node_button_recognition "https://github.com/1bananachicken/maante/tree/dev/assets/resource/base/pipeline/Common/Button"
click node_image_assets "https://github.com/1bananachicken/maante/tree/dev/assets/resource/base/image"
click node_pipeline_schema "https://github.com/1bananachicken/maante/blob/dev/deps/tools/pipeline.schema.json"
click node_routes "https://github.com/1bananachicken/maante/tree/dev/assets/resource/routes"
click node_teleport_metadata "https://github.com/1bananachicken/maante/tree/dev/assets/resource/base/map_teleport"
click node_route_runner "https://github.com/1bananachicken/maante/blob/dev/agent/custom/action/Navi/route_runner.py"
click node_navigation_server "https://github.com/1bananachicken/maante/blob/dev/agent/custom/action/Navi/navigation_server.py"
click node_route_websocket "https://github.com/1bananachicken/maante/blob/dev/agent/custom/action/Navi/route_websocket_service.py"
click node_sound_control "https://github.com/1bananachicken/maante/blob/dev/agent/custom/action/SoundTrigger/SoundListener.py"
click node_sound_assets "https://github.com/1bananachicken/maante/tree/dev/assets/resource/base/sounds"
click node_gameplay_engines "https://github.com/1bananachicken/maante/tree/dev/agent/custom/action/Tetris"
click node_interface "https://github.com/1bananachicken/maante/blob/dev/assets/interface.json"
click node_build "https://github.com/1bananachicken/maante/blob/dev/build.py"
click node_workflows "https://github.com/1bananachicken/maante/tree/dev/.github/workflows"
click node_common_assets "https://github.com/1bananachicken/maante/tree/dev/assets/MaaCommonAssets"

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_entry,node_runtime_utils,node_feature_actions toneBlue
class node_pipelines,node_tasks,node_scene_manager,node_button_recognition,node_image_assets,node_pipeline_schema toneAmber
class node_routes,node_teleport_metadata,node_route_runner,node_navigation_server,node_route_websocket toneMint
class node_sound_control,node_sound_assets,node_gameplay_engines toneRose
class node_interface,node_build,node_workflows,node_common_assets toneIndigo
class node_maaframework toneNeutral
```

## Components

### Agent Runtime

- [Python agent entry](https://github.com/1bananachicken/maante/blob/dev/agent/main.py): agent entry · Exposes custom Python behavior to MaaFramework. · `agent/main.py`
- [Runtime utilities](https://github.com/1bananachicken/maante/blob/dev/agent/utils/logger.py): shared services · Logging, localization, focus, screen, and environment support. · `agent/utils/logger.py`
- [Feature action modules](https://github.com/1bananachicken/maante/tree/dev/agent/custom/action): Python actions · Stateful automation behavior for game features. · `agent/custom/action`

### Automation Resources

- [Base pipelines](https://github.com/1bananachicken/maante/tree/dev/assets/resource/base/pipeline): pipeline definitions · Declarative recognition, input, transitions, and scene flow. · `assets/resource/base/pipeline`
- [Tasks and presets](https://github.com/1bananachicken/maante/tree/dev/assets/resource/tasks): task definitions · User-selectable automations and composed daily, AFK, and realtime runs. · `assets/resource/tasks`
- [Scene manager](https://github.com/1bananachicken/maante/tree/dev/assets/resource/base/pipeline/SceneManager): scene pipelines · Canonical world, login, and menu state detection. · `assets/resource/base/pipeline/SceneManager`
- [Shared button recognition](https://github.com/1bananachicken/maante/tree/dev/assets/resource/base/pipeline/Common/Button): UI pipelines · Reusable UI-control recognition. · `assets/resource/base/pipeline/Common/Button`
- [Image and model assets](https://github.com/1bananachicken/maante/tree/dev/assets/resource/base/image): visual assets · Templates and models used for screen recognition. · `assets/resource/base/image`
- [Pipeline schema](https://github.com/1bananachicken/maante/blob/dev/deps/tools/pipeline.schema.json): contract schema · Constrains pipeline and custom-action contracts. · `deps/tools/pipeline.schema.json`

### Navigation

- [Route data](https://github.com/1bananachicken/maante/tree/dev/assets/resource/routes): persistent routes · Saved routes and map coordinates. · `assets/resource/routes`
- [Teleport metadata](https://github.com/1bananachicken/maante/tree/dev/assets/resource/base/map_teleport): map data · Teleport point definitions. · `assets/resource/base/map_teleport`
- [Route runner](https://github.com/1bananachicken/maante/blob/dev/agent/custom/action/Navi/route_runner.py): navigation action · Plans and executes waypoint movement. · `agent/custom/action/Navi/route_runner.py`
- [Navigation server](https://github.com/1bananachicken/maante/blob/dev/agent/custom/action/Navi/navigation_server.py): navigation action · Supports local and online navigation requests. · `agent/custom/action/Navi/navigation_server.py`
- [Route WebSocket service](https://github.com/1bananachicken/maante/blob/dev/agent/custom/action/Navi/route_websocket_service.py): WebSocket service · Optional external route-control interface. · `agent/custom/action/Navi/route_websocket_service.py`

### Specialized Control

- [Audio dodge control](https://github.com/1bananachicken/maante/blob/dev/agent/custom/action/SoundTrigger/SoundListener.py): perception actions · Detects sound cues and issues dodge or counter input. · `agent/custom/action/SoundTrigger/SoundListener.py`
- [Sound assets](https://github.com/1bananachicken/maante/tree/dev/assets/resource/base/sounds): audio assets · `assets/resource/base/sounds`
- [Local gameplay engines](https://github.com/1bananachicken/maante/tree/dev/agent/custom/action/Tetris): decision actions · Tetris, rhythm, and piano analysis and control. · `agent/custom/action/Tetris`

### Integration & Delivery

- [Framework interface](https://github.com/1bananachicken/maante/blob/dev/assets/interface.json): interface definition · Defines the MaaFramework-facing interface. · `assets/interface.json`
- [Build orchestration](https://github.com/1bananachicken/maante/blob/dev/build.py): build entry · Starts release and build orchestration. · `build.py`
- [GitHub workflows](https://github.com/1bananachicken/maante/tree/dev/.github/workflows): CI/CD · Automation for installation, schemas, i18n, releases, and documentation. · `.github/workflows`
- [Shared Maa assets](https://github.com/1bananachicken/maante/tree/dev/assets/MaaCommonAssets): framework assets · `assets/MaaCommonAssets`

### Other components

- **MaaFramework / MXU**: external runtime · Executes automation pipelines and provides the UI foundation.

## Connections

- MaaFramework / MXU → Python agent entry: loads agent
- MaaFramework / MXU → Base pipelines: executes
- MaaFramework / MXU → Framework interface: reads
- Python agent entry → Feature action modules: dispatches
- Python agent entry → Runtime utilities: uses
- Base pipelines → Feature action modules: invokes custom actions
- Tasks and presets → Base pipelines: composes
- Base pipelines → Scene manager: reuses scenes
- Base pipelines → Shared button recognition: reuses controls
- Scene manager → Image and model assets: recognizes with
- Shared button recognition → Image and model assets: matches
- Pipeline schema → Base pipelines: validates
- Feature action modules → Route runner: includes
- Route runner → Route data: reads
- Route runner → Teleport metadata: uses
- Navigation server → Route runner: requests navigation
- Route WebSocket service → Navigation server: serves requests
- Feature action modules → Audio dodge control: includes
- Audio dodge control → Sound assets: listens for cues
- Feature action modules → Local gameplay engines: includes
- Build orchestration → GitHub workflows: supports delivery
- MaaFramework / MXU → Shared Maa assets: uses
