# lucas-campagna/mt5linux architecture

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

- Interactive diagram: https://gitdiagram.com/lucas-campagna/mt5linux
- Repository: https://github.com/lucas-campagna/mt5linux

## Overview

##### Project Type and Purpose
- This package acts as a bridge allowing MetaTrader5 (a Windows-based trading platform) to be used on Linux. It leverages Wine to run a Windows Python environment and the MetaTrader5 library and uses rpyc to create a server–client communication model.
- The goal is to have a server (running inside Wine on Linux, executing Windows Python code) that exposes MetaTrader5 functionalities via an rpyc interface. Linux clients then connect to this server to perform trading operations.

##### Analyzing the File Structure
- The top-level “mt5linux” directory is the core package. With its __main__.py, it provides a command-line entry point to start the server.
- The presence of setup.py, setup.cfg, and requirements.txt indicate a standard Python package structure, and tests show at least one basic integration test.
- No separate “frontend” or complex backend directories exist, confirming that the design is focused on bridging the Wine-powered Windows subsystem with standard Linux-based Python client code.

##### Insights from the README
- The README clearly explains the dual-environment usage:
- On the Windows side (inside Wine), run the server using the command: “python -m mt5linux <path/to/python.exe>”.
- On the Linux side, scripts connect to the server using the mt5linux package.
- Key external dependencies include Wine, rpyc, and the MetaTrader5 library.

## Diagram (Mermaid)

```mermaid
flowchart TD
    LC["Linux Client (mt5linux)"]:::linux
    subgraph "Wine (Windows Python Environment)"
        SE["Server Entry Point & rpyc Server (mt5linux/__main__.py)"]:::communication
        MT["MetaTrader5 Library"]:::library
    end

    LC -->|"RPC_call(host=localhost,port=18812)"| SE
    SE -->|"Executes_trade_ops"| MT
    MT -->|"Returns_trading_data"| SE
    SE -->|"Sends_response"| LC

    click LC "https://github.com/lucas-campagna/mt5linux/tree/master/mt5linux/"
    click SE "https://github.com/lucas-campagna/mt5linux/blob/master/mt5linux/__main__.py"

    classDef linux fill:#D6EAF8,stroke:#2E86C1,stroke-width:2px;
    classDef communication fill:#ABEBC6,stroke:#28B463,stroke-width:2px;
    classDef library fill:#F5B7B1,stroke:#C0392B,stroke-width:2px;
```
