# sims1253/ost_dashboard architecture

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

- Interactive diagram: https://gitdiagram.com/sims1253/ost_dashboard
- Repository: https://github.com/sims1253/ost_dashboard

## Overview

##### Main Components

a. Data Input Layer:
- FIT File Reader Component
- Directory Scanner Component
- Support for both single file and directory processing

b. Core Processing Layer:
- RR Interval Extractor
- HRV Calculator
- Caching System (indicated by cache.R)
- Heart Rate Processing Module

c. Visualization Layer:
- HRV Plot Generator
- Trend Plot Generator
- Plot Composition System (patchwork integration)

##### Component Relationships

**[Input Layer] → [Processing Layer] → [Visualization Layer]**

##### Specific Implementation Details

- Rectangles for core processing modules
- Parallelograms for input/output operations
- Rounded rectangles for visualization components

Following flows:
**FIT Files → Directory Scanner → Cache System**
- → RR Interval Extractor
- → HRV Calculator
- → Plot Generators

##### Technical Details

Annotations showing:
- R package dependencies
- File format specifications (FIT)
- Cache mechanism
- Plot types (HRV plot, trend plot)

##### Key Features to Highlight

- Caching mechanism for performance optimization
- Support for both single file and batch processing
- Dual visualization capabilities (individual and trend analysis)
- Integration with patchwork for plot composition

##### The flexibility in handling both single files and directories

Remember to maintain R-specific conventions and show how the package integrates with the broader R ecosystem, particularly for visualization components.

## Diagram (Mermaid)

```mermaid
graph TB
    %% Define styles
    classDef input fill:#a8d1f0,stroke:#333
    classDef process fill:#90EE90,stroke:#333
    classDef cache fill:#FFB347,stroke:#333
    classDef viz fill:#DDA0DD,stroke:#333
    classDef api fill:#F0E68C,stroke:#333

    %% Input Layer
    subgraph Input
        FIT[FIT File Reader]
        DIR[Directory Scanner]
    end

    %% Processing Layer
    subgraph Processing
        RR[RR Interval Extractor]
        HRV[HRV Calculator]
        HR[Heart Rate Processing]
        CACHE[(Caching System)]
    end

    %% Visualization Layer
    subgraph Visualization
        HRVPLOT[HRV Plot Generator]
        TRENDPLOT[Trend Plot Generator]
        PATCH[Plot Composition]
    end

    %% Connections
    FIT --> RR
    DIR --> RR
    RR --> CACHE
    RR --> HRV
    HRV --> HR
    CACHE --> HRV
    HRV --> HRVPLOT
    HRV --> TRENDPLOT
    HRVPLOT --> PATCH
    TRENDPLOT --> PATCH

    %% Click events
    click FIT "https://github.com/sims1253/ost_dashboard/blob/master/R/core.R"
    click DIR "https://github.com/sims1253/ost_dashboard/blob/master/R/core.R"
    click RR "https://github.com/sims1253/ost_dashboard/blob/master/R/core.R"
    click HRV "https://github.com/sims1253/ost_dashboard/blob/master/R/core.R"
    click HR "https://github.com/sims1253/ost_dashboard/blob/master/R/core.R"
    click CACHE "https://github.com/sims1253/ost_dashboard/blob/master/R/cache.R"
    click HRVPLOT "https://github.com/sims1253/ost_dashboard/blob/master/R/plot.R"
    click TRENDPLOT "https://github.com/sims1253/ost_dashboard/blob/master/R/plot.R"

    %% Style applications
    class FIT,DIR input
    class RR,HRV,HR process
    class CACHE cache
    class HRVPLOT,TRENDPLOT,PATCH viz

    %% Legend
    subgraph Legend
        L1[Input Components]:::input
        L2[Processing Components]:::process
        L3[(Storage Components)]:::cache
        L4[Visualization Components]:::viz
    end
```
