# cleitonleonel/pyquotex architecture

> Architecture diagram of the GitHub repository cleitonleonel/pyquotex, 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/cleitonleonel/pyquotex
- Repository: https://github.com/cleitonleonel/pyquotex

## Overview

##### Project Type and Purpose
- The project is a Python library (not a full-stack app or trading bot on its own) that provides developers with tools to automate communication with the Quotex platform.
- It abstracts away the details of the Quotex API (authentication, data retrieval, order management, etc.) via both HTTP and WebSocket channels.
- The design emphasizes real-time data (candlestick data, sentiment, etc.) and a collection of modular functions (e.g., connection, balance management, buying operations).

##### File Structure
- Top-level files and directories:
- app.py: Likely an example entry point for using the library.
- quotexapi: The main package containing core modules.
- examples: Sample scripts to demonstrate usage.
- docs: Documentation in multiple languages.
- .github: GitHub workflows and CI/CD pipelines.
- Within quotexapi, note the separation into submodules:
- API-related logic (quotexapi/api.py, stable_api.py): Core interfaces to interact with the Quotex server.
- HTTP communication (quotexapi/http): Modules handling login, logout, history, resource, settings, etc.
- WebSocket communication (quotexapi/ws): Contains channels (e.g., buy, candles, sell_option, ssid) and objects used for streaming real-time data.
- Utility functions (quotexapi/utils): For calculating indicators, installing dependencies (Playwright), processing data, and service routines.
- Other support files include configuration (quotexapi/config.py), expiration handling, and global variables.

a. Main Components:
- Client Application / Entry Point (app.py and examples): Where developers initiate the library.
- Core Quotex Library (quotexapi package):
- Initialization & Configuration (config.py, global_value.py)
- API Client Abstraction (api.py, stable_api.py)
- HTTP Module: Modules under quotexapi/http (login, logout, history, etc.)
- WebSocket Module: Modules under quotexapi/ws including separate channels and objects that manage real-time communications.
- Utility Module: Helper functions (quotexapi/utils) for data processing, indicator calculations, and Playwright-related tasks.
- External Dependencies & APIs:
- Quotex API itself (remote server endpoints).
- Third-party tools (e.g., Playwright for browser support, OpenSSL as per installation notes).

b. Relationships and Interactions:
- The entry point (app.py) calls functions implemented in the stable_api and related modules.
- HTTP Subsystem (for operations like login, data retrieval via HTTP endpoints).
- WebSocket Subsystem (for real-time data, option trading actions, streaming candles, etc.).
- Utility functions support the API Client by processing data (candles, indicators) and performing installations (Playwright_install).
- The examples show integration, so include a “Developer Integrations” block that uses the library.

c. Architectural Patterns & Design Principles:
- Modular design: Each module (HTTP, WS, utils) is separated by responsibility.
- Asynchronous programming: Significant use of async/await (visible in connection testing and data retrieval functions) ensures non-blocking I/O.
- Extensibility: The library is built to be easily integrated into third-party systems for trading operations.
- Separation of concerns: Clear demarcation between connection/authentication, data retrieval, order operations, and data processing.

- Decompose the API client into two major branches: HTTP communication and WebSocket communication.
- An extra section that shows integration points with utility modules and external services.

## Diagram (Mermaid)

```mermaid
graph TD
    %% Client Applications
    subgraph "Client Applications"
        A["app.py"]:::entry
        B["Examples"]:::entry
    end

    %% Core Quotex Library
    subgraph "Core Quotex Library"
        subgraph "Initialization & Configuration"
            C["config.py"]:::core
            D["global_value.py"]:::core
        end
        E["API Abstraction<br/>(api.py, stable_api.py)"]:::core
    end

    %% HTTP Communication Layer
    subgraph "HTTP Communication Layer"
        H["HTTP Modules<br/>(quotexapi/http)"]:::http
    end

    %% WebSocket Communication Layer
    subgraph "WebSocket Communication Layer"
        subgraph "Channels"
            I["Channels<br/>(quotexapi/ws/channels)"]:::websocket
        end
        subgraph "Objects"
            J["Objects<br/>(quotexapi/ws/objects)"]:::websocket
            K["WS Client<br/>(quotexapi/ws/client.py)"]:::websocket
        end
    end

    %% Utility & Helper Functions
    subgraph "Utility & Helper Functions"
        U["Utilities<br/>(quotexapi/utils)"]:::utils
    end

    %% Expiration Handling
    L["Expiration Handling<br/>(quotexapi/expiration.py)"]:::core
    
    %% External Services
    subgraph "External Services"
        X["Playwright"]:::external
        Y["OpenSSL"]:::external
        Z["Quotex API Endpoints"]:::external
    end

    %% Relationships
    A -->|"calls"| E
    B -->|"integrates"| E
    E -->|"uses"| C
    E -->|"uses"| D
    E -->|"HTTP call"| H
    E -->|"opens WS channel"| I
    E -->|"manages WS"| K
    E -->|"supports with data processing"| U
    E -->|"checks expiry"| L
    E -->|"sends/receives"| Z
    H -->|"communicates with"| Z
    I -->|"streams data from"| Z
    K -->|"maintains WS connection with"| Z
    U -->|"installs via"| X
    E -->|"ensures secure connection with"| Y

    %% Click Events
    click A "https://github.com/cleitonleonel/pyquotex/blob/master/app.py"
    click B "https://github.com/cleitonleonel/pyquotex/tree/master/examples/"
    click E "https://github.com/cleitonleonel/pyquotex/blob/master/quotexapi/api.py"
    click C "https://github.com/cleitonleonel/pyquotex/blob/master/quotexapi/config.py"
    click D "https://github.com/cleitonleonel/pyquotex/blob/master/quotexapi/global_value.py"
    click H "https://github.com/cleitonleonel/pyquotex/tree/master/quotexapi/http/"
    click I "https://github.com/cleitonleonel/pyquotex/tree/master/quotexapi/ws/channels/"
    click J "https://github.com/cleitonleonel/pyquotex/tree/master/quotexapi/ws/objects/"
    click K "https://github.com/cleitonleonel/pyquotex/blob/master/quotexapi/ws/client.py"
    click U "https://github.com/cleitonleonel/pyquotex/tree/master/quotexapi/utils/"
    click L "https://github.com/cleitonleonel/pyquotex/blob/master/quotexapi/expiration.py"
    click X "https://github.com/cleitonleonel/pyquotex/blob/master/quotexapi/utils/playwright_install.py"

    %% Styles
    classDef entry fill:#f9e79f,stroke:#d35400,stroke-width:2px;
    classDef core fill:#d5f5e3,stroke:#27ae60,stroke-width:2px;
    classDef http fill:#d6eaf8,stroke:#2980b9,stroke-width:2px;
    classDef websocket fill:#fadbd8,stroke:#c0392b,stroke-width:2px;
    classDef utils fill:#fcf3cf,stroke:#f1c40f,stroke-width:2px;
    classDef external fill:#e8daef,stroke:#8e44ad,stroke-width:2px;
```
