# phybyte/mvx-api-deployer architecture

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

- Interactive diagram: https://gitdiagram.com/phybyte/mvx-api-deployer
- Repository: https://github.com/phybyte/mvx-api-deployer

## Overview

##### Identifying the Main Components
- Deployment Scripts: Represent the initialization, installation, and start scripts (1-Init.sh, 2-Install.sh, 3-Start.sh) as the entry point for managing and orchestrating the setup.
- Configuration: Include the central configuration file (config.cfg) and the structured configuration directories under config/ covering different network types (devnet, mainnet) and their respective service configurations.
- ElasticSearch Indexer: Represent this as the service that processes raw blockchain data. Show its dependencies on configuration files in the mx-chain-es-indexer-go directories.
- ElasticSearch Database & Kibana: Illustrate these as the storage and visualization layers that handle indexing and visualization of the blockchain data, according to the deployment description.
- MultiversX API: Represent the API service which exposes an external REST interface to query the blockchain data.
- xExchange Service: Include the exchange service component (mx-exchange-service) responsible for feeding data into the API.
- Supporting Services and Infrastructure: Optionally illustrate the bash-based maintenance commands, environment configuration (.env files) and docker-compose orchestration files that tie these components together.

##### Relationships and Interactions
- How the deployment scripts trigger the setup sequence by initializing the server, installing individual services, and finally starting them.
- That the Observing Squad components continuously collect blockchain data and feed it into the ElasticSearch Indexer.
- That the Indexer, in turn, transforms and loads the data into the ElasticSearch Database, which is then visualized by Kibana.
- That the MultiversX API pulls data from the ElasticSearch Database and also may interact with the xExchange service to enrich the API data.

##### Architectural Patterns and Technologies
- A modular microservices approach: Each service (observing nodes, indexer, API, xExchange) is built and managed separately.
- Usage of containerization (docker-compose files) as the mechanism to deploy services reliably.
- That the configuration is environment-specific (different folders for devnet and mainnet), meaning that the deployment can scale or change per network.
- Mention the reliance on Docker/Docker Compose for orchestration.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Deployment & Initialization
    subgraph "Deployment & Initialization"
        D1["1-Init.sh"]:::scripts
        D2["2-Install.sh"]:::scripts
        D3["3-Start.sh"]:::scripts
        DS["Scripts Directory"]:::scripts
        Cfg["Central Configuration (config.cfg)"]:::config
        Env["Environment Config (config/)"]:::config
    end

    %% Services
    subgraph "Services"
        subgraph "Observing Squad"
            OS_dev["Observing Squad (Devnet)"]:::service
            OS_main["Observing Squad (Mainnet)"]:::service
        end
        subgraph "ElasticSearch Indexer"
            EI_dev["ElasticSearch Indexer (Devnet)"]:::service
            EI_main["ElasticSearch Indexer (Mainnet)"]:::service
        end
        subgraph "Storage & Visualization"
            ES_DB["ElasticSearch DB"]:::db
            Kibana["Kibana"]:::service
        end
        subgraph "API & Exchange"
            API_dev["MultiversX API (Devnet)"]:::service
            API_main["MultiversX API (Mainnet)"]:::service
            XE_dev["xExchange Service (Devnet)"]:::service
            XE_main["xExchange Service (Mainnet)"]:::service
        end
        Orchestration["Docker Compose Orchestration"]:::orchestration
    end

    %% Relationships: Deployment triggers configuration
    D1 -->|"init"| Cfg
    D2 -->|"install"| Cfg
    D3 -->|"start"| Cfg
    DS -->|"maintenance"| Env
    Cfg -->|"loads"| Env

    %% Configuration flows to Services
    Env --> OS_dev
    Env --> OS_main
    Env --> EI_dev
    Env --> EI_main
    Env --> API_dev
    Env --> API_main
    Env --> XE_dev
    Env --> XE_main

    %% Observing Squad feeds into Indexers
    OS_dev -->|"feeds"| EI_dev
    OS_main -->|"feeds"| EI_main

    %% Indexers process data into ElasticSearch Database
    EI_dev -->|"indexes"| ES_DB
    EI_main -->|"indexes"| ES_DB

    %% Database supports visualization and API data serving
    ES_DB -->|"visualizes"| Kibana
    ES_DB -->|"serves-data"| API_dev
    ES_DB -->|"serves-data"| API_main

    %% API interacts with xExchange for data enrichment
    API_dev -->|"interacts"| XE_dev
    API_main -->|"interacts"| XE_main

    %% Orchestration oversees service deployment (dotted lines)
    Orchestration -.-> D1
    Orchestration -.-> D2
    Orchestration -.-> D3
    Orchestration -.-> EI_dev
    Orchestration -.-> EI_main
    Orchestration -.-> API_dev
    Orchestration -.-> API_main
    Orchestration -.-> XE_dev
    Orchestration -.-> XE_main

    %% Click Events for component mappings
    click D1 "https://github.com/phybyte/mvx-api-deployer/blob/main/1-Init.sh"
    click D2 "https://github.com/phybyte/mvx-api-deployer/blob/main/2-Install.sh"
    click D3 "https://github.com/phybyte/mvx-api-deployer/blob/main/3-Start.sh"
    click DS "https://github.com/phybyte/mvx-api-deployer/tree/main/scripts/"
    click Cfg "https://github.com/phybyte/mvx-api-deployer/blob/main/config.cfg"
    click Env "https://github.com/phybyte/mvx-api-deployer/tree/main/config/"
    click OS_dev "https://github.com/phybyte/mvx-api-deployer/tree/main/config/devnet/0-observingSquad/elrond-nodes"
    click OS_main "https://github.com/phybyte/mvx-api-deployer/tree/main/config/mainnet/0-observingSquad/elrond-nodes"
    click EI_dev "https://github.com/phybyte/mvx-api-deployer/tree/main/config/devnet/1-mx-chain-es-indexer-go"
    click EI_main "https://github.com/phybyte/mvx-api-deployer/tree/main/config/mainnet/1-mx-chain-es-indexer-go"
    click API_dev "https://github.com/phybyte/mvx-api-deployer/tree/main/config/devnet/3-mx-api-service"
    click API_main "https://github.com/phybyte/mvx-api-deployer/tree/main/config/mainnet/3-mx-api-service"
    click XE_dev "https://github.com/phybyte/mvx-api-deployer/tree/main/config/devnet/2-mx-exchange-service"
    click XE_main "https://github.com/phybyte/mvx-api-deployer/tree/main/config/mainnet/2-mx-exchange-service"

    %% Styles
    classDef scripts fill:#f9c,stroke:#333,stroke-width:2px;
    classDef config fill:#bbf,stroke:#333,stroke-width:2px;
    classDef service fill:#cff,stroke:#333,stroke-width:2px;
    classDef db fill:#afa,stroke:#333,stroke-width:2px;
    classDef orchestration fill:#fea,stroke:#333,stroke-width:2px;
```
