# hgalexx/hg.savehistory architecture

> Architecture diagram of the GitHub repository hgalexx/hg.savehistory, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-11-27). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/hgalexx/hg.savehistory
- Repository: https://github.com/hgalexx/hg.savehistory

## Overview

Hg.SaveHistory is a Windows desktop application for managing file-save snapshots through game- or application-specific engines. Users create a profile in the wizard, configure its engine, then use the main window to back up, restore, archive, delete, and organize snapshots. Engine scripts run through Lua; watcher-driven automatic backups and optional screenshots extend that workflow. The tree and excerpts establish the main UI, engine, script, settings, and hotkey components. Several feature links are documented in the README because their implementation details were not sampled.

Main entry points: [`Hg.SaveHistory/Forms/FormMain.cs`](https://github.com/hgalexx/hg.savehistory/blob/master/Hg.SaveHistory/Forms/FormMain.cs) (Main window), [`Hg.SaveHistory/Managers/LuaManager.cs`](https://github.com/hgalexx/hg.savehistory/blob/master/Hg.SaveHistory/Managers/LuaManager.cs) (Lua runtime), [`Hg.SaveHistory/API/Engine.cs`](https://github.com/hgalexx/hg.savehistory/blob/master/Hg.SaveHistory/API/Engine.cs) (Engine API), [`Hg.SaveHistory/API/EngineSnapshot.cs`](https://github.com/hgalexx/hg.savehistory/blob/master/Hg.SaveHistory/API/EngineSnapshot.cs) (Snapshot model)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_profile_setup["Profile setup"]
  node_profile_wizard["Profile wizard"]
  node_engine_discovery["Engine discovery"]
  node_engine_scripts["Engine scripts<br/>[EngineScript.cs]"]
  node_script_files["Script files"]
  node_profile_data["Profile data<br/>[ProfileFile.cs]"]
end

subgraph group_snapshot_runtime["Snapshot runtime"]
  node_main_window["Main window<br/>[FormMain.cs]"]
  node_lua_runtime["Lua runtime<br/>[LuaManager.cs]"]
  node_engine_api["Engine API<br/>[Engine.cs]"]
  node_snapshot_model["Snapshot model<br/>[EngineSnapshot.cs]"]
  node_snapshot_categories["Snapshot categories"]
  node_backup_restore["Backup and restore<br/>[BackupHelper.cs]"]
  node_watcher_manager["Watcher manager<br/>[WatcherManager.cs]"]
  node_engine_watcher["Engine watcher<br/>[EngineWatcher.cs]"]
  node_screenshot_helper["Screenshot helper"]
end

subgraph group_app_controls["Application controls"]
  node_hotkeys["Hotkey manager<br/>[HotKeysManager.cs]"]
  node_settings_manager["Settings manager<br/>[SettingsManager.cs]"]
  node_settings_model["Settings model<br/>[Settings.cs]"]
  node_cleanup_ui["Snapshot cleanup"]
  node_sound_manager["Sound notifications<br/>[SoundManager.cs]"]
end

subgraph group_support_services["Support services"]
  node_logger["Logging<br/>[Logger.cs]"]
  node_filesystem[("Save files")]
end

node_user(("User"))

node_user -->|"creates profile"| node_profile_wizard
node_profile_wizard -->|"selects engine"| node_engine_discovery
node_engine_discovery -->|"loads scripts"| node_engine_scripts
node_engine_discovery -->|"collects files"| node_script_files
node_profile_wizard -->|"configures profile"| node_profile_data
node_user -->|"manages snapshots"| node_main_window
node_main_window -->|"opens profile"| node_lua_runtime
node_lua_runtime -->|"creates engine"| node_engine_api
node_lua_runtime -->|"loads scripts"| node_engine_scripts
node_main_window -->|"opens profile"| node_profile_data
node_lua_runtime -->|"loads settings"| node_profile_data
node_lua_runtime -->|"loads snapshots"| node_snapshot_model
node_main_window -.->|"performs actions"| node_backup_restore
node_main_window -->|"displays snapshots"| node_snapshot_model
node_engine_api -->|"holds snapshots"| node_snapshot_model
node_engine_api -->|"holds categories"| node_snapshot_categories
node_main_window -->|"manages auto-backup"| node_watcher_manager
node_watcher_manager -->|"uses watchers"| node_engine_watcher
node_engine_api -->|"configures screenshots"| node_screenshot_helper
node_main_window -.->|"captures screenshots"| node_screenshot_helper
node_main_window -->|"manages hotkeys"| node_hotkeys
node_hotkeys -.->|"selects snapshots"| node_snapshot_model
node_main_window -->|"uses settings"| node_settings_manager
node_settings_manager -->|"loads and saves"| node_settings_model
node_main_window -->|"configures cleanup"| node_cleanup_ui
node_main_window -.->|"plays notifications"| node_sound_manager
node_backup_restore -.->|"operates on"| node_filesystem
node_watcher_manager -.->|"watches files"| node_filesystem

click node_profile_wizard "https://github.com/hgalexx/hg.savehistory/blob/master/Hg.SaveHistory/Wizards/FormWizardNewProfile.cs"
click node_engine_discovery "https://github.com/hgalexx/hg.savehistory/blob/master/Hg.SaveHistory/Managers/EngineScriptManager.cs"
click node_engine_scripts "https://github.com/hgalexx/hg.savehistory/blob/master/Hg.SaveHistory/Types/EngineScript.cs"
click node_script_files "https://github.com/hgalexx/hg.savehistory/blob/master/Hg.SaveHistory/Types/EngineScriptFile.cs"
click node_profile_data "https://github.com/hgalexx/hg.savehistory/blob/master/Hg.SaveHistory/Types/ProfileFile.cs"
click node_main_window "https://github.com/hgalexx/hg.savehistory/blob/master/Hg.SaveHistory/Forms/FormMain.cs"
click node_lua_runtime "https://github.com/hgalexx/hg.savehistory/blob/master/Hg.SaveHistory/Managers/LuaManager.cs"
click node_engine_api "https://github.com/hgalexx/hg.savehistory/blob/master/Hg.SaveHistory/API/Engine.cs"
click node_snapshot_model "https://github.com/hgalexx/hg.savehistory/blob/master/Hg.SaveHistory/API/EngineSnapshot.cs"
click node_snapshot_categories "https://github.com/hgalexx/hg.savehistory/blob/master/Hg.SaveHistory/API/EngineSnapshotCategory.cs"
click node_backup_restore "https://github.com/hgalexx/hg.savehistory/blob/master/Hg.SaveHistory/API/BackupHelper.cs"
click node_watcher_manager "https://github.com/hgalexx/hg.savehistory/blob/master/Hg.SaveHistory/Managers/WatcherManager.cs"
click node_engine_watcher "https://github.com/hgalexx/hg.savehistory/blob/master/Hg.SaveHistory/API/EngineWatcher.cs"
click node_screenshot_helper "https://github.com/hgalexx/hg.savehistory/blob/master/Hg.SaveHistory/API/ScreenshotHelper.cs"
click node_hotkeys "https://github.com/hgalexx/hg.savehistory/blob/master/Hg.SaveHistory/Managers/HotKeysManager.cs"
click node_settings_manager "https://github.com/hgalexx/hg.savehistory/blob/master/Hg.SaveHistory/Managers/SettingsManager.cs"
click node_settings_model "https://github.com/hgalexx/hg.savehistory/blob/master/Hg.SaveHistory/Types/Settings.cs"
click node_cleanup_ui "https://github.com/hgalexx/hg.savehistory/blob/master/Hg.SaveHistory/Controls/AutoCleanupControl.cs"
click node_sound_manager "https://github.com/hgalexx/hg.savehistory/blob/master/Hg.SaveHistory/Managers/SoundManager.cs"
click node_logger "https://github.com/hgalexx/hg.savehistory/blob/master/Hg.SaveHistory/Utilities/Logger.cs"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_profile_wizard,node_engine_discovery,node_engine_scripts,node_script_files,node_profile_data,node_user toneBlue
class node_main_window,node_lua_runtime,node_engine_api,node_snapshot_model,node_snapshot_categories,node_backup_restore,node_watcher_manager,node_engine_watcher,node_screenshot_helper toneAmber
class node_hotkeys,node_settings_manager,node_settings_model,node_cleanup_ui,node_sound_manager toneMint
class node_logger,node_filesystem toneRose
```

## Components

### Profile setup

- [Profile wizard](https://github.com/hgalexx/hg.savehistory/blob/master/Hg.SaveHistory/Wizards/FormWizardNewProfile.cs): `Hg.SaveHistory/Wizards/FormWizardNewProfile.cs`
- [Engine discovery](https://github.com/hgalexx/hg.savehistory/blob/master/Hg.SaveHistory/Managers/EngineScriptManager.cs): `Hg.SaveHistory/Managers/EngineScriptManager.cs`
- [Engine scripts](https://github.com/hgalexx/hg.savehistory/blob/master/Hg.SaveHistory/Types/EngineScript.cs): `Hg.SaveHistory/Types/EngineScript.cs`
- [Script files](https://github.com/hgalexx/hg.savehistory/blob/master/Hg.SaveHistory/Types/EngineScriptFile.cs): `Hg.SaveHistory/Types/EngineScriptFile.cs`
- [Profile data](https://github.com/hgalexx/hg.savehistory/blob/master/Hg.SaveHistory/Types/ProfileFile.cs): `Hg.SaveHistory/Types/ProfileFile.cs`

### Snapshot runtime

- [Main window](https://github.com/hgalexx/hg.savehistory/blob/master/Hg.SaveHistory/Forms/FormMain.cs): `Hg.SaveHistory/Forms/FormMain.cs`
- [Lua runtime](https://github.com/hgalexx/hg.savehistory/blob/master/Hg.SaveHistory/Managers/LuaManager.cs): `Hg.SaveHistory/Managers/LuaManager.cs`
- [Engine API](https://github.com/hgalexx/hg.savehistory/blob/master/Hg.SaveHistory/API/Engine.cs): `Hg.SaveHistory/API/Engine.cs`
- [Snapshot model](https://github.com/hgalexx/hg.savehistory/blob/master/Hg.SaveHistory/API/EngineSnapshot.cs): `Hg.SaveHistory/API/EngineSnapshot.cs`
- [Snapshot categories](https://github.com/hgalexx/hg.savehistory/blob/master/Hg.SaveHistory/API/EngineSnapshotCategory.cs): `Hg.SaveHistory/API/EngineSnapshotCategory.cs`
- [Backup and restore](https://github.com/hgalexx/hg.savehistory/blob/master/Hg.SaveHistory/API/BackupHelper.cs): `Hg.SaveHistory/API/BackupHelper.cs`
- [Watcher manager](https://github.com/hgalexx/hg.savehistory/blob/master/Hg.SaveHistory/Managers/WatcherManager.cs): `Hg.SaveHistory/Managers/WatcherManager.cs`
- [Engine watcher](https://github.com/hgalexx/hg.savehistory/blob/master/Hg.SaveHistory/API/EngineWatcher.cs): `Hg.SaveHistory/API/EngineWatcher.cs`
- [Screenshot helper](https://github.com/hgalexx/hg.savehistory/blob/master/Hg.SaveHistory/API/ScreenshotHelper.cs): `Hg.SaveHistory/API/ScreenshotHelper.cs`

### Application controls

- [Hotkey manager](https://github.com/hgalexx/hg.savehistory/blob/master/Hg.SaveHistory/Managers/HotKeysManager.cs): `Hg.SaveHistory/Managers/HotKeysManager.cs`
- [Settings manager](https://github.com/hgalexx/hg.savehistory/blob/master/Hg.SaveHistory/Managers/SettingsManager.cs): `Hg.SaveHistory/Managers/SettingsManager.cs`
- [Settings model](https://github.com/hgalexx/hg.savehistory/blob/master/Hg.SaveHistory/Types/Settings.cs): `Hg.SaveHistory/Types/Settings.cs`
- [Snapshot cleanup](https://github.com/hgalexx/hg.savehistory/blob/master/Hg.SaveHistory/Controls/AutoCleanupControl.cs): `Hg.SaveHistory/Controls/AutoCleanupControl.cs`
- [Sound notifications](https://github.com/hgalexx/hg.savehistory/blob/master/Hg.SaveHistory/Managers/SoundManager.cs): `Hg.SaveHistory/Managers/SoundManager.cs`

### Support services

- [Logging](https://github.com/hgalexx/hg.savehistory/blob/master/Hg.SaveHistory/Utilities/Logger.cs): `Hg.SaveHistory/Utilities/Logger.cs`
- **Save files**

### Other components

- **User**

## Connections

- User → Profile wizard: creates profile (evidence: `Hg.SaveHistory/Wizards/FormWizardNewProfile.cs`)
- Profile wizard → Engine discovery: selects engine (evidence: `Hg.SaveHistory/Wizards/FormWizardNewProfile.cs`)
- Engine discovery → Engine scripts: loads scripts (evidence: `Hg.SaveHistory/Managers/EngineScriptManager.cs`)
- Engine discovery → Script files: collects files (evidence: `Hg.SaveHistory/Managers/EngineScriptManager.cs`)
- Profile wizard → Profile data: configures profile (evidence: `Hg.SaveHistory/Wizards/FormWizardNewProfile.cs`)
- User → Main window: manages snapshots
- Main window → Lua runtime: opens profile (evidence: `Hg.SaveHistory/Forms/FormMain.cs`)
- Lua runtime → Engine API: creates engine (evidence: `Hg.SaveHistory/Managers/LuaManager.cs`)
- Lua runtime → Engine scripts: loads scripts (evidence: `Hg.SaveHistory/Managers/LuaManager.cs`)
- Main window → Profile data: opens profile (evidence: `Hg.SaveHistory/Forms/FormMain.cs`)
- Lua runtime → Profile data: loads settings (evidence: `Hg.SaveHistory/Managers/LuaManager.cs`)
- Lua runtime → Snapshot model: loads snapshots (evidence: `Hg.SaveHistory/Managers/LuaManager.cs`)
- Main window → Backup and restore: performs actions
- Main window → Snapshot model: displays snapshots (evidence: `Hg.SaveHistory/Forms/FormMain.cs`)
- Engine API → Snapshot model: holds snapshots (evidence: `Hg.SaveHistory/API/Engine.cs`)
- Engine API → Snapshot categories: holds categories (evidence: `Hg.SaveHistory/API/Engine.cs`)
- Main window → Watcher manager: manages auto-backup (evidence: `Hg.SaveHistory/Forms/FormMain.cs`)
- Watcher manager → Engine watcher: uses watchers (evidence: `Hg.SaveHistory/Managers/WatcherManager.cs`)
- Engine API → Screenshot helper: configures screenshots (evidence: `Hg.SaveHistory/API/Engine.cs`)
- Main window → Screenshot helper: captures screenshots (evidence: `Hg.SaveHistory/Forms/FormMain.cs`)
- Main window → Hotkey manager: manages hotkeys (evidence: `Hg.SaveHistory/Forms/FormMain.cs`)
- Hotkey manager → Snapshot model: selects snapshots
- Main window → Settings manager: uses settings (evidence: `Hg.SaveHistory/Forms/FormMain.cs`)
- Settings manager → Settings model: loads and saves (evidence: `Hg.SaveHistory/Managers/SettingsManager.cs`)
- Main window → Snapshot cleanup: configures cleanup (evidence: `Hg.SaveHistory/Forms/FormMain.cs`)
- Main window → Sound notifications: plays notifications (evidence: `Hg.SaveHistory/Forms/FormMain.cs`)
- Backup and restore → Save files: operates on
- Watcher manager → Save files: watches files
