# garthtb/frameseal architecture

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

- Interactive diagram: https://gitdiagram.com/garthtb/frameseal
- Repository: https://github.com/garthtb/frameseal

## Overview

##### Project type and purpose
- Frame Seal is a desktop image-processing tool built with .NET 9.0 WPF using the MVVM pattern.

##### Break down the file structure
- Top-level: FrameSeal.sln, FrameSeal folder, license and README files.
- Inside FrameSeal/:
- App.xaml + App.xaml.cs — WPF application entry and resource definitions
- FrameSeal.csproj — project configuration and NuGet dependencies (CommunityToolkit.Mvvm, Magick.NET)
- Models/ — core domain logic (Core.cs), file utilities (FileUtils.cs), image manipulation (ImageUtils.cs), settings model (SettingsModel.cs), string helpers (StringUtils.cs)
- ViewModels/ — MainViewModel.cs which orchestrates UI commands, data binding, and delegates to Models
- Views/ — MainWindow.xaml + code-behind for the primary UI

##### Extract architectural hints from the README
- MVVM design with clear separation of Views, ViewModels, Models
- Two major external libraries: CommunityToolkit.Mvvm for MVVM support and Magick.NET for image operations

##### Main components
a. Presentation Layer (UI)
- Components: MainWindow (XAML view), code-behind only for view initialization
- Framework: WPF (XAML)
b. Application Layer (MVVM)
- MainViewModel
- CommunityToolkit.Mvvm providing ObservableObjects, RelayCommands and binding infrastructure
c. Domain/Business Logic Layer
- Core.cs: overall application logic (e.g., command routing)
- FileUtils.cs: reading/writing image files, managing input/output paths
- ImageUtils.cs: invoking Magick.NET APIs to apply borders and embed metadata
- StringUtils.cs: formatting text overlays and metadata
d. Infrastructure & External Services
- Magick.NET library for image processing
- File system (local directories for source and output images)
- .NET 9.0 runtime and WPF framework

- User clicks “Open Image” in View → bound command in MainViewModel
- MainViewModel calls FileUtils to load the image
- MainViewModel passes image and SettingsModel to ImageUtils
- MainViewModel updates bound properties → View refreshes display
- On “Save Image,” MainViewModel invokes FileUtils to write output

##### Architectural patterns and important design principles
- MVVM pattern enforces separation of concerns:
- Views contain no business logic
- ViewModels coordinate actions and expose bindable properties
- Models contain pure domain logic and utility functions
- Dependency inversion: ViewModels depend on interfaces/abstracted Models; external libs are invoked inside Models
- Single Responsibility: each class (FileUtils, ImageUtils, SettingsModel, Core) does one thing

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Presentation Layer
    subgraph "Presentation Layer"
        AppX["App.xaml"]:::ui
        AppXcs["App.xaml.cs"]:::ui
        MW["MainWindow.xaml"]:::ui
        MWcs["MainWindow.xaml.cs"]:::ui
    end

    %% Application Layer
    subgraph "Application Layer"
        MVM["MainViewModel"]:::vm
        CT["CommunityToolkit.Mvvm"]:::external
    end

    %% Domain Layer
    subgraph "Domain/Business Logic Layer"
        Core["Core.cs"]:::model
        FU["FileUtils.cs"]:::model
        IU["ImageUtils.cs"]:::model
        SM["SettingsModel.cs"]:::model
        SS["StringUtils.cs"]:::model
    end

    %% Infrastructure & External Services
    subgraph "Infrastructure & External"
        Magick["Magick.NET"]:::external
        FS["File System"]:::external
        DotNet[".NET 9.0 WPF"]:::external
    end

    %% Configuration
    subgraph "Configuration"
        SLN["FrameSeal.sln"]:::external
        CSP["FrameSeal.csproj"]:::external
    end

    %% Relationships
    MW -->|"OpenImageCommand"| MVM
    MW -->|"SaveImageCommand"| MVM
    AppXcs -->|"Init View"| MW
    AppX -->|"Defines Resources"| AppXcs
    MVM -->|"LoadImage()"| FU
    MVM -->|"ProcessImage()"| IU
    MVM -->|"Bind Properties"| MW
    MVM -->|"Uses Preferences"| SM
    MVM -->|"ObservableObjects/Commands"| CT
    FU -->|"Read/Write Files"| FS
    IU -->|"InvokeMagick()"| Magick
    Magick -->|"Return Image"| IU
    IU -->|"FormatText()"| SS
    IU -->|"Apply Settings"| SM
    DotNet --> MW
    DotNet --> AppX
    DotNet --> MVM
    DotNet --> Core
    DotNet --> FU
    DotNet --> IU
    DotNet --> SM
    DotNet --> SS
    Core --> FU
    Core --> IU

    %% Click Events
    click AppX "https://github.com/garthtb/frameseal/blob/master/FrameSeal/App.xaml"
    click AppXcs "https://github.com/garthtb/frameseal/blob/master/FrameSeal/App.xaml.cs"
    click MW "https://github.com/garthtb/frameseal/blob/master/FrameSeal/Views/MainWindow.xaml"
    click MWcs "https://github.com/garthtb/frameseal/blob/master/FrameSeal/Views/MainWindow.xaml.cs"
    click MVM "https://github.com/garthtb/frameseal/blob/master/FrameSeal/ViewModels/MainViewModel.cs"
    click Core "https://github.com/garthtb/frameseal/blob/master/FrameSeal/Models/Core.cs"
    click FU "https://github.com/garthtb/frameseal/blob/master/FrameSeal/Models/FileUtils.cs"
    click IU "https://github.com/garthtb/frameseal/blob/master/FrameSeal/Models/ImageUtils.cs"
    click SM "https://github.com/garthtb/frameseal/blob/master/FrameSeal/Models/SettingsModel.cs"
    click SS "https://github.com/garthtb/frameseal/blob/master/FrameSeal/Models/StringUtils.cs"
    click CSP "https://github.com/garthtb/frameseal/blob/master/FrameSeal/FrameSeal.csproj"
    click SLN "https://github.com/garthtb/frameseal/blob/master/FrameSeal.sln"

    %% Styles
    classDef ui fill:#AED6F1,stroke:#3498DB,stroke-width:1px
    classDef vm fill:#A9DFBF,stroke:#27AE60,stroke-width:1px
    classDef model fill:#F9E79F,stroke:#F1C40F,stroke-width:1px
    classDef external fill:#D5D8DC,stroke:#7F8C8D,stroke-width:1px
```
