# nirvash/illustra architecture

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

- Interactive diagram: https://gitdiagram.com/nirvash/illustra
- Repository: https://github.com/nirvash/illustra

## Overview

##### Main Components
- User Interface (UI) Layer:
- Views (in src/Views): MainWindow, ImageViewerWindow, property dialogs, custom controls (such as RatingStarControl, ZoomControl).
- ViewModels (in src/ViewModels): Main window, settings, file system tree, keyboard shortcuts, etc.
- XAML resources and themes (Dark.xaml, Light.xaml in src/Themes).
- Application/Domain Layer:
- Models (in src/Models and src/Shared/Models): Representing images, file nodes, settings, ratings, etc.
- Services and Helpers (in src/Services and src/Helpers): File operations, thumbnail processing, database access, drag & drop helpers, notifications, and UI helper classes.
- Converters and Extensions: Value converters (BooleanToColorConverter, etc.) and extension methods for file and image handling.
- Backend/API or Integration Layer:
- MCPHost component (in src/MCPHost): Contains controllers (such as McpController), APIService, Program.cs, Startup, and configuration files to provide web/API interfacing or external command handling.
- Persistence & Data Management:
- Database management classes (e.g., DatabaseAccess, DatabaseManager) and integration with SQLite-net for rating data persistence.
- External Dependencies:
- Third-party libraries (SkiaSharp, SixLabors.ImageSharp, pngcs, gong-wpf-dragdrop, VirtualizingWrapPanel, Extended.Wpf.Toolkit, MahApps.Metro, Prism, and Microsoft.Extensions.DependencyInjection) as seen in the README.
- Tests:
- Unit and integration tests (located in tests folder) which validate the components like MCPHost and application functionalities.

##### Relationships and Data Flow
- UI Components (Views/ViewModels) interact with the Domain Layer (Models and Services) to invoke business logic.
- Services (such as FileSystemMonitor, ThumbnailRequestQueue, ImagePropertiesService) retrieve image files/data and coordinate operations between Models and UI.
- The MCPHost component exposes API endpoints via its Controllers, which likely serve as a bridge between external commands and internal operations.
- The database layer (through classes like DatabaseManager) is used by services for persisting user ratings, settings, and possibly metadata.
- External libraries provide lower-level functions (image processing, drag/drop, virtualization) used within the services and controls.

##### Architectural Patterns & Design Principles
- MVVM Pattern:
- Clearly separate the presentation (Views) from business logic (ViewModels and Models).
- Use of Prism for MVVM, promoting maintainability and testability.
- Dependency Injection:
- Integration of Microsoft.Extensions.DependencyInjection to manage services and decouple dependencies.
- Modular Design:
- Separation of application logic (in src), API/integration (MCPHost), shared functionality (src/Shared), and testing (tests).
- External Service Integration:

- Clear textual and visual labels for every component.
- UI elements (Views/ViewModels),
- Business logic (Services/Helpers, Models),
- Integration/API components (MCPHost),
- Infrastructure/external dependencies (third-party libraries and database persistence).

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Presentation Layer
    subgraph "Presentation Layer"
        subgraph "Views"
            MainWindow["MainWindow.xaml"]:::ui
            ImageViewer["ImageViewerWindow.xaml"]:::ui
            RatingStar["RatingStarControl.xaml"]:::ui
            ZoomControl["ZoomControl.xaml"]:::ui
        end
        subgraph "ViewModels"
            MainVM["MainWindowViewModel.cs"]:::ui
            FolderVM["FolderViewModel.cs"]:::ui
        end
        subgraph "Themes"
            DarkTheme["Dark.xaml"]:::ui
            LightTheme["Light.xaml"]:::ui
        end
    end

    %% Business/Domain Layer
    subgraph "Business/Domain Layer"
        subgraph "Models"
            FileNode["FileNodeModel.cs"]:::domain
            ImagePropsModel["ImagePropertiesModel.cs"]:::domain
            AppSettings["AppSettingsModel.cs"]:::domain
            McpEvent["McpBaseEventArgs.cs"]:::domain
            ToolExecute["ToolExecuteRequest.cs"]:::domain
        end
        subgraph "Services & Helpers"
            ImgPropsService["ImagePropertiesService.cs"]:::domain
            LangService["LanguageService.cs"]:::domain
            DatabaseAccess["DatabaseAccess.cs"]:::domain
            DatabaseManager["DatabaseManager.cs"]:::domain
            DefaultThumbnail["DefaultThumbnailProcessor.cs"]:::domain
            DragDrop["DragDropHelper.cs"]:::domain
            FileOperation["FileOperationHelper.cs"]:::domain
            ThumbnailQueue["ThumbnailRequestQueue.cs"]:::domain
        end
        subgraph "Converters & Extensions"
            BoolToColor["BoolToColorConverter.cs"]:::domain
            BooleanToColor["BooleanToColorConverter.cs"]:::domain
            FileNodeExtensions["FileNodeModelExtensions.cs"]:::domain
        end
    end

    %% Integration/API Layer
    subgraph "Integration/API Layer"
        MCPHost["MCPHost"]:::integration
    end

    %% Infrastructure / External Dependencies
    subgraph "Infrastructure"
        Database["SQLite Database"]:::persistence
        ExternalLibs["Third-Party Libraries"]:::external
    end

    %% Tests Layer
    subgraph "Tests Layer"
        Tests["Tests"]:::tests
    end

    %% Data Flow Connections

    %% From Presentation to Domain
    MainWindow -->|"bindsTo"| MainVM
    RatingStar -->|"triggers"| MainVM
    ImageViewer -->|"displays"| MainVM
    ZoomControl -->|"interacts"| MainVM
    MainVM -->|"calls"| ImgPropsService
    FolderVM -->|"invokes"| FileOperation

    %% Domain Internal Connections
    ImgPropsService -->|"manages"| ImagePropsModel
    LangService -->|"updates"| AppSettings
    ImgPropsService -->|"uses"| DefaultThumbnail
    ImgPropsService -->|"queues"| ThumbnailQueue
    ImgPropsService -->|"utilizes"| DragDrop
    ImgPropsService -->|"performs"| FileOperation
    DatabaseAccess -->|"accesses"| DatabaseManager
    DatabaseManager -->|"persists"| Database
    MainVM -.->|"convertsData"| BoolToColor
    MainVM -.->|"convertsData"| BooleanToColor

    %% Integration/API Interaction with Domain
    MCPHost -->|"exposesAPI"| ImgPropsService
    MCPHost -->|"exposesAPI"| LangService

    %% External Dependencies
    ExternalLibs -->|"supports"| ImgPropsService
    ExternalLibs -->|"enhances"| RatingStar

    %% Themes Applied
    DarkTheme -->|"appliedTo"| MainWindow
    LightTheme -->|"appliedTo"| MainWindow

    %% Tests Connections
    Tests -->|"tests"| MCPHost
    Tests -->|"tests"| ImgPropsService
    Tests -->|"tests"| LangService

    %% Click Events
    click MainWindow "https://github.com/nirvash/illustra/blob/master/src/Views/MainWindow.xaml"
    click ImageViewer "https://github.com/nirvash/illustra/blob/master/src/Views/ImageViewerWindow.xaml"
    click RatingStar "https://github.com/nirvash/illustra/blob/master/src/Views/RatingStarControl.xaml"
    click ZoomControl "https://github.com/nirvash/illustra/blob/master/src/Views/ZoomControl.xaml"
    click MainVM "https://github.com/nirvash/illustra/blob/master/src/ViewModels/MainWindowViewModel.cs"
    click FolderVM "https://github.com/nirvash/illustra/blob/master/src/ViewModels/FolderViewModel.cs"
    click DarkTheme "https://github.com/nirvash/illustra/blob/master/src/Themes/Dark.xaml"
    click LightTheme "https://github.com/nirvash/illustra/blob/master/src/Themes/Light.xaml"
    click FileNode "https://github.com/nirvash/illustra/blob/master/src/Models/FileNodeModel.cs"
    click ImagePropsModel "https://github.com/nirvash/illustra/blob/master/src/Models/ImagePropertiesModel.cs"
    click AppSettings "https://github.com/nirvash/illustra/blob/master/src/Models/AppSettingsModel.cs"
    click McpEvent "https://github.com/nirvash/illustra/blob/master/src/Shared/Models/McpBaseEventArgs.cs"
    click ToolExecute "https://github.com/nirvash/illustra/blob/master/src/Shared/Models/ToolExecuteRequest.cs"
    click ImgPropsService "https://github.com/nirvash/illustra/blob/master/src/Services/ImagePropertiesService.cs"
    click LangService "https://github.com/nirvash/illustra/blob/master/src/Services/LanguageService.cs"
    click DatabaseAccess "https://github.com/nirvash/illustra/blob/master/src/Helpers/DatabaseAccess.cs"
    click DatabaseManager "https://github.com/nirvash/illustra/blob/master/src/Helpers/DatabaseManager.cs"
    click DefaultThumbnail "https://github.com/nirvash/illustra/blob/master/src/Helpers/DefaultThumbnailProcessor.cs"
    click DragDrop "https://github.com/nirvash/illustra/blob/master/src/Helpers/DragDropHelper.cs"
    click FileOperation "https://github.com/nirvash/illustra/blob/master/src/Helpers/FileOperationHelper.cs"
    click ThumbnailQueue "https://github.com/nirvash/illustra/blob/master/src/Helpers/ThumbnailRequestQueue.cs"
    click BoolToColor "https://github.com/nirvash/illustra/blob/master/src/Converters/BoolToColorConverter.cs"
    click BooleanToColor "https://github.com/nirvash/illustra/blob/master/src/Converters/BooleanToColorConverter.cs"
    click FileNodeExtensions "https://github.com/nirvash/illustra/blob/master/src/Extensions/FileNodeModelExtensions.cs"
    click MCPHost "https://github.com/nirvash/illustra/tree/master/src/MCPHost"
    click Tests "https://github.com/nirvash/illustra/tree/master/tests"

    %% Styles
    classDef ui fill:#F9E79F,stroke:#BB8F00,stroke-width:2px;
    classDef domain fill:#AED6F1,stroke:#2874A6,stroke-width:2px;
    classDef integration fill:#A9DFBF,stroke:#1E8449,stroke-width:2px;
    classDef persistence fill:#F5CBA7,stroke:#D35400,stroke-width:2px;
    classDef tests fill:#D2B4DE,stroke:#8E44AD,stroke-width:2px;
    classDef external fill:#E8DAEF,stroke:#AF7AC5,stroke-width:2px;
```
