# mcmonkeyprojects/swarmui architecture

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

- Interactive diagram: https://gitdiagram.com/mcmonkeyprojects/swarmui
- Repository: https://github.com/mcmonkeyprojects/swarmui

## Overview

##### Main Components

a) Frontend Layer:
- Web Interface (ASP.NET Core based)
- Static Assets (wwwroot directory containing CSS, JS, and images)
- Multiple UI Themes
- Internationalization Support (languages directory)

b) Core Application Layer:
- Extension Management System
- Settings Management
- User/Session Management
- WebAPI Controllers
- Text2Image Engine Core

c) Backend Integration Layer:
- Abstract Backend Interface
- Multiple Backend Support:
- ComfyUI Backend
- AutoWebUI Backend
- Swarm Backend (for distributed processing)

d) Built-in Extensions:
- Grid Generator
- Image Batch Tool
- Scorers
- Dynamic Thresholding
- ComfyUI Integration

e) Data Storage:
- Model Management
- User Settings
- Session Data
- Presets Storage

##### Relationships and Data Flow

- User requests flowing from Frontend → WebAPI → Backend
- Image generation pipeline: Frontend → T2IEngine → Backend → Storage
- Extension system interactions with core components
- Model loading/management flow
- Authentication/Authorization flow

##### Implementation Details to Highlight

- ASP.NET Core based architecture
- Modular extension system
- Multiple backend support
- RESTful API structure
- WebSocket connections for real-time updates
- Docker container support

##### Storage/Infrastructure Layer (bottom)

Left → Right organization:
- Core components in center
- Extensions branching to right
- Backend systems to left
- Support services distributed appropriately

##### Additional Elements

- Version information
- Technologies used
- Optional components vs required components
- Scaling/deployment considerations

## Diagram (Mermaid)

```mermaid
graph TB
    subgraph Frontend
        WI["Web Interface"]:::frontend
        SA["Static Assets"]:::frontend
        TH["UI Themes"]:::frontend
        I18N["Internationalization"]:::frontend
    end

    subgraph Core
        WS["Web Server"]:::core
        EM["Extension Manager"]:::core
        SM["Settings Manager"]:::core
        T2IE["Text2Image Engine"]:::core
        MH["Model Handler"]:::core
        PT["Parameter Types"]:::core
    end

    subgraph UserManagement
        SH["Session Handler"]:::auth
        US["User System"]:::auth
        PM["Permissions"]:::auth
    end

    subgraph APILayer
        CAPI["Core API"]:::api
        MAPI["Models API"]:::api
        T2IAPI["Text2Image API"]:::api
        AAPI["Admin API"]:::api
    end

    subgraph BackendIntegration
        ABI["Abstract Backend Interface"]:::backend
        BH["Backend Handler"]:::backend
        CUI["ComfyUI Backend"]:::backend
        AWUI["AutoWebUI Backend"]:::backend
    end

    subgraph BuiltInExtensions
        GG["Grid Generator"]:::extension
        IBT["Image Batch Tool"]:::extension
        SC["Scorers"]:::extension
        DT["Dynamic Thresholding"]:::extension
    end

    subgraph Utils
        IU["Image Utils"]:::util
        WM["Webhook Manager"]:::util
        SMon["System Monitor"]:::util
        MM["Memory Management"]:::util
    end

    %% Relationships
    WI --> APILayer
    APILayer --> Core
    Core --> BackendIntegration
    Core --> BuiltInExtensions
    Core --> UserManagement
    Core --> Utils

    %% Click events
    click WI "https://github.com/mcmonkeyprojects/SwarmUI/tree/master/src/Pages"
    click SA "https://github.com/mcmonkeyprojects/SwarmUI/tree/master/src/wwwroot"
    click TH "https://github.com/mcmonkeyprojects/SwarmUI/tree/master/src/wwwroot/css/themes"
    click I18N "https://github.com/mcmonkeyprojects/SwarmUI/tree/master//languages"
    click EM "https://github.com/mcmonkeyprojects/SwarmUI/blob/master/src/Core/ExtensionsManager.cs"
    click SM "https://github.com/mcmonkeyprojects/SwarmUI/blob/master/src/Core/Settings.cs"
    click WS "https://github.com/mcmonkeyprojects/SwarmUI/blob/master/src/Core/WebServer.cs"
    click SH "https://github.com/mcmonkeyprojects/SwarmUI/blob/master/src/Accounts/SessionHandler.cs"
    click US "https://github.com/mcmonkeyprojects/SwarmUI/blob/master/src/Accounts/User.cs"
    click PM "https://github.com/mcmonkeyprojects/SwarmUI/blob/master/src/Accounts/Permissions.cs"
    click ABI "https://github.com/mcmonkeyprojects/SwarmUI/blob/master/src/Backends/AbstractT2IBackend.cs"
    click BH "https://github.com/mcmonkeyprojects/SwarmUI/blob/master/src/Backends/BackendHandler.cs"
    click CUI "https://github.com/mcmonkeyprojects/SwarmUI/tree/master/src/BuiltinExtensions/ComfyUIBackend"
    click AWUI "https://github.com/mcmonkeyprojects/SwarmUI/tree/master/src/BuiltinExtensions/AutoWebUIBackend"
    click T2IE "https://github.com/mcmonkeyprojects/SwarmUI/blob/master/src/Text2Image/T2IEngine.cs"
    click MH "https://github.com/mcmonkeyprojects/SwarmUI/blob/master/src/Text2Image/T2IModelHandler.cs"
    click PT "https://github.com/mcmonkeyprojects/SwarmUI/blob/master/src/Text2Image/T2IParamTypes.cs"
    click GG "https://github.com/mcmonkeyprojects/SwarmUI/tree/master/src/BuiltinExtensions/GridGenerator"
    click IBT "https://github.com/mcmonkeyprojects/SwarmUI/tree/master/src/BuiltinExtensions/ImageBatchTool"
    click SC "https://github.com/mcmonkeyprojects/SwarmUI/tree/master/src/BuiltinExtensions/Scorers"
    click DT "https://github.com/mcmonkeyprojects/SwarmUI/tree/master/src/BuiltinExtensions/DynamicThresholding"
    click CAPI "https://github.com/mcmonkeyprojects/SwarmUI/blob/master/src/WebAPI/API.cs"
    click MAPI "https://github.com/mcmonkeyprojects/SwarmUI/blob/master/src/WebAPI/ModelsAPI.cs"
    click T2IAPI "https://github.com/mcmonkeyprojects/SwarmUI/blob/master/src/WebAPI/T2IAPI.cs"
    click AAPI "https://github.com/mcmonkeyprojects/SwarmUI/blob/master/src/WebAPI/AdminAPI.cs"
    click IU "https://github.com/mcmonkeyprojects/SwarmUI/blob/master/src/Utils/Image.cs"
    click WM "https://github.com/mcmonkeyprojects/SwarmUI/blob/master/src/Utils/WebhookManager.cs"
    click SMon "https://github.com/mcmonkeyprojects/SwarmUI/blob/master/src/Utils/SystemStatusMonitor.cs"
    click MM "https://github.com/mcmonkeyprojects/SwarmUI/blob/master/src/Utils/MemCleaner.cs"

    %% Styling
    classDef frontend fill:#90EE90
    classDef core fill:#87CEEB
    classDef auth fill:#FF6B6B
    classDef api fill:#FFB347
    classDef backend fill:#DDA0DD
    classDef extension fill:#F0E68C
    classDef util fill:#B8860B

    %% Legend
    subgraph Legend
        F[Frontend]:::frontend
        C[Core]:::core
        A[Auth]:::auth
        AP[API]:::api
        B[Backend]:::backend
        E[Extension]:::extension
        U[Utility]:::util
    end
```
