# owoeye-babatunde/robotrade architecture

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

- Interactive diagram: https://gitdiagram.com/owoeye-babatunde/robotrade
- Repository: https://github.com/owoeye-babatunde/robotrade

## Overview

##### Main Components
- Front/Client Side (if applicable): Although not explicitly a “frontend”, the inference pipeline provides a websocket-based API which acts as the consumer interface.
- Data Ingestion & Trade Streaming: The “trades” service connects to external data sources (e.g., Kraken Websocket API) for real-time trade data.
- Data Transformation & Feature Engineering: Services like “candles” (for converting trade streams to OHLCV data) and “technical-indicators” (for computing indicators with Ta-Lib) process the raw trade data.
- News & Signal Processing: The “news” and “news-signal” services fetch, preprocess, and transform news data – integrating NLP processing – to generate trade signals.
- Feature Store Integration: The “to-feature-store” service pushes engineered features from traded data and news signals into the Feature Store.
- Machine Learning & Prediction:
- “price-predictor” is responsible for model training and prediction based on the feature store data.
- “prediction-api”, developed in Rust, offers a high-performance API endpoint for serving predictions (likely via websockets).
- Supporting Infrastructure: Docker, Docker Compose, and automated CI/CD workflows (GitHub Actions, pre-commit hooks, Ruff configuration) are part of the overall delivery pipeline.

##### Representing Interactions and Data Flows
- That both the training pipeline and the inference pipeline are downstream consumers of these features.
- Relationship from the “price-predictor” to “prediction-api” where the trained model is deployed, and the prediction API serves real-time prediction requests.

##### Architectural Patterns and Design Principles
- Microservices approach by isolating each major function (trades, candles, technical-indicators, news, news-signal, to-feature-store, price-predictor, prediction-api) in separate service containers.
- Usage of stateful stream processing and containerization to ensure scalability and robust deployment.
- That critical high-performance components may use Rust, while most services are implemented in Python.
- Point out integration with Kafka/Redpanda as the backbone for real-time data streaming.

##### Incorporate Specific Technologies
- Integration with tools such as Quix Streams for stateful processing and feature store management.
- Mention deployment orchestration via Docker Compose and the configuration management (environment settings and Dockerfiles).

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% External Sources
    subgraph "External Sources"
        Kraken["Kraken Websocket (External)"]:::external
        NewsFeed["News Feed (External)"]:::external
    end

    %% Data Ingestion Layer
    subgraph "Data Ingestion"
        TradesService["Trades Service (Kraken API)"]:::ingestion
    end

    %% Data Transformation & Feature Engineering Layer
    subgraph "Data Transformation"
        CandlesService["Candles Service – OHLCV conversion"]:::transformation
        TechIndicatorsService["Technical Indicators Service – Ta-Lib"]:::transformation
        NewsService["News Processing Service"]:::transformation
        NewsSignalService["News Signal Engine"]:::transformation
        FeatureStoreService["Feature Store Integration"]:::transformation
    end

    %% Machine Learning & Prediction Layer
    subgraph "ML Pipeline"
        PricePredictor["Price Predictor (Model Training & Inference)"]:::ml
    end

    %% API Serving Layer
    subgraph "API Serving"
        PredictionAPI["Prediction API (Rust)"]:::api
    end

    %% Infrastructure & CI/CD
    subgraph "Infrastructure"
        DockerCompose["Docker Compose"]:::infra
        CICDPipelines["CI/CD Pipelines"]:::infra
    end

    %% Monitoring & Logging
    Monitoring["Monitoring & Logging"]:::monitoring

    %% Data Flow Connections
    Kraken -->|"feeds"| TradesService
    NewsFeed -->|"feeds"| NewsService

    TradesService -->|"sends data"| CandlesService
    TradesService -->|"sends data"| TechIndicatorsService

    CandlesService -->|"outputs OHLCV"| FeatureStoreService
    TechIndicatorsService -->|"outputs indicators"| FeatureStoreService

    NewsService -->|"processes news"| NewsSignalService
    NewsSignalService -->|"generates signals"| FeatureStoreService

    FeatureStoreService -->|"provides features"| PricePredictor
    PricePredictor -->|"deploys model"| PredictionAPI

    PricePredictor -->|"logs performance"| Monitoring
    PredictionAPI -->|"reports metrics"| Monitoring

    %% Infrastructure Deployment Connections (dashed)
    DockerCompose -.->|"deploys"| TradesService
    CICDPipelines -.->|"deploys"| PricePredictor

    %% Styling definitions
    classDef ingestion fill:#f9d9a9,stroke:#333,stroke-width:2px;
    classDef transformation fill:#fdeac8,stroke:#333,stroke-width:2px;
    classDef ml fill:#cfe2f3,stroke:#333,stroke-width:2px;
    classDef api fill:#d9ead3,stroke:#333,stroke-width:2px;
    classDef infra fill:#ead1dc,stroke:#333,stroke-width:2px;
    classDef external fill:#fff2cc,stroke:#333,stroke-width:2px;
    classDef monitoring fill:#d0e0e3,stroke:#333,stroke-width:2px;

    %% Click Events
    click TradesService "https://github.com/owoeye-babatunde/robotrade/tree/main/services/trades"
    click CandlesService "https://github.com/owoeye-babatunde/robotrade/tree/main/services/candles"
    click TechIndicatorsService "https://github.com/owoeye-babatunde/robotrade/tree/main/services/technical-indicators"
    click NewsService "https://github.com/owoeye-babatunde/robotrade/tree/main/services/news"
    click NewsSignalService "https://github.com/owoeye-babatunde/robotrade/tree/main/services/news-signal"
    click FeatureStoreService "https://github.com/owoeye-babatunde/robotrade/tree/main/services/to-feature-store"
    click PricePredictor "https://github.com/owoeye-babatunde/robotrade/tree/main/services/price-predictor"
    click PredictionAPI "https://github.com/owoeye-babatunde/robotrade/tree/main/services/prediction-api"
    click DockerCompose "https://github.com/owoeye-babatunde/robotrade/tree/main/docker-compose"
    click CICDPipelines "https://github.com/owoeye-babatunde/robotrade/tree/main/.github/workflows"
```
