# mrcatplay/autoresell architecture

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

- Interactive diagram: https://gitdiagram.com/mrcatplay/autoresell
- Repository: https://github.com/mrcatplay/autoresell

## Overview

##### Project Type and Purpose
- This is a Node.js automation tool (“bot”) designed to log into multiple Minecraft anarchy servers (with optional SOCKS5 proxies), automatically sell a specified in-game item at a configured price, and send sale notifications to a Telegram chat.
- Key indicators: presence of index.js as entry point, modules like Autoresel.js (automation), sendTelegram.js (notifications), processChatCommand.js (runtime commands), and a JSON config (Name.json) specifying bot accounts and Telegram settings.

##### File Structure Analysis
- Top-level files:
- index.js – orchestrates startup, reads config, kicks off bot workflows
- Name.json – configuration (Telegram token/chatId, sale price, user account details, proxy settings)
- Autoresel.js – core item-selling logic using the Minecraft protocol
- processChatCommand.js – handles incoming Telegram chat commands at runtime
- sendTelegram.js – wrapper around the Telegram Bot API for notifications
- startBOT/Proxy.js + startBOT/NotProxy.js – two variants of the per-account bot runner, chosen based on presence of proxy config

- No database or front-end; modular CLI service with external integrations: Minecraft servers and Telegram.

##### Key README Insights
- The JSON config drives everything: token, chat ID, main recipient, target item, price, and an array of user bots (with optional proxies).
- Launch is simply `node index.js` after config.

a. Main Components
- Config Loader (reads Name.json)
- Bot Orchestrator (index.js)
- Bot Worker Module – two variants:
– Proxy-enabled (startBOT/Proxy.js)
– Direct (startBOT/NotProxy.js)
- Auto-Seller Logic (Autoresel.js)
- Telegram Command Processor (processChatCommand.js)
- Telegram Notifier (sendTelegram.js)
- External Systems: Minecraft Anarchy Servers + Telegram Bot API

b. Relationships & Data Flows
1) On start, Config Loader → passes settings to Bot Orchestrator.
2) Bot Orchestrator spawns one Bot Worker per user: picks Proxy.js if proxy settings exist, else NotProxy.js.
3) Each Bot Worker uses Autoresel.js to:
- To Minecraft server (via proxy or direct)
- Authenticate with nickname/password
- Monitor in-game store, execute sale at configured price
- Emit sale events or errors back to Orchestrator
4) Orchestrator forwards sale events to Telegram Notifier, which calls Telegram Bot API.
5) processChatCommand.js listens for incoming Telegram commands (e.g., status requests), routes them to Orchestrator at runtime.

c. Architectural Patterns & Principles
- Modular separation of concerns: config, orchestration, worker logic, notifications, command handling
- Strategy pattern for proxy vs. non-proxy workers
- Event-driven notifications (Emit/Listen between workers and notifier)

d. Key Technologies
- Node.js runtime
- Telegram Bot API (via sendTelegram.js)
- Minecraft protocol library (inside Autoresel.js)
- SOCKS5 proxy handling (in Proxy.js)

## Diagram (Mermaid)

```mermaid
flowchart TD
    Config["Config Loader\n(Name.json)"]:::config
    Orch["Bot Orchestrator\n(index.js)"]:::core
    subgraph "Bot Workers"
        direction TB
        Proxy["Proxy Worker\n(startBOT/Proxy.js)"]:::worker
        Direct["Direct Worker\n(startBOT/NotProxy.js)"]:::worker
    end
    Auto["Auto-Seller Logic\n(Autoresel.js)"]:::worker
    Notif["Telegram Notifier\n(sendTelegram.js)"]:::core
    Cmd["Telegram Command Processor\n(processChatCommand.js)"]:::core
    ExtMC["Minecraft Servers"]:::external
    ExtTG["Telegram Bot API"]:::external

    Config -->|"load config"| Orch
    Orch -->|"spawn Proxy if proxy"| Proxy
    Orch -->|"spawn Direct if no proxy"| Direct
    Proxy -->|"delegate selling"| Auto
    Direct -->|"delegate selling"| Auto
    Auto -->|"authenticate/connect"| ExtMC
    Auto -->|"sale event"| Orch
    Orch -->|"forward sale event"| Notif
    Notif -->|"send notification"| ExtTG
    ExtTG -->|"incoming commands"| Cmd
    Cmd -->|"runtime command"| Orch

    classDef config fill:#dddddd,stroke:#333,stroke-width:1px
    classDef core fill:#aaddff,stroke:#333,stroke-width:1px
    classDef worker fill:#aaffaa,stroke:#333,stroke-width:1px
    classDef external fill:#ffd699,stroke:#333,stroke-width:1px

    click Config "https://github.com/mrcatplay/autoresell/blob/master/Name.json"
    click Orch "https://github.com/mrcatplay/autoresell/blob/master/index.js"
    click Proxy "https://github.com/mrcatplay/autoresell/blob/master/startBOT/Proxy.js"
    click Direct "https://github.com/mrcatplay/autoresell/blob/master/startBOT/NotProxy.js"
    click Auto "https://github.com/mrcatplay/autoresell/blob/master/Autoresel.js"
    click Notif "https://github.com/mrcatplay/autoresell/blob/master/sendTelegram.js"
    click Cmd "https://github.com/mrcatplay/autoresell/blob/master/processChatCommand.js"
```
