# ton-blockchain/mytonctrl architecture

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

- Interactive diagram: https://gitdiagram.com/ton-blockchain/mytonctrl
- Repository: https://github.com/ton-blockchain/mytonctrl

## Overview

##### Project type and purpose
- MyTonCtrl is primarily a console-based node/validator management application for the TON blockchain.
- It acts as a wrapper around external TON tooling (`fift`, `lite-client`, `validator-engine-console`) and also provides installer functionality (`mytoninstaller`), core business logic (`modules`), and a core API library (`mytoncore`).

##### File structure
- Top‐level directories:
- `functions/` – small standalone utility functions (e.g., session statistics).
- `modules/` – command implementations covering alerting, backups, pool/nominator/validator management, telemetry, Prometheus, wallets, etc.
- `mytoncore/` – core Python library exposing abstractions over Fift, lite‐client, contracts, telemetry, models, and scanner.
- `mytonctrl/` – CLI front‐end application that ties together `modules` and `mytoncore` to present user commands and an installer mode.
- `mytoninstaller/` – installer front‐end for setting up TON node or validator, packaging systemd, JSON-RPC, toncenter, and related scripts.
- `scripts/` and `tools/` – miscellaneous shell and Python scripts for installation, backups, key injection, etc.
- `tests/` – integration/functional tests for block scanning, TPS load, bounce tests.
- Notice patterns:
- A layered architecture (CLI → modules → core library → external executables & contracts).
- An installer sub‐application with its own configuration and scripts.
- Subdirectories for contracts under `mytoncore/contracts` indicating embedded smart-contract artifacts.

##### README for additional insights
- Confirms console application wrapping Fift, lite-client, validator console.
- Describes two installation modes: `liteserver` or `validator`.
- Mentions telemetry to `toncenter.com` and optional web admin panel / local toncenter copy.

- application modules in another,
- external executables in a third,
- external services/endpoints in a fourth.
- Notes on deployment: Linux environment, Python interpreter, systemd.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Actors
    User["User"]:::actor

    %% User / CLI Layer
    subgraph "User / CLI Layer"
        Mytonctrl["mytonctrl CLI"]:::cli
        Mytoninstaller["mytoninstaller CLI"]:::cli
    end

    %% Installer Flow Components
    subgraph "Installer Flow"
        Scripts["scripts"]:::support
        Systemd["systemd"]:::infra
        JSONRPC["JSON-RPC / Web Admin"]:::service
    end

    %% Application Logic Layer
    subgraph "Application Logic Layer"
        Modules["modules"]:::modules
    end

    %% Core API Layer
    subgraph "Core API Layer"
        Mytoncore["mytoncore"]:::core
    end

    %% External Executables & Contracts
    subgraph "External Executables & Contracts"
        Execs["fift / lite-client / validator-engine-console & Contracts"]:::external
    end

    %% Persistent Store
    subgraph "Persistent Store"
        FS["Local Files (wallets, configs)"]:::storage
    end

    %% Supporting Tools
    subgraph "Supporting Scripts & Tools"
        Tools["tools"]:::support
    end

    %% External Services & Resources
    subgraph "External Services & Resources"
        TONNetwork["TON Network (RPC)"]:::service
        Telemetry["Telemetry Endpoint (toncenter.com)"]:::service
    end

    %% Tests
    subgraph "Integration / Functional Tests"
        Tests["tests"]:::test
    end

    %% Connections
    User --> Mytonctrl
    User --> Mytoninstaller

    Mytonctrl --> Modules
    Modules --> Mytoncore
    Mytoncore --> Execs
    Execs --> TONNetwork
    Mytoncore -->|Telemetry Data| Telemetry

    Mytoninstaller --> Scripts
    Scripts --> Systemd
    Scripts --> JSONRPC
    Scripts --> FS

    Modules --> FS
    Tools --> FS

    FS --> Modules
    FS --> Mytoninstaller

    Tools --> Mytoninstaller

    Tests --> Mytoncore
    Tests --> Execs
    Tests --> Modules

    %% Click Events
    click Mytonctrl "https://github.com/ton-blockchain/mytonctrl/blob/master/mytonctrl/__main__.py"
    click Mytoninstaller "https://github.com/ton-blockchain/mytonctrl/blob/master/mytoninstaller/__main__.py"
    click Modules "https://github.com/ton-blockchain/mytonctrl/tree/master/modules/"
    click Mytoncore "https://github.com/ton-blockchain/mytonctrl/tree/master/mytoncore/"
    click Scripts "https://github.com/ton-blockchain/mytonctrl/tree/master/scripts/"
    click Tools "https://github.com/ton-blockchain/mytonctrl/tree/master/tools/"
    click Tests "https://github.com/ton-blockchain/mytonctrl/tree/master/tests/"

    %% Styles
    classDef actor fill:#f9f,stroke:#333,stroke-width:2px;
    classDef cli fill:#bbf,stroke:#333,stroke-width:1px;
    classDef modules fill:#bfb,stroke:#333,stroke-width:1px;
    classDef core fill:#ffb,stroke:#333,stroke-width:1px;
    classDef external fill:#fbb,stroke:#333,stroke-width:1px;
    classDef support fill:#fbf,stroke:#333,stroke-width:1px;
    classDef storage fill:#eef,stroke:#333,stroke-width:1px;
    classDef service fill:#def,stroke:#333,stroke-width:1px;
    classDef infra fill:#ddd,stroke:#333,stroke-width:1px;
    classDef test fill:#ffd,stroke:#333,stroke-width:1px;
```
