# techieguy12/filewatcher architecture

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

- Interactive diagram: https://gitdiagram.com/techieguy12/filewatcher
- Repository: https://github.com/techieguy12/filewatcher

## Overview

##### Project type and purpose
- This is an open-source, cross-platform command-line File Watcher tool written in C#/.NET.
- Its purpose is to monitor file system changes (create, modify, delete) on local or external drives, then perform user-defined reactions: send HTTP notifications, execute file operations (copy/move/delete), or run arbitrary commands.

##### File structure
- Top-level solution:
– FileWatcher.sln coordinates two project types:
- FileWatcher (the core .NET tool)
- FwInstaller (a WiX installer for Windows)
– LICENSE, README.md, templates/ (config file template)
- src/ (core code) organized into feature areas:
– Configuration (XML parsing abstractions, triggers, actions, filters, notifications)
– FileSystem (wrappers around directory and file concepts)
– IO (path, name, pattern matching, file/folder operations)
– Log (logging engine with rollover)
– Net (HTTP Request/Response for notification endpoint)
– Program.cs & appsettings.json (entry point and runtime settings)
- FwInstaller/ (WiX project) uses config.xml.sample and Package.wxs for building an .msi/.exe

##### README for additional insights
- Confirms supported platforms (Windows/MacOS/Linux), zero-install portability, low resource use
- Highlights configuration-driven architecture, plug-in points for actions, notifications, exclusions

##### Detail without over-splitting
- Call out the installer project as a separate packaging flow

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% CLI Layer
    CLI["CLI Front End"]:::cli
    Settings["appsettings.json"]:::config
    CLI -->|"reads settings"| Settings

    %% Configuration Layer
    subgraph "Configuration Layer"
        direction TB
        Templates["config-template.xml"]:::template
        XMLFile["XmlFile"]:::config
        IConfigurationFile["IConfigurationFile"]:::config
        Actions["Actions"]:::config
        NotificationsCfg["Notifications"]:::config
        FiltersCfg["Filters"]:::config
        TriggersCfg["Triggers"]:::config
        ChangeInfo["ChangeInfo"]:::config
        CommandCfg["Command"]:::config
        CommandsCfg["Commands"]:::config
        RunnableBase["RunnableBase"]:::config
    end
    Templates -->|"provides template"| XMLFile
    Settings --> XMLFile
    XMLFile --> IConfigurationFile
    IConfigurationFile --> Actions
    IConfigurationFile --> NotificationsCfg
    IConfigurationFile --> FiltersCfg
    IConfigurationFile --> TriggersCfg
    IConfigurationFile --> ChangeInfo
    IConfigurationFile --> CommandCfg
    CommandCfg --> CommandsCfg
    CommandsCfg --> RunnableBase

    %% Core Engine Layer
    subgraph "Core Engine & Watchers" 
        direction TB
        CoreEngine["Core Watch Engine"]:::core
        Watchers["FileSystem Watchers"]:::core
        Processor["Trigger/Filter Processor"]:::core
    end
    CLI -->|"parses args"| CoreEngine
    XMLFile -->|"builds models"| CoreEngine
    CoreEngine -->|"instantiates"| Watchers
    Watchers -->|"ChangeEvent"| Processor

    %% Action & Notification Layer
    subgraph "Action Executor" 
        direction TB
        FileOps["File Operations Module"]:::action
        CommandRunner["Command Runner"]:::action
    end
    subgraph "Notification Sender"
        Notifier["Notification Sender"]:::notification
    end
    Processor -->|"TriggerMatch"| FileOps
    Processor -->|"TriggerMatch"| CommandRunner
    Processor -->|"TriggerMatch"| Notifier

    %% Logging Subsystem
    Logger["Logging Subsystem"]:::logging
    Processor -->|"logs events"| Logger
    FileOps -->|"logs actions"| Logger
    CommandRunner -->|"logs commands"| Logger
    Notifier -->|"logs notifications"| Logger
    CoreEngine -->|"logs status"| Logger
    Watchers -->|"logs events"| Logger

    %% Installer Project
    subgraph "Installer Project" 
        direction TB
        InstallerProj["FwInstaller.wixproj"]:::installer
        PackageWxs["Package.wxs"]:::installer
        ConfigSample["config.xml.sample"]:::installer
    end
    CoreEngine -->|"build output"| InstallerProj

    %% Click Events
    click CLI "https://github.com/techieguy12/filewatcher/blob/main/src/Program.cs"
    click Settings "https://github.com/techieguy12/filewatcher/blob/main/src/appsettings.json"
    click Templates "https://github.com/techieguy12/filewatcher/blob/main/templates/config-template.xml"
    click XMLFile "https://github.com/techieguy12/filewatcher/blob/main/src/Configuration/XmlFile.cs"
    click IConfigurationFile "https://github.com/techieguy12/filewatcher/blob/main/src/Configuration/IConfigurationFile.cs"
    click Actions "https://github.com/techieguy12/filewatcher/blob/main/src/Configuration/Actions.cs"
    click NotificationsCfg "https://github.com/techieguy12/filewatcher/blob/main/src/Configuration/Notifications.cs"
    click FiltersCfg "https://github.com/techieguy12/filewatcher/blob/main/src/Configuration/Filters.cs"
    click TriggersCfg "https://github.com/techieguy12/filewatcher/blob/main/src/Configuration/Triggers.cs"
    click ChangeInfo "https://github.com/techieguy12/filewatcher/blob/main/src/Configuration/ChangeInfo.cs"
    click CommandCfg "https://github.com/techieguy12/filewatcher/blob/main/src/Configuration/Command.cs"
    click CommandsCfg "https://github.com/techieguy12/filewatcher/blob/main/src/Configuration/Commands.cs"
    click RunnableBase "https://github.com/techieguy12/filewatcher/blob/main/src/Configuration/RunnableBase.cs"
    click CoreEngine "https://github.com/techieguy12/filewatcher/blob/main/src/FileWatcher.csproj"
    click Watchers "https://github.com/techieguy12/filewatcher/blob/main/src/FileSystem/Directory.cs"
    click Processor "https://github.com/techieguy12/filewatcher/blob/main/src/Configuration/Triggers.cs"
    click FileOps "https://github.com/techieguy12/filewatcher/blob/main/src/IO/Files.cs"
    click CommandRunner "https://github.com/techieguy12/filewatcher/blob/main/src/Configuration/Command.cs"
    click Notifier "https://github.com/techieguy12/filewatcher/blob/main/src/Net/Request.cs"
    click Logger "https://github.com/techieguy12/filewatcher/blob/main/src/Log/Logger.cs"
    click InstallerProj "https://github.com/techieguy12/filewatcher/blob/main/FwInstaller/FwInstaller.wixproj"
    click PackageWxs "https://github.com/techieguy12/filewatcher/blob/main/FwInstaller/Package.wxs"
    click ConfigSample "https://github.com/techieguy12/filewatcher/blob/main/FwInstaller/config.xml.sample"

    %% Styles
    classDef cli fill:#eef,stroke:#99f,stroke-width:2px
    classDef config fill:#efe,stroke:#3c3,stroke-width:2px
    classDef core fill:#def,stroke:#36f,stroke-width:2px
    classDef action fill:#fed,stroke:#f90,stroke-width:2px
    classDef notification fill:#fed,stroke:#f60,stroke-width:2px
    classDef logging fill:#ddd,stroke:#999,stroke-width:2px
    classDef installer fill:#fdd,stroke:#f33,stroke-width:2px
    classDef template fill:#dfd,stroke:#2a2,stroke-width:2px
```
