# operativef/oscar architecture

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

- Interactive diagram: https://gitdiagram.com/operativef/oscar
- Repository: https://github.com/operativef/oscar

## Overview

##### Main Components

a. Core Application Layer:
- Main application (oscar/main.cpp, mainwindow.cpp)
- User Interface components (*.ui files)
- Profile management (oscar/profileselect.cpp, profiles.cpp)

b. Data Processing Layer (SleepLib):
- Machine data loaders (oscar/SleepLib/loader_plugins/*)
- Data models (day.cpp, session.cpp, event.cpp)
- Calculations engine (calcs.cpp)

c. Visualization Layer:
- Graph components (oscar/Graphs/*)
- Statistics generation (statistics.cpp)
- Report generation (reports.cpp)

d. Support Systems:
- Translation system (Translations/*)
- Help system (help/*)
- Update mechanism (UpdaterWindow.cpp)

**[User Interface Layer]**

- Main Window
- Daily View
- Overview
- Statistics
- Reports

**[Data Processing Layer]**

- Machine Loaders
- PRS1 Loader
- ResMed Loader
- Other Device Loaders

- Data Models
- Profile
- Session
- Events

- Calculations Engine

**[Visualization Layer]**

- Graph Engine
- Line Charts
- Summary Charts
- Session Charts

- Report Generator

**[Support Systems]**

- Translation System
- Help System
- Update Manager

##### Data Flow Indicators

Following interactions:
- User input → UI Layer
- UI Layer → Data Processing Layer
- Data Processing → Visualization Layer
- Support Systems ↔ All Layers

##### Technical Details

- Qt5 dependency
- OpenGL usage for graphics
- Serial port communication for device data
- Multi-language support architecture
- Help system integration

## Diagram (Mermaid)

```mermaid
graph TB
    %% Styles and classes
    classDef ui fill:#3498db,stroke:#2980b9,color:white
    classDef data fill:#2ecc71,stroke:#27ae60,color:white
    classDef viz fill:#e67e22,stroke:#d35400,color:white
    classDef support fill:#95a5a6,stroke:#7f8c8d,color:white
    classDef plugin fill:#9b59b6,stroke:#8e44ad,color:white

    %% Main Application Layer
    subgraph MainApp
        Main["Main Entry Point"]:::ui
        MainWindow["Main Window"]:::ui
        ProfileMgmt["Profile Management"]:::ui
    end

    %% User Interface Layer
    subgraph UILayer
        DailyView["Daily View"]:::ui
        Overview["Overview"]:::ui
        Stats["Statistics View"]:::ui
        Prefs["Preferences"]:::ui
        Welcome["Welcome Screen"]:::ui
    end

    %% Data Processing Layer
    subgraph DataLayer
        subgraph Loaders
            PRS1["PRS1 Loader"]:::plugin
            ResMed["ResMed Loader"]:::plugin
            OtherLoaders["Other Device Loaders"]:::plugin
        end

        subgraph Models
            Profile["Profile Model"]:::data
            Session["Session Model"]:::data
            Events["Events Model"]:::data
        end

        CalcEngine["Calculations Engine"]:::data
    end

    %% Visualization Layer
    subgraph VizLayer
        GraphEngine["Graph Engine"]:::viz
        StatsEngine["Statistics Engine"]:::viz
        ReportGen["Report Generator"]:::viz
    end

    %% Support Systems
    subgraph SupportSys
        Translation["Translation System"]:::support
        Help["Help System"]:::support
        Updater["Update Manager"]:::support
    end

    %% Relationships
    Main --> MainWindow
    MainWindow --> ProfileMgmt
    MainWindow --> DailyView
    MainWindow --> Overview
    MainWindow --> Stats
    MainWindow --> Prefs
    MainWindow --> Welcome

    ProfileMgmt --> Profile
    DailyView --> Session
    Session --> Events
    
    Loaders --> Models
    Models --> CalcEngine
    CalcEngine --> GraphEngine
    CalcEngine --> StatsEngine
    StatsEngine --> ReportGen

    Translation --> MainWindow
    Help --> MainWindow
    Updater --> MainWindow

    %% Click events for component mapping
    click Main "https://github.com/operativeF/oscar/blob/operativef_personal/oscar/main.cpp"
    click MainWindow "https://github.com/operativeF/oscar/blob/operativef_personal/oscar/mainwindow.cpp"
    click ProfileMgmt "https://github.com/operativeF/oscar/blob/operativef_personal/oscar/SleepLib/profiles.cpp"
    click DailyView "https://github.com/operativeF/oscar/blob/operativef_personal/oscar/daily.cpp"
    click Overview "https://github.com/operativeF/oscar/blob/operativef_personal/oscar/overview.cpp"
    click Prefs "https://github.com/operativeF/oscar/blob/operativef_personal/oscar/preferencesdialog.cpp"
    click Welcome "https://github.com/operativeF/oscar/blob/operativef_personal/oscar/welcome.cpp"
    click PRS1 "https://github.com/operativeF/oscar/blob/operativef_personal/oscar/SleepLib/loader_plugins/prs1_loader.cpp"
    click ResMed "https://github.com/operativeF/oscar/blob/operativef_personal/oscar/SleepLib/loader_plugins/resmed_loader.cpp"
    click OtherLoaders "https://github.com/operativeF/oscar/tree/operativef_personal/oscar/SleepLib/loader_plugins"
    click Session "https://github.com/operativeF/oscar/blob/operativef_personal/oscar/SleepLib/session.cpp"
    click Events "https://github.com/operativeF/oscar/blob/operativef_personal/oscar/SleepLib/event.cpp"
    click CalcEngine "https://github.com/operativeF/oscar/blob/operativef_personal/oscar/SleepLib/calcs.cpp"
    click GraphEngine "https://github.com/operativeF/oscar/tree/operativef_personal/oscar/Graphs"
    click StatsEngine "https://github.com/operativeF/oscar/blob/operativef_personal/oscar/statistics.cpp"
    click ReportGen "https://github.com/operativeF/oscar/blob/operativef_personal/oscar/reports.cpp"
    click Translation "https://github.com/operativeF/oscar/tree/operativef_personal/Translations"
    click Help "https://github.com/operativeF/oscar/tree/operativef_personal/oscar/help"
    click Updater "https://github.com/operativeF/oscar/blob/operativef_personal/oscar/UpdaterWindow.cpp"

    %% Legend
    subgraph Legend
        UI["UI Component"]:::ui
        DataComp["Data Component"]:::data
        VizComp["Visualization Component"]:::viz
        SupportComp["Support Component"]:::support
        PluginComp["Plugin Component"]:::plugin
    end
```
