# veeamhub/veeam-healthcheck architecture

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

- Interactive diagram: https://gitdiagram.com/veeamhub/veeam-healthcheck
- Repository: https://github.com/veeamhub/veeam-healthcheck

## Overview

##### Project type and purpose
- Type: A monolithic .NET desktop utility (C# + XAML GUI + CLI)
- Purpose: Run locally on a Veeam Backup & Replication or Veeam Backup for Microsoft 365 server, collect configuration and performance data, analyze it, and generate an HTML-based health-check report (plus CSV artifacts).

##### File structure
- Top-level solution (vHC/HC.sln) contains:
– HC_Reporting project: the main application
· Startup (orchestration): EntryPoint.cs, argument parsing, admin/hotfix checks, mode selection
· Functions:
· Collection: PS script invoker, registry reader, SQL executor, log parser, impersonation
· Analysis: data-model objects and algorithmic calculations
· Reporting: CSV handlers, data-type parsers, HTML exporter (uses ReportScript.js, css.css)
· Common utilities: logging, XML scrubber, global constants
· Resources & Localization: .resx files, PS scripts to build resource files
· Tools & Build scripts: PowerShell/Batch/shell scripts for collecting data and building localization
· GUI (VhcGui.xaml + code-behind)
– VhcXTests project: xUnit/MSTest-style unit tests covering argument parsing, reporting, CSV parsing, HTML exporting, logging
- CI/CD: GitHub workflows for static analysis (Semgrep, CodeQL) and virus scanning

- Presentation Layer
– EntryPoint (CLI) and XAML GUI
- Orchestration Layer
– Startup services: Admin check, hotfix detector, argument parser, mode selector, client functions
- Data Collection Services
– PowerShell invoker (PSCollections)
– Registry/DB accessor
– Log parser
- Analysis Services
– DataModels (Analysis/DataModels)
– Business logic for job session statistics, concurrency, success rates
- Reporting Services
– CSV handlers (Functions/Reporting/CsvHandlers)
– DataType parsers (Functions/Reporting/DataTypes)
– HTML exporter (Functions/Reporting/Html)
- Infrastructure & Utilities
– Logging (Common/Logging)
– Scrubber (Common/Scrubber)
– Global constants (Common/CGlobals)
– Localization resources
- Outputs
– HTML report
– CSV files
– Sample HTML (SAMPLE folder)
- External dependencies
– Veeam Backup & Replication / VB365 installation (local DB, registry, logs)
– PowerShell runtime
– File system (C:\temp\vHC)

##### Relationships and data flow
1. User invokes EntryPoint (CLI args or GUI click).
2. Startup orchestrator validates environment (admin, hotfix), parses options.
3. Orchestrator calls Collection services in parallel or sequence:
– PS scripts to collect data (VB365/VBR)
– Registry reader & SQL queries to the Veeam database
– Log file parser
4. Raw data fed into Analysis services:
– Build in-memory data models
– Perform calculations (durations, concurrency heat maps, success rates)
5. Analysis results passed to Reporting services:
– Generate CSVs via CsvHandlers
– Transform data into HTML via HtmlExporter (templating, CSS, ReportScript.js)
6. Outputs written to disk under C:\temp\vHC
7. Unit tests validate each component in VhcXTests

##### Architectural patterns & design principles
- Layered architecture (Presentation → Orchestration → Services → Infrastructure)
- Single responsibility: each namespace folder holds a service type
- Modular extension via PS scripts and localization resources
- Dependency inversion for logging and CSV reader interfaces
- Parallel or sequential task execution orchestrated from Startup

##### Essential elements
- Clear component names & package paths
– Project modules (Common, Collection, Analysis, Reporting, Startup)
– Infrastructure (Logging, Scrubber)
– External systems and outputs

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Presentation Layer
    subgraph "Presentation Layer"
        direction TB
        EntryPoint["EntryPoint (CLI)"]:::presentation
        GUI["VhcGui.xaml"]:::presentation
        GUIcode["VhcGui.xaml.cs"]:::presentation
    end

    %% Orchestration Layer
    subgraph "Orchestration Layer"
        direction TB
        AdminCheck["CAdminCheck"]:::orchestration
        HotfixDetector["CHotfixDetector"]:::orchestration
        ArgsParser["CArgsParser"]:::orchestration
        ModeSelector["CReportModeSelector"]:::orchestration
        ClientFunctions["CClientFunctions"]:::orchestration
    end

    %% Data Collection Services
    subgraph "Data Collection Services"
        direction TB
        Impersonation["CImpersonation"]:::collection
        DBAccessor["CDbAccessor"]:::collection
        RegReader["CRegReader"]:::collection
        SqlExecutor["CSqlExecutor"]:::collection
        Queries["CQueries"]:::collection
        LogParser["CLogParser"]:::collection
        PSInvoker["PSInvoker"]:::collection
        Scripts["CScripts"]:::collection
        ScriptFile["Collect-VB365Data.ps1"]:::collection
    end

    %% Analysis Services
    subgraph "Analysis Services"
        direction TB
        DataModels["DataModels"]:::analysis
    end

    %% Reporting Services
    subgraph "Reporting Services"
        direction TB
        CsvHandlers["CsvHandlers"]:::reporting
        DataTypesParser["CDataTypesParser"]:::reporting
        HtmlExporter["CHtmlExporter"]:::reporting
        ReportScript["ReportScript.js"]:::reporting
        CssStyle["css.css"]:::reporting
    end

    %% Infrastructure & Utilities
    subgraph "Infrastructure & Utilities"
        direction TB
        Logger["CLogger"]:::infrastructure
        Scrubber["CXmlHandler"]:::infrastructure
        Globals["CGlobals"]:::infrastructure
        Localization["Resources/Localization"]:::infrastructure
        Tools["Tools"]:::infrastructure
    end

    %% External Dependencies
    subgraph "External Dependencies"
        direction TB
        VeeamDB[(Veeam DB)]:::external
        Registry[(Registry)]:::external
        PSRuntime[(PowerShell Runtime)]:::external
        FileSystem[(File System)]:::external
    end

    %% Outputs
    subgraph "Outputs"
        direction TB
        HTMLReport[(HTML Report)]:::output
        CSVOutput[(CSV Files)]:::output
        SampleHTML[(Sample HTML)]:::output
    end

    %% Unit Tests
    subgraph "Unit Tests"
        direction TB
        Tests["VhcXTests"]:::test
    end

    %% Connections - Invocation Flow
    EntryPoint -->|invokes| AdminCheck
    EntryPoint -->|invokes| HotfixDetector
    EntryPoint -->|invokes| ArgsParser
    EntryPoint -->|invokes| ModeSelector
    EntryPoint -->|invokes| ClientFunctions
    GUIcode -->|invokes| AdminCheck

    %% Collection Flow
    ClientFunctions -->|calls| Impersonation
    ClientFunctions -->|calls| DBAccessor
    DBAccessor --> RegReader
    DBAccessor --> SqlExecutor
    DBAccessor --> Queries
    ClientFunctions -->|calls| LogParser
    ClientFunctions -->|calls| PSInvoker
    PSInvoker --> Scripts
    Scripts --> ScriptFile

    %% External integrations
    DBAccessor -->|reads/writes| VeeamDB
    RegReader -->|reads| Registry
    PSInvoker -->|executes| PSRuntime
    LogParser -->|reads| FileSystem
    ScriptFile -->|collects data| FileSystem

    %% Analysis Flow
    Impersonation --> DataModels
    RegReader --> DataModels
    SqlExecutor --> DataModels
    Queries --> DataModels
    LogParser --> DataModels
    ScriptFile --> DataModels

    %% Reporting Flow
    DataModels --> CsvHandlers
    DataModels --> DataTypesParser
    DataModels --> HtmlExporter
    HtmlExporter --> ReportScript
    HtmlExporter --> CssStyle

    %% Outputs Writing
    CsvHandlers --> CSVOutput
    DataTypesParser --> CSVOutput
    HtmlExporter --> HTMLReport
    SampleHTML --> FileSystem

    %% Utilities usage
    AdminCheck --> Logger
    HotfixDetector --> Logger
    ArgsParser --> Logger
    ModeSelector --> Logger
    ClientFunctions --> Logger
    CsvHandlers --> Logger
    HtmlExporter --> Logger
    Scrubber --> HtmlExporter
    Globals --> all
    Localization --> CsvHandlers
    Tools --> Scripts

    %% Unit Tests
    Tests --> EntryPoint
    Tests --> CsvHandlers
    Tests --> HtmlExporter
    Tests --> Logger

    %% Click Events
    click EntryPoint "https://github.com/veeamhub/veeam-healthcheck/blob/master/vHC/HC_Reporting/Startup/EntryPoint.cs"
    click GUI "https://github.com/veeamhub/veeam-healthcheck/blob/master/vHC/HC_Reporting/VhcGui.xaml"
    click GUIcode "https://github.com/veeamhub/veeam-healthcheck/blob/master/vHC/HC_Reporting/VhcGui.xaml.cs"
    click AdminCheck "https://github.com/veeamhub/veeam-healthcheck/blob/master/vHC/HC_Reporting/Startup/CAdminCheck.cs"
    click HotfixDetector "https://github.com/veeamhub/veeam-healthcheck/blob/master/vHC/HC_Reporting/Startup/CHotfixDetector.cs"
    click ArgsParser "https://github.com/veeamhub/veeam-healthcheck/blob/master/vHC/HC_Reporting/Startup/CArgsParser.cs"
    click ModeSelector "https://github.com/veeamhub/veeam-healthcheck/blob/master/vHC/HC_Reporting/Startup/CReportModeSelector.cs"
    click ClientFunctions "https://github.com/veeamhub/veeam-healthcheck/blob/master/vHC/HC_Reporting/Startup/CClientFunctions.cs"
    click Impersonation "https://github.com/veeamhub/veeam-healthcheck/blob/master/vHC/HC_Reporting/Functions/Collection/CImpersonation.cs"
    click RegReader "https://github.com/veeamhub/veeam-healthcheck/blob/master/vHC/HC_Reporting/Functions/Collection/DB/CRegReader.cs"
    click SqlExecutor "https://github.com/veeamhub/veeam-healthcheck/blob/master/vHC/HC_Reporting/Functions/Collection/DB/CSqlExecutor.cs"
    click DBAccessor "https://github.com/veeamhub/veeam-healthcheck/blob/master/vHC/HC_Reporting/Functions/Collection/DB/CDbAccessor.cs"
    click Queries "https://github.com/veeamhub/veeam-healthcheck/blob/master/vHC/HC_Reporting/Functions/Collection/DB/CQueries.cs"
    click LogParser "https://github.com/veeamhub/veeam-healthcheck/blob/master/vHC/HC_Reporting/Functions/Collection/LogParser/CLogParser.cs"
    click PSInvoker "https://github.com/veeamhub/veeam-healthcheck/blob/master/vHC/HC_Reporting/Functions/Collection/PSCollections/PSInvoker.cs"
    click Scripts "https://github.com/veeamhub/veeam-healthcheck/blob/master/vHC/HC_Reporting/Functions/Collection/PSCollections/CScripts.cs"
    click ScriptFile "https://github.com/veeamhub/veeam-healthcheck/blob/master/vHC/HC_Reporting/Functions/Collection/PSCollections/Scripts/Collect-VB365Data.ps1"
    click DataModels "https://github.com/veeamhub/veeam-healthcheck/tree/master/vHC/HC_Reporting/Functions/Analysis/DataModels"
    click CsvHandlers "https://github.com/veeamhub/veeam-healthcheck/tree/master/vHC/HC_Reporting/Functions/Reporting/CsvHandlers"
    click DataTypesParser "https://github.com/veeamhub/veeam-healthcheck/blob/master/vHC/HC_Reporting/Functions/Reporting/DataTypes/CDataTypesParser.cs"
    click HtmlExporter "https://github.com/veeamhub/veeam-healthcheck/blob/master/vHC/HC_Reporting/Functions/Reporting/Html/CHtmlExporter.cs"
    click ReportScript "https://github.com/veeamhub/veeam-healthcheck/blob/master/vHC/HC_Reporting/ReportScript.js"
    click CssStyle "https://github.com/veeamhub/veeam-healthcheck/blob/master/vHC/HC_Reporting/css.css"
    click Logger "https://github.com/veeamhub/veeam-healthcheck/blob/master/vHC/HC_Reporting/Common/Logging/CLogger.cs"
    click Scrubber "https://github.com/veeamhub/veeam-healthcheck/blob/master/vHC/HC_Reporting/Common/Scrubber/CXmlHandler.cs"
    click Globals "https://github.com/veeamhub/veeam-healthcheck/blob/master/vHC/HC_Reporting/Common/CGlobals.cs"
    click Localization "https://github.com/veeamhub/veeam-healthcheck/tree/master/vHC/HC_Reporting/Resources/Localization"
    click Tools "https://github.com/veeamhub/veeam-healthcheck/tree/master/vHC/HC_Reporting/Tools"
    click Tests "https://github.com/veeamhub/veeam-healthcheck/tree/master/vHC/VhcXTests/"

    %% Styles
    classDef presentation fill:#cce5ff,stroke:#333,stroke-width:1px
    classDef orchestration fill:#c2f0c2,stroke:#333,stroke-width:1px
    classDef collection fill:#fff2cc,stroke:#333,stroke-width:1px
    classDef analysis fill:#d9d2e9,stroke:#333,stroke-width:1px
    classDef reporting fill:#fde9d9,stroke:#333,stroke-width:1px
    classDef infrastructure fill:#e6e6e6,stroke:#333,stroke-width:1px
    classDef external fill:#f4cccc,stroke:#333,stroke-width:1px,stroke-dasharray: 5 5
    classDef output fill:#d5e8d4,stroke:#333,stroke-width:1px,stroke-dasharray: 5 5
    classDef test fill:#d0e0e3,stroke:#333,stroke-width:1px,stroke-dasharray: 2 2
```
