# esl1h/vbackups architecture

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

- Interactive diagram: https://gitdiagram.com/esl1h/vbackups
- Repository: https://github.com/esl1h/vbackups

## Overview

##### Project Type & Purpose
- This is an open-source, command-line backup utility written in V (wrapped in a shell script), designed to:
- Read a YAML config (backups.yaml)
- Compress directories in parallel (pigz)
- Encrypt & sign archives (GPG)
- Send real-time notifications (ntfy.sh)
- Clean up temporary files and collect statistics

##### Main Components
a. V-Backup Script (vbackup.vsh / compiled V code)
b. Configuration (backups.yaml)
c. Local Compression Engine (tar + pigz)
d. Local Encryption Engine (GPG)
e. Notification Service (ntfy.sh)
f. Destination Storage (local filesystem directory)
g. Optional Scheduler (cron or systemd)

##### Relationships & Data Flows
- The Script reads the YAML config → iterates each backup item
- For each item:
- Calls tar+pigz → produces .tar.gz
- Calls GPG → produces .tar.gz.gpg
- Deletes the .tar.gz
- Updates in-memory statistics object
- After all items:
- Script issues HTTP POST to ntfy.sh with summary
- Script exits
- Scheduler (cron/systemd) triggers the script on a fixed schedule

##### Architectural Patterns
- Linear pipeline per item (Load → Compress → Encrypt → Clean)
- Modular external tool invocation (shell calls to tar/pigz/gpg/curl)
- Configuration-driven behavior (YAML)
- Single process, sequential loop, fault-tolerant via exit codes

a. Sketch a “Local Host” container. Inside it, place:
– “vbackup.vsh / V binary” (center)
– “tar + pigz” (to the right of script)
– “GPG” (right of compression)
– “Local Backup Directory” (destination, bottom of encryption)
b. Outside the Local Host, place:
– “Load config” (config → script)
– “Compress .tar.gz” (script → tar+pigz)
– “Encrypt & Sign” (tar+pigz → GPG)
– “Store .gpg” (GPG → Backup Directory)
– “Delete temp file” (script → indicates cleanup)
– “Send notification” (script → ntfy.sh)
– “Scheduled run” (Cron/systemd → script)

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Local Host boundary
    subgraph "Local Host"
        direction TB
        YAML["backups.yaml"]:::internal
        Script["vbackup.vsh / V binary"]:::internal
        subgraph "Loop per item"
            direction TB
            Compression["tar + pigz"]:::tools
            Encryption["GPG"]:::tools
        end
        Storage["Local Backup Directory"]:::storage
    end

    %% External services
    Scheduler["Cron / systemd"]:::external
    Notification["ntfy.sh API"]:::external

    %% Project Files
    subgraph "Project Files"
        direction TB
        Vmod["v.mod"]:::internal
        Doc["readme.adoc"]:::internal
        Gita[".gitattributes"]:::internal
        Giti[".gitignore"]:::internal
        Editor[".editorconfig"]:::internal
    end

    %% Connections
    YAML -->|"Load config"| Script
    Scheduler -.->|"Scheduled run"| Script
    Script -->|"Compress .tar.gz"| Compression
    Compression -->|"Encrypt & Sign"| Encryption
    Encryption -->|"Store .gpg"| Storage
    Script -->|"Send notification"| Notification
    Script -->|"Delete temp file"| Script

    %% Legend
    subgraph "Legend"
        direction TB
        A["Internal Processes"]:::internal
        B["External Tools"]:::tools
        C["Storage"]:::storage
        D["External Services"]:::external
    end

    %% Click Events
    click Script "https://github.com/esl1h/vbackups/blob/main/vbackup.vsh"
    click YAML "https://github.com/esl1h/vbackups/blob/main/backups.yaml"
    click Vmod "https://github.com/esl1h/vbackups/blob/main/v.mod"
    click Doc "https://github.com/esl1h/vbackups/blob/main/readme.adoc"
    click Gita "https://github.com/esl1h/vbackups/blob/main/.gitattributes"
    click Giti "https://github.com/esl1h/vbackups/blob/main/.gitignore"
    click Editor "https://github.com/esl1h/vbackups/blob/main/.editorconfig"

    %% Styles
    classDef internal fill:#add8e6,stroke:#333,stroke-width:1px
    classDef tools fill:#ffa500,stroke:#333,stroke-width:1px
    classDef storage fill:#90ee90,stroke:#333,stroke-width:1px
    classDef external fill:#dda0dd,stroke:#333,stroke-width:1px
```
