# cassiojhones/folderflex architecture

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

- Interactive diagram: https://gitdiagram.com/cassiojhones/folderflex
- Repository: https://github.com/cassiojhones/folderflex

## Overview

##### Project Type and Purpose
- This is a desktop application built with WPF (XAML + .NET 8) following the MVVM pattern.
- FolderFlex automates moving/copying of large numbers of files from nested subfolders into a single root or destination folder, with progress feedback, error logging, and auto-update via GitHub Releases.

##### File-Structure Analysis
Top‐level:
- FolderFlex.sln – solution file for both projects.
- FolderFlex/ – WPF app project.
- FolderFlexCommon/ – shared class library for messaging and settings.
- config.flx – runtime configuration.
Within FolderFlex/:
- View/ (XAML views)
- ViewModel/ (VMs exposing commands & properties)
- Factory/ (ComponentFactory for MainWindow, illustrates Factory Pattern)
- Services/
– FileService.cs (core file‐move/copy operations)
– ErrorManager/ (ErrorHandler, ErrorLogger, LogManager implementing Observer Pattern via IObserver/ISubject)
– OpenDialog.cs (UI file/folder picking)
- Util/ (converters, RelayCommand for ICommand, UpdateChecker for GitHub Releases)
- App.xaml(.cs) (application entry point)
Within FolderFlexCommon/:
- Messages/MessageMap & messages.json (i18n)
- Settings/ (ApplicationSettings, IniFileParameterStore, XmlParameterStore implementing IParameterStore)

##### README Insights
- Confirms WPF front end, .NET 8 back end.
- Highlights MVVM, multi-language support, progress feedback, auto updates, and logging.

##### Diagramming the Architecture
a. Main Components
1) UI Layer (WPF View)
2) Presentation Layer (ViewModel, RelayCommand)
3) Component Factory (instantiates MainWindow components)
4) Business Logic / Domain Layer (FileService)
5) Services
- ErrorManager (Observer Pattern)
- OpenDialog service
- UpdateChecker (External GitHub Releases API)
6) Shared Library (FolderFlexCommon):
- Messaging (JSON resources)
- Settings (INI/XML parameter stores)
7) Data Stores:
- Local file system (source/destination folders, config.flx)
- Log files
8) External Service: GitHub Releases
b. Relationships & Data Flow
- User clicks button in View → ViewModel command executes → uses Factory to build processing components → FileService scans file system → raises progress events → ErrorManager logs errors (Observer) → FileService writes to destination FS.
- ViewModel subscribes to FileService events to update UI.
- UpdateChecker periodically calls GitHub Releases REST API → notifies ViewModel → prompts user to update.
- Settings are loaded via IParameterStore implementations (INI or XML) from FolderFlexCommon and injected into services.
c. Architectural Patterns
- MVVM (UI / ViewModel / Model separation)
- Factory Pattern (component creation)
- Observer Pattern (ErrorManager / logging, progress notifications)
- Dependency Injection (services and common library abstractions)
d. Technologies & Libraries
- WPF (XAML, System.Windows)
- .NET 8
- JSON (messages.json for i18n)
- GitHub REST API (auto-update)
- IParameterStore (INI/XML config handling)

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% UI Layer
    subgraph "UI Layer" 
        direction TB
        ViewXAML["FolderFlexMain.xaml"]:::ui
        ViewCS["FolderFlexMain.xaml.cs"]:::ui
    end

    %% Presentation Layer
    subgraph "Presentation Layer" 
        direction TB
        VM1["FolderFlexViewModel.cs"]:::presentation
        VM2["FolderFlexMessageProviderViewModel.cs"]:::presentation
        Relay["RelayCommand.cs"]:::presentation
    end

    %% Bootstrap / Composition
    subgraph "Bootstrap / Factory" 
        direction TB
        Factory["ProcessFileComponent.cs"]:::service
        AppXAML["App.xaml"]:::ui
        AppCS["App.xaml.cs"]:::ui
    end

    %% Domain / Business Logic
    subgraph "Domain Layer" 
        direction TB
        FileService["FileService.cs"]:::domain
    end

    %% Services Layer
    subgraph "Services" 
        direction TB
        subgraph "ErrorManager" 
            direction TB
            ErrorHandler["ErrorHandler.cs"]:::service
            ErrorLogger["ErrorLogger.cs"]:::service
            LogManager["LogManager.cs"]:::service
            IObserver["IObserver.cs"]:::service
            ISubject["ISubject.cs"]:::service
        end
        OpenDialog["OpenDialog.cs"]:::service
        UpdateChecker["UpdateChecker.cs"]:::service
    end

    %% Shared Library
    subgraph "Shared Library (FolderFlexCommon)" 
        direction TB
        subgraph "Messaging (i18n)" 
            MessageMap["MessageMap.cs"]:::shared
            MessagesJson["messages.json"]:::shared
        end
        subgraph "Settings" 
            AppSettings["ApplicationSettings.cs"]:::shared
            IniStore["IniFileParameterStore.cs"]:::shared
            XmlStore["XmlParameterStore.cs"]:::shared
            IParameter["IParameterStore.cs"]:::shared
        end
    end

    %% Infrastructure / Data Stores
    subgraph "Data Stores & Config" 
        direction TB
        FS["Local File System"]:::infra
        Config["config.flx"]:::infra
        Logs["Log Files"]:::infra
    end

    %% External
    GitHub["GitHub Releases"]:::external

    %% Connections
    ViewXAML -->|"ICommand Bind"| VM1
    ViewCS -->|"ICommand Bind"| VM1
    VM1 -->|"uses"| Relay
    VM1 -->|"invoke"| Factory
    Factory -->|"create"| FileService
    FileService -->|"read/write"| FS
    FileService -->|"progress events"| VM1
    FileService -->|"error events"| ErrorHandler
    ErrorHandler -->|"log"| ErrorLogger
    ErrorLogger -->|"write"| LogManager
    LogManager -->|"store"| Logs
    VM1 -->|"load settings"| AppSettings
    VM1 -->|"load messages"| MessageMap
    OpenDialog -->|"pick folder"| VM1
    UpdateChecker -->|"REST API"| GitHub
    GitHub -->|"release data"| UpdateChecker
    UpdateChecker -->|"notify"| VM1

    IObserver -->|"implemented by"| ErrorHandler
    ISubject -->|"implemented by"| FileService
    AppCS -->|"application start"| Factory

    IniStore -->|"implements"| IParameter
    XmlStore -->|"implements"| IParameter

    VM2 -.->|"provides messages"| VM1

    %% Click Events
    click ViewXAML "https://github.com/cassiojhones/folderflex/blob/master/FolderFlex/View/FolderFlexMain.xaml"
    click ViewCS "https://github.com/cassiojhones/folderflex/blob/master/FolderFlex/View/FolderFlexMain.xaml.cs"
    click VM1 "https://github.com/cassiojhones/folderflex/blob/master/FolderFlex/ViewModel/FolderFlexViewModel.cs"
    click VM2 "https://github.com/cassiojhones/folderflex/blob/master/FolderFlex/ViewModel/FolderFlexMessageProviderViewModel.cs"
    click Relay "https://github.com/cassiojhones/folderflex/blob/master/FolderFlex/Util/RelayCommand.cs"
    click Factory "https://github.com/cassiojhones/folderflex/blob/master/FolderFlex/Factory/MainWindow.ComponentFactory/ProcessFileComponent.cs"
    click FileService "https://github.com/cassiojhones/folderflex/blob/master/FolderFlex/Services/FileService.cs"
    click ErrorHandler "https://github.com/cassiojhones/folderflex/blob/master/FolderFlex/Services/ErrorManager/ErrorHandler.cs"
    click ErrorLogger "https://github.com/cassiojhones/folderflex/blob/master/FolderFlex/Services/ErrorManager/ErrorLogger.cs"
    click LogManager "https://github.com/cassiojhones/folderflex/blob/master/FolderFlex/Services/ErrorManager/LogManager.cs"
    click IObserver "https://github.com/cassiojhones/folderflex/blob/master/FolderFlex/Services/Interface/IObserver.cs"
    click ISubject "https://github.com/cassiojhones/folderflex/blob/master/FolderFlex/Services/Interface/ISubject.cs"
    click OpenDialog "https://github.com/cassiojhones/folderflex/blob/master/FolderFlex/Services/OpenDialog.cs"
    click UpdateChecker "https://github.com/cassiojhones/folderflex/blob/master/FolderFlex/Util/UpdateChecker.cs"
    click AppXAML "https://github.com/cassiojhones/folderflex/blob/master/FolderFlex/App.xaml"
    click AppCS "https://github.com/cassiojhones/folderflex/blob/master/FolderFlex/App.xaml.cs"
    click MessageMap "https://github.com/cassiojhones/folderflex/blob/master/FolderFlexCommon/Messages/MessageMap.cs"
    click MessagesJson "https://github.com/cassiojhones/folderflex/blob/master/FolderFlexCommon/Messages/Resources/messages.json"
    click AppSettings "https://github.com/cassiojhones/folderflex/blob/master/FolderFlexCommon/Settings/ApplicationSettings/ApplicationSettings.cs"
    click IniStore "https://github.com/cassiojhones/folderflex/blob/master/FolderFlexCommon/Settings/IniFileParameterStore.cs"
    click XmlStore "https://github.com/cassiojhones/folderflex/blob/master/FolderFlexCommon/Settings/XmlParameterStore.cs"
    click IParameter "https://github.com/cassiojhones/folderflex/blob/master/FolderFlexCommon/Settings/Model/IParameterStore.cs"
    click Config "https://github.com/cassiojhones/folderflex/blob/master/config.flx"

    %% Styles
    classDef ui fill:#cce5ff,stroke:#004085;
    classDef presentation fill:#d4edda,stroke:#155724;
    classDef domain fill:#fff3cd,stroke:#856404;
    classDef service fill:#f5c6cb,stroke:#721c24;
    classDef shared fill:#e2e3e5,stroke:#6c757d;
    classDef infra fill:#d1ecf1,stroke:#0c5460;
    classDef external fill:#f8d7da,stroke:#721c24;
```
