# cagnulein/qdomyos-zwift architecture

> Architecture diagram of the GitHub repository cagnulein/qdomyos-zwift, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2024-12-27). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/cagnulein/qdomyos-zwift
- Repository: https://github.com/cagnulein/qdomyos-zwift

## Overview

##### Main Components

a. Core Application Layer:
- Qt-based cross-platform application (iOS, Android, macOS, Linux)
- Main UI components (QML-based interface)
- Settings and configuration management
- Profile management system

b. Device Integration Layer:
- Bluetooth Low Energy (BLE) communication module
- ANT+ protocol support
- Device discovery and management
- Virtual device implementations
- Device-specific adapters for different equipment types:
- Treadmills
- Bikes
- Ellipticals
- Rowers

c. Protocol Translation Layer:
- FTMS (Fitness Machine Service) protocol handling
- Heart rate monitoring
- Power/Speed/Cadence data conversion
- Resistance/Incline control

d. External Service Integration:
- Zwift integration
- Wahoo integration
- Strava upload capability
- Video streaming support
- GPX/workout file processing

e. Data Management:
- Workout data collection
- Statistics generation
- Email reporting system
- Training program management

##### Connection Flow Representation

- Data flow between physical devices and the application
- Communication between the app and fitness platforms
- User interaction paths
- Workout data synchronization

##### Specific Implementation Details

Technical details such as:
- Qt 5.15.2 framework usage
- BLE/ANT+ protocol implementation
- WebSocket API for external communication
- MQTT support for data publishing
- HTTP server functionality

## Diagram (Mermaid)

```mermaid
graph TB
    subgraph UI
        MainUI["Main UI (QML)"]:::ui
        Settings["Settings Interface"]:::ui
        Profiles["Profile Management"]:::ui
        VideoUI["Video Playback"]:::ui
    end

    subgraph Core
        MainApp["Main Application"]:::core
        SettingsManager["Settings Manager"]:::core
        ProfileManager["Profile Manager"]:::core
        DataManager["Data Manager"]:::core
    end

    subgraph DeviceLayer["Device Integration"]
        BLE["BLE Communication"]:::device
        ANT["ANT+ Protocol"]:::device
        DeviceDiscovery["Device Discovery"]:::device
        
        subgraph DeviceTypes
            Bike["Bike Devices"]:::device
            Treadmill["Treadmill Devices"]:::device
            Rower["Rower Devices"]:::device
            Elliptical["Elliptical Devices"]:::device
        end
    end

    subgraph ProtocolLayer["Protocol Translation"]
        FTMS["FTMS Protocol"]:::protocol
        HeartRate["Heart Rate Monitor"]:::protocol
        PowerData["Power/Speed/Cadence"]:::protocol
        ResistanceControl["Resistance Control"]:::protocol
    end

    subgraph ExternalServices
        Zwift["Zwift Integration"]:::external
        Wahoo["Wahoo Integration"]:::external
        Strava["Strava Upload"]:::external
        VideoStream["Video Streaming"]:::external
    end

    subgraph DataManagement
        WorkoutData["Workout Collection"]:::data
        Stats["Statistics"]:::data
        Email["Email Reporting"]:::data
        Training["Training Programs"]:::data
    end

    %% Connections
    MainUI --> MainApp
    Settings --> SettingsManager
    Profiles --> ProfileManager
    MainApp --> DeviceLayer
    MainApp --> ProtocolLayer
    DeviceLayer --> ProtocolLayer
    ProtocolLayer --> ExternalServices
    MainApp --> DataManagement
    VideoUI --> VideoStream

    %% Click Events
    click MainUI "https://github.com/cagnulein/qdomyos-zwift/blob/master/src/main.qml"
    click MainApp "https://github.com/cagnulein/qdomyos-zwift/blob/master/src/main.cpp"
    click SettingsManager "https://github.com/cagnulein/qdomyos-zwift/blob/master/src/qzsettings.cpp"
    click Profiles "https://github.com/cagnulein/qdomyos-zwift/blob/master/src/profiles.qml"
    click BLE "https://github.com/cagnulein/qdomyos-zwift/blob/master/src/devices/bluetooth.cpp"
    click DeviceDiscovery "https://github.com/cagnulein/qdomyos-zwift/blob/master/src/devices/discoveryoptions.h"
    click Bike "https://github.com/cagnulein/qdomyos-zwift/blob/master/src/devices/bike.h"
    click Treadmill "https://github.com/cagnulein/qdomyos-zwift/blob/master/src/devices/treadmill.h"
    click Rower "https://github.com/cagnulein/qdomyos-zwift/blob/master/src/devices/rower.h"
    click Elliptical "https://github.com/cagnulein/qdomyos-zwift/blob/master/src/devices/elliptical.h"
    click FTMS "https://github.com/cagnulein/qdomyos-zwift/blob/master/src/devices/ftmsbike/ftmsbike.cpp"
    click HeartRate "https://github.com/cagnulein/qdomyos-zwift/blob/master/src/devices/heartratebelt/heartratebelt.cpp"
    click Zwift "https://github.com/cagnulein/qdomyos-zwift/tree/master/src/zwift-api"
    click VideoStream "https://github.com/cagnulein/qdomyos-zwift/blob/master/src/videoPlayback.qml"
    click Training "https://github.com/cagnulein/qdomyos-zwift/blob/master/src/trainprogram.cpp"
    click WorkoutData "https://github.com/cagnulein/qdomyos-zwift/blob/master/src/charts.cpp"

    %% Styles
    classDef ui fill:#9370DB,stroke:#333,stroke-width:2px
    classDef core fill:#4169E1,stroke:#333,stroke-width:2px
    classDef device fill:#3CB371,stroke:#333,stroke-width:2px
    classDef protocol fill:#FFD700,stroke:#333,stroke-width:2px
    classDef external fill:#FFA500,stroke:#333,stroke-width:2px
    classDef data fill:#20B2AA,stroke:#333,stroke-width:2px

    %% Legend
    subgraph Legend
        UI_L["UI Components"]:::ui
        Core_L["Core Components"]:::core
        Device_L["Device Components"]:::device
        Protocol_L["Protocol Components"]:::protocol
        External_L["External Services"]:::external
        Data_L["Data Management"]:::data
    end
```
