# andrzejmiskow/tradeai-advancing-algorithmic-trading-systems-with-time-series-transformer-for-cryptocurrency-data architecture

> Architecture diagram of the GitHub repository andrzejmiskow/tradeai-advancing-algorithmic-trading-systems-with-time-series-transformer-for-cryptocurrency-data, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-07-01). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/andrzejmiskow/tradeai-advancing-algorithmic-trading-systems-with-time-series-transformer-for-cryptocurrency-data
- Repository: https://github.com/andrzejmiskow/tradeai-advancing-algorithmic-trading-systems-with-time-series-transformer-for-cryptocurrency-data

## Overview

##### Project type and purpose
- This is a full-stack algorithmic trading research system (“TradeAI”) for cryptocurrency data, combining:
- A React-based frontend UI (in UI/)
- A Python backend service serving ML predictions & trading logic (in prediction_service/)
- Data pipelines and experiments for model training (in src/)
- Versioned datasets managed by DVC (in data/)
- Containerization for local and Azure deployment (Dockerfile, docker-compose.yml)

##### File structure
- Top-level:
- UI/: React app for visualization and user controls
- prediction_service/: Flask/FastAPI-style service hosting ML models, DRL execution, portfolio management, test clients
- src/: Offline pipeline—data ingestion, feature building, model training, evaluation, notebooks, experiments
- data/: DVC-tracked raw and processed data organized by sampling frequency and split (train/test)
- docker-compose.yml, Dockerfile: orchestrate UI, API, potential data volumes
- Patterns:
- Separation of concerns: frontend vs. service vs. offline pipelines
- Use of DVC for data versioning and reproducible pipelines
- MLflow (train_and_evaluate_mlflow_template.py) for experiments tracking
- Transformer and DRL strategy modules under prediction_service/transformers & drl_strategy.py

##### README for additional insights
- Purpose: investigate transformer models + DRL for medium-frequency crypto trading
- Technologies: React, Flask (or similar), PyTorch/TensorFlow transformers, DVC, Docker, Azure
- Architecture notes: full-stack, microservice-friendly, MLOps aspirations

##### Detail
- Interactions (e.g., “DVC pull/push”, “MLflow logging”, “Docker build & deploy”)
- Avoid over-aggregation: break the backend into prediction, execution, portfolio, data handlers

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Frontend Layer
    subgraph "Frontend Layer"
        UIApp["React Frontend"]:::service
        UIPublic["Public Assets"]:::data
    end

    %% Prediction Service Layer
    subgraph "Prediction API Service"
        PSApp["app.py"]:::service
        PSData["data.py"]:::service
        PSTransPred["transformer_predictor.py"]:::service
        PSDRL["drl_strategy.py"]:::service
        PSPortfolio["portfolio.py"]:::service
        PSExec["execution.py"]:::service
        PSTestClient["test_client.py"]:::service

        subgraph "Transformer Modules"
            TM1["ETSFormer_layers.py"]:::ml
            TM2["embeding.py"]:::ml
            TM3["model_layers.py"]:::ml
            TM4["models.py"]:::ml
            TM5["self_attention_layers.py"]:::ml
        end

        subgraph "Transformer Support"
            TMSupport["transformer_integration.py"]:::ml
        end
    end

    %% Offline Pipeline
    subgraph "Offline Pipeline"
        subgraph "Data Ingestion"
            Ingest1["make_dataset.py"]:::pipeline
            Ingest2["transform_orderbook.py"]:::pipeline
            Ingest3["split_data.ipynb"]:::pipeline
        end
        FE["build_features.py"]:::pipeline
        subgraph "Experiments"
            Exp1["train_pred.py"]:::pipeline
            Exp2["transformer_integration.py"]:::pipeline
        end
        MLFlow["train_and_evaluate_mlflow_template.py"]:::pipeline
        subgraph "Transformer Definitions"
            OfflineTM1["embeding.py"]:::ml
            OfflineTM2["model_layers.py"]:::ml
            OfflineTM3["models.py"]:::ml
            OfflineTM4["self_attention_layers.py"]:::ml
        end
        subgraph "Visualization"
            Viz1["visualize.py"]:::pipeline
            Viz2["view_lob_data.ipynb"]:::pipeline
        end
    end

    %% Data Storage
    subgraph "Data Storage"
        RawData["Raw Data"]:::data
        ProcData["Processed Data"]:::data
        DVCRemote["DVC Remote Storage"]:::external
        MLflowServer["MLflow Tracking"]:::external
    end

    %% Containerization & Orchestration
    subgraph "Container & Deployment"
        Dockerfile["Dockerfile"]:::external
        DockerCompose["docker-compose.yml"]:::external
        RunLocal["run_locally.sh"]:::external
        RunAzure["run_in_azure.sh"]:::external
    end

    %% External Services
    Exchange["Crypto Exchanges"]:::external
    Azure["Azure Cloud"]:::external

    %% Data and Control Flows
    UIApp -->|"REST API"| PSApp
    PSApp -->|uses| PSData
    PSApp -->|loads| PSTransPred
    PSApp -->|loads| PSDRL
    PSDRL -->|uses| PSTransPred
    PSDRL -->|allocates| PSPortfolio
    PSPortfolio -->|generates orders| PSExec
    PSExec -->|executes on| Exchange

    Ingest1 --> RawData
    Ingest2 --> RawData
    Ingest2 --> ProcData
    Ingest3 --> ProcData
    ProcData --> FE
    FE -->|"features"| Exp1
    FE -->|"features"| Exp2
    Exp1 --> OfflineTM1
    Exp1 --> OfflineTM2
    Exp1 --> OfflineTM3
    Exp1 --> OfflineTM4
    Exp1 --> MLFlow
    Exp2 --> MLFlow
    MLFlow --> MLflowServer
    MLFlow --> DVCRemote
    FE --> DVCRemote
    RawData --> DVCRemote

    %% Orchestration
    Dockerfile --> UIApp
    Dockerfile --> PSApp
    Dockerfile --> MLFlow
    DockerCompose --> Dockerfile
    RunLocal --> DockerCompose
    RunAzure --> Azure

    %% Click Events
    click UIApp "https://github.com/andrzejmiskow/tradeai-advancing-algorithmic-trading-systems-with-time-series-transformer-for-cryptocurrency-data/tree/main/UI/"
    click UIPublic "https://github.com/andrzejmiskow/tradeai-advancing-algorithmic-trading-systems-with-time-series-transformer-for-cryptocurrency-data/tree/main/UI/public/"
    click PSApp "https://github.com/andrzejmiskow/tradeai-advancing-algorithmic-trading-systems-with-time-series-transformer-for-cryptocurrency-data/blob/main/prediction_service/app.py"
    click PSData "https://github.com/andrzejmiskow/tradeai-advancing-algorithmic-trading-systems-with-time-series-transformer-for-cryptocurrency-data/blob/main/prediction_service/data.py"
    click PSTransPred "https://github.com/andrzejmiskow/tradeai-advancing-algorithmic-trading-systems-with-time-series-transformer-for-cryptocurrency-data/blob/main/prediction_service/transformer_predictor.py"
    click PSDRL "https://github.com/andrzejmiskow/tradeai-advancing-algorithmic-trading-systems-with-time-series-transformer-for-cryptocurrency-data/blob/main/prediction_service/drl_strategy.py"
    click PSPortfolio "https://github.com/andrzejmiskow/tradeai-advancing-algorithmic-trading-systems-with-time-series-transformer-for-cryptocurrency-data/blob/main/prediction_service/portfolio.py"
    click PSExec "https://github.com/andrzejmiskow/tradeai-advancing-algorithmic-trading-systems-with-time-series-transformer-for-cryptocurrency-data/blob/main/prediction_service/execution.py"
    click PSTestClient "https://github.com/andrzejmiskow/tradeai-advancing-algorithmic-trading-systems-with-time-series-transformer-for-cryptocurrency-data/blob/main/prediction_service/test_client.py"
    click TM1 "https://github.com/andrzejmiskow/tradeai-advancing-algorithmic-trading-systems-with-time-series-transformer-for-cryptocurrency-data/blob/main/prediction_service/transformers/ETSFormer_layers.py"
    click TM2 "https://github.com/andrzejmiskow/tradeai-advancing-algorithmic-trading-systems-with-time-series-transformer-for-cryptocurrency-data/blob/main/prediction_service/transformers/embeding.py"
    click TM3 "https://github.com/andrzejmiskow/tradeai-advancing-algorithmic-trading-systems-with-time-series-transformer-for-cryptocurrency-data/blob/main/prediction_service/transformers/model_layers.py"
    click TM4 "https://github.com/andrzejmiskow/tradeai-advancing-algorithmic-trading-systems-with-time-series-transformer-for-cryptocurrency-data/blob/main/prediction_service/transformers/models.py"
    click TM5 "https://github.com/andrzejmiskow/tradeai-advancing-algorithmic-trading-systems-with-time-series-transformer-for-cryptocurrency-data/blob/main/prediction_service/transformers/self_attention_layers.py"
    click TMSupport "https://github.com/andrzejmiskow/tradeai-advancing-algorithmic-trading-systems-with-time-series-transformer-for-cryptocurrency-data/blob/main/prediction_service/transformers_support/transformer_integration.py"
    click Ingest1 "https://github.com/andrzejmiskow/tradeai-advancing-algorithmic-trading-systems-with-time-series-transformer-for-cryptocurrency-data/blob/main/src/data/make_dataset.py"
    click Ingest2 "https://github.com/andrzejmiskow/tradeai-advancing-algorithmic-trading-systems-with-time-series-transformer-for-cryptocurrency-data/blob/main/src/data/transform_orderbook.py"
    click Ingest3 "https://github.com/andrzejmiskow/tradeai-advancing-algorithmic-trading-systems-with-time-series-transformer-for-cryptocurrency-data/blob/main/src/data/split_data.ipynb"
    click FE "https://github.com/andrzejmiskow/tradeai-advancing-algorithmic-trading-systems-with-time-series-transformer-for-cryptocurrency-data/blob/main/src/features/build_features.py"
    click Exp1 "https://github.com/andrzejmiskow/tradeai-advancing-algorithmic-trading-systems-with-time-series-transformer-for-cryptocurrency-data/blob/main/src/experiments/transformers/train_pred.py"
    click Exp2 "https://github.com/andrzejmiskow/tradeai-advancing-algorithmic-trading-systems-with-time-series-transformer-for-cryptocurrency-data/blob/main/src/experiments/transformers/transformer_integration.py"
    click MLFlow "https://github.com/andrzejmiskow/tradeai-advancing-algorithmic-trading-systems-with-time-series-transformer-for-cryptocurrency-data/blob/main/src/models/train_and_evaluate_mlflow_template.py"
    click OfflineTM1 "https://github.com/andrzejmiskow/tradeai-advancing-algorithmic-trading-systems-with-time-series-transformer-for-cryptocurrency-data/blob/main/src/models/transformers/embeding.py"
    click OfflineTM2 "https://github.com/andrzejmiskow/tradeai-advancing-algorithmic-trading-systems-with-time-series-transformer-for-cryptocurrency-data/blob/main/src/models/transformers/model_layers.py"
    click OfflineTM3 "https://github.com/andrzejmiskow/tradeai-advancing-algorithmic-trading-systems-with-time-series-transformer-for-cryptocurrency-data/blob/main/src/models/transformers/models.py"
    click OfflineTM4 "https://github.com/andrzejmiskow/tradeai-advancing-algorithmic-trading-systems-with-time-series-transformer-for-cryptocurrency-data/blob/main/src/models/transformers/self_attention_layers.py"
    click Viz1 "https://github.com/andrzejmiskow/tradeai-advancing-algorithmic-trading-systems-with-time-series-transformer-for-cryptocurrency-data/blob/main/src/visualization/visualize.py"
    click Viz2 "https://github.com/andrzejmiskow/tradeai-advancing-algorithmic-trading-systems-with-time-series-transformer-for-cryptocurrency-data/blob/main/src/visualization/view_lob_data.ipynb"
    click Dockerfile "https://github.com/andrzejmiskow/tradeai-advancing-algorithmic-trading-systems-with-time-series-transformer-for-cryptocurrency-data/tree/main/Dockerfile"
    click DockerCompose "https://github.com/andrzejmiskow/tradeai-advancing-algorithmic-trading-systems-with-time-series-transformer-for-cryptocurrency-data/blob/main/docker-compose.yml"
    click RunLocal "https://github.com/andrzejmiskow/tradeai-advancing-algorithmic-trading-systems-with-time-series-transformer-for-cryptocurrency-data/blob/main/run_locally.sh"
    click RunAzure "https://github.com/andrzejmiskow/tradeai-advancing-algorithmic-trading-systems-with-time-series-transformer-for-cryptocurrency-data/blob/main/run_in_azure.sh"

    %% Styles
    classDef service fill:#a0c4ff,stroke:#333,stroke-width:1px
    classDef ml fill:#bde0fe,stroke:#333,stroke-width:1px
    classDef data fill:#caffbf,stroke:#333,stroke-width:1px
    classDef pipeline fill:#fdffb6,stroke:#333,stroke-width:1px
    classDef external fill:#ffd6a5,stroke:#333,stroke-width:1px
```
