# sims1253/hrvester architecture

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

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

## Overview

##### Main System Components

a) Data Input Layer
- FIT file input handling
- Parallel processing capabilities (furrr)
- Demonstrate cache system interaction

b) Processing Core
- HRV Analysis Pipeline
- Neural Recovery Calculation
- Training Readiness Assessment

c) Output/Visualization Layer
- Dashboard Generation
- Reporting System
- Plot Generation

##### Specific Implementation Details

**[Data Input] -> [Processing Core] -> [Output Layer]**

Key elements to include:

Data Input Layer:
- FIT File Processor (process_fit_file.R)
- Cache System (cache.R)
- Input Validation (validate_inputs.R)

Processing Core (core.R):
- RR Interval Analysis
- HRV Calculations
- Heart Rate Recovery
- Neural Recovery Assessment
- Training Readiness Scoring

Analysis Layer (analysis.R):
- Moving Averages
- Trend Analysis
- Sport-Specific Metrics (BJJ)

Visualization Layer:
- Dashboard Generation
- Plot System
- Report Generation

##### Component Relationships

Use these connection types:
- Double lines for cache interactions

##### Technical Details

- R package dependencies
- Cache versioning system
- Multi-threading capabilities
- File format handling (FIT)

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Styles and classes
    classDef input fill:#a8d1f0,stroke:#333
    classDef processing fill:#90EE90,stroke:#333
    classDef analysis fill:#FFB347,stroke:#333
    classDef output fill:#DDA0DD,stroke:#333
    classDef cache fill:#B19CD9,stroke:#333
    classDef utility fill:#D3D3D3,stroke:#333

    %% Data Input Layer
    subgraph InputLayer["Data Input Layer"]
        FIT[FIT File Processor]:::input
        IV[Input Validation]:::input
    end
    click FIT "https://github.com/sims1253/hrvester/blob/master/R/core.R"
    click IV "https://github.com/sims1253/hrvester/blob/master/R/core.R"

    %% Cache System
    subgraph CacheSystem["Cache System"]
        CS[Cache Storage]:::cache
        CV[Cache Validation]:::cache
    end
    click CS "https://github.com/sims1253/hrvester/blob/master/R/cache.R"
    click CV "https://github.com/sims1253/hrvester/blob/master/R/cache.R"

    %% Processing Core
    subgraph ProcessingCore["Processing Core"]
        RR[RR Interval Analysis]:::processing
        HRV[HRV Calculations]:::processing
        HRR[Heart Rate Recovery]:::processing
        NR[Neural Recovery]:::processing
    end
    click RR "https://github.com/sims1253/hrvester/blob/master/R/core.R"
    click HRV "https://github.com/sims1253/hrvester/blob/master/R/core.R"
    click HRR "https://github.com/sims1253/hrvester/blob/master/R/core.R"
    click NR "https://github.com/sims1253/hrvester/blob/master/R/core.R"

    %% Analysis Layer
    subgraph AnalysisLayer["Analysis Layer"]
        MA[Moving Averages]:::analysis
        TA[Trend Analysis]:::analysis
        TR[Training Readiness]:::analysis
        BJJ[BJJ Metrics]:::analysis
    end
    click MA "https://github.com/sims1253/hrvester/blob/master/R/analysis.R"
    click TA "https://github.com/sims1253/hrvester/blob/master/R/analysis.R"
    click TR "https://github.com/sims1253/hrvester/blob/master/R/analysis.R"
    click BJJ "https://github.com/sims1253/hrvester/blob/master/R/plot.R"

    %% Output Layer
    subgraph OutputLayer["Output Layer"]
        DG[Dashboard Generation]:::output
        PS[Plot System]:::output
        RG[Report Generation]:::output
        TV[Trend Visualization]:::output
    end
    click DG "https://github.com/sims1253/hrvester/blob/master/R/dashboard.R"
    click PS "https://github.com/sims1253/hrvester/blob/master/R/plot.R"
    click RG "https://github.com/sims1253/hrvester/blob/master/R/core.R"
    click TV "https://github.com/sims1253/hrvester/blob/master/R/plot.R"

    %% Utility
    subgraph UtilityLayer["Utility Layer"]
        SFO[Safe File Operations]:::utility
    end
    click SFO "https://github.com/sims1253/hrvester/blob/master/R/core.R"

    %% Connections
    FIT --> IV
    IV --> RR
    RR --> HRV
    HRV --> HRR
    HRR --> NR
    NR --> MA
    MA --> TA
    TA --> TR
    TR --> BJJ
    
    MA --> DG
    TA --> PS
    TR --> RG
    BJJ --> TV

    %% Cache Interactions
    CS -.-> FIT
    CS -.-> HRV
    CS -.-> MA
    CV -.-> CS

    %% Safe File Operations
    SFO -.-> FIT
    SFO -.-> RG

    %% Legend
    subgraph Legend
        L1[Data Input]:::input
        L2[Processing]:::processing
        L3[Analysis]:::analysis
        L4[Output]:::output
        L5[Cache]:::cache
        L6[Utility]:::utility
    end
```
