# binarynoir/noirwatch architecture

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

- Interactive diagram: https://gitdiagram.com/binarynoir/noirwatch
- Repository: https://github.com/binarynoir/noirwatch

## Overview

##### Main Components

a) Core Components:
- Website Monitor Engine
- Cache Management System
- Notification Dispatcher
- Configuration Manager
- Process Manager (Service/Daemon)

b) External Interfaces:
- Target Websites (monitored URLs)
- Notification Services (Pushover, Desktop Notifications)
- File System (Cache, Logs)

**[External Layer]**
- Monitored Websites
- Notification Services (Pushover, Desktop)

**[Core Layer]**
- Website Monitor Engine
- Cache Management
- Configuration Manager
- Process Manager

**[Storage Layer]**
- Cache Directory
- Log Files
- Configuration Files

##### Component Relationships

a) Data Flow:
- Website Monitor Engine → Monitored Websites (HTTP requests)
- Website Monitor Engine → Cache Management (store website snapshots)
- Cache Management → Storage Layer (read/write operations)
- Configuration Manager → Storage Layer (config file operations)
- Notification Dispatcher → External Notification Services

b) Control Flow:
- Process Manager → Website Monitor Engine (control monitoring service)
- Website Monitor Engine → Notification Dispatcher (trigger notifications)
- Configuration Manager → All Components (provide settings)

##### Additional Details

Annotations for:
- Check intervals
- Timeout settings
- Supported notification methods
- Cache directory structure
- Configuration file format (JSON)

##### Technical Specifications

Notes about:
- Bash 4.0+ requirement
- Required system utilities (curl, sed, shasum, etc.)
- Platform-specific components (notify-send, powershell)
- Service deployment options (systemd, launchd, Windows Task Scheduler)

##### Implementation Notes

Highlight:
- Modular design for notification methods
- Configuration file structure
- Cache management strategy
- Process management approach
- Cross-platform compatibility

##### Service-oriented architecture

Remember to include version information and any platform-specific variations in the implementation, as the tool supports Linux, macOS, and Windows environments.

## Diagram (Mermaid)

```mermaid
graph TB
    subgraph External["External Layer"]
        Websites["Target Websites"]
        NotifServices["Notification Services"]:::external
        subgraph NotificationTypes["Notification Types"]
            Pushover["Pushover"]
            Desktop["Desktop Notifications"]
        end
    end

    subgraph Core["Core Layer"]
        Monitor["Website Monitor Engine"]:::core
        Cache["Cache Management System"]:::core
        NotifDispatch["Notification Dispatcher"]:::core
        Config["Configuration Manager"]:::core
        Process["Process Manager"]:::core
    end

    subgraph Storage["Storage Layer"]
        CacheDir["Cache Directory"]:::storage
        LogFiles["Log Files"]:::storage
        ConfigFiles["Configuration Files"]:::storage
    end

    subgraph Platform["Platform-Specific Components"]
        NotifySend["notify-send\n(Linux)"]
        PowerShell["PowerShell\n(Windows)"]
    end

    %% Core relationships
    Monitor -->|HTTP Requests| Websites
    Monitor -->|Store Snapshots| Cache
    Monitor -->|Trigger| NotifDispatch
    Process -->|Control| Monitor
    Config -->|Settings| Monitor
    Config -->|Settings| Cache
    Config -->|Settings| NotifDispatch
    
    %% Storage relationships
    Cache -->|Read/Write| CacheDir
    Config -->|Read| ConfigFiles
    Monitor -->|Write| LogFiles
    
    %% Notification flow
    NotifDispatch -->|Send| NotifServices
    NotifDispatch -->|Desktop| NotifySend
    NotifDispatch -->|Desktop| PowerShell
    NotificationTypes -->|API| NotifServices

    %% Component mappings with click events
    click Monitor "https://github.com/binarynoir/noirwatch/tree/main/noirwatch"
    click Config "https://github.com/binarynoir/noirwatch/blob/main/test/test.json"
    click ConfigFiles "https://github.com/binarynoir/noirwatch/blob/main/test/test.sh"
    click LogFiles "https://github.com/binarynoir/noirwatch/blob/main/noirwatch.1"
    click Process "https://github.com/binarynoir/noirwatch/blob/main/.github/workflows/release.yml"
    click Cache "https://github.com/binarynoir/noirwatch/blob/main/.devcontainer/devcontainer.json"
    click NotifDispatch "https://github.com/binarynoir/noirwatch/tree/main/Brewfile"
    click NotifServices "https://github.com/binarynoir/noirwatch/blob/main/scripts/publish-release.sh"

    %% Styling
    classDef core fill:#2374ab
    classDef external fill:#7dba84
    classDef storage fill:#ffb347
    classDef config fill:#gray
    classDef critical fill:#ff6b6b

    %% Legend
    subgraph Legend
        L1[Core Components]:::core
        L2[External Services]:::external
        L3[Storage Elements]:::storage
        L4[Critical Components]:::critical
    end
```
