# cocktailpeanut/fluxgym architecture

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

- Interactive diagram: https://gitdiagram.com/cocktailpeanut/fluxgym
- Repository: https://github.com/cocktailpeanut/fluxgym

## Overview

Key Components to Include:

##### User Interface Layer
- Main UI features:
- Image/Caption Upload Interface
- Training Configuration Panel
- Advanced Settings Panel
- Sample Image Generation Interface
- Huggingface Publishing Interface

##### Application Layer
- It to both UI and processing layers
- Configuration management system for:
- Model settings
- Training parameters
- Huggingface integration

##### Processing Layer
- Kohya Scripts Integration component
- Training Pipeline component
- Sample Generation Engine
- Model Management System

##### Storage Layer
- Model Storage (models/ directory with subdirectories for clip, unet, vae)
- Output Storage (outputs/ directory)
- Configuration Storage (models.yaml)

##### External Services
- Huggingface Hub Integration
- PyTorch/CUDA Runtime
- Docker Container Environment

- [Web UI Layer]
- ↕
- [Application Layer]
- ↕
- [Processing Layer]
- ↕
- [Storage Layer]

##### Connection Types
- Double lines: File system interactions

Special Considerations:

##### VRAM Management
- A special section showing memory optimization for different VRAM sizes (12GB/16GB/20GB)
- How the system manages model loading and unloading

##### Docker Integration
- A container boundary around the main components
- Volume mappings for models and outputs
- Environment variable configurations

##### Training Pipeline
- Detail the flow from image upload to trained model
- Sample generation integration points
- Where model checkpointing occurs

##### Automation Features
- Auto-download mechanism for models
- Automatic sample generation workflow
- Huggingface publishing pipeline

- Symbols for different types of data flow
- Component type indicators
- VRAM configuration options
- Document Docker-specific elements

Additional Notes:
##### Keep the ma
- Training pipeline details
- Sample generation workflow
- Model management system
- Huggingface integration flow

- Low VRAM support
- Extensibility through Kohya Scripts
- Automated model management
- Simple yet powerful UI
- Docker container support
- Huggingface integration

## Diagram (Mermaid)

```mermaid
graph TB
    %% Styles
    classDef ui fill:#3498db,stroke:#2980b9,color:white
    classDef app fill:#2ecc71,stroke:#27ae60,color:white
    classDef process fill:#e74c3c,stroke:#c0392b,color:white
    classDef storage fill:#f1c40f,stroke:#f39c12,color:black
    classDef external fill:#9b59b6,stroke:#8e44ad,color:white
    classDef infra fill:#95a5a6,stroke:#7f8c8d,color:white

    %% User Interface Layer
    subgraph UI
        WebUI["Gradio Web UI"]:::ui
        Upload["Image/Caption Upload"]:::ui
        Config["Training Configuration"]:::ui
        Advanced["Advanced Settings"]:::ui
        Sample["Sample Generation UI"]:::ui
        HFPublish["Huggingface Publishing UI"]:::ui
    end

    %% Application Layer
    subgraph AppLayer
        AppServer["Application Server"]:::app
        ConfigMgmt["Configuration Management"]:::app
        AutoScripts["Automation Scripts"]:::app
    end

    %% Processing Layer
    subgraph Processing
        KohyaInt["Kohya Scripts Integration"]:::process
        TrainPipe["Training Pipeline"]:::process
        SampleGen["Sample Generation Engine"]:::process
        ModelMgmt["Model Management System"]:::process
        VRAMMgmt["VRAM Optimization"]:::process
    end

    %% Storage Layer
    subgraph Storage
        ModelStore["Model Storage"]:::storage
        OutputStore["Output Storage"]:::storage
        ConfigStore["Configuration Storage"]:::storage
        CLIP["CLIP Models"]:::storage
        UNET["UNET Models"]:::storage
        VAE["VAE Models"]:::storage
    end

    %% External Services
    subgraph External
        HFHub["Huggingface Hub"]:::external
        PyTorch["PyTorch/CUDA Runtime"]:::external
        Docker["Docker Container"]:::external
    end

    %% Connections
    WebUI --> Upload
    WebUI --> Config
    WebUI --> Advanced
    WebUI --> Sample
    WebUI --> HFPublish
    
    Upload --> AppServer
    Config --> AppServer
    Advanced --> AppServer
    Sample --> AppServer
    HFPublish --> AppServer
    
    AppServer --> ConfigMgmt
    AppServer --> KohyaInt
    ConfigMgmt --> TrainPipe
    
    KohyaInt --> TrainPipe
    TrainPipe --> SampleGen
    TrainPipe --> ModelMgmt
    ModelMgmt --> VRAMMgmt
    
    ModelMgmt --> ModelStore
    ModelStore --> CLIP
    ModelStore --> UNET
    ModelStore --> VAE
    TrainPipe --> OutputStore
    ConfigMgmt --> ConfigStore
    
    HFPublish --> HFHub
    TrainPipe --> PyTorch
    Docker --> AppServer

    %% Click Events
    click AppServer "https://github.com/cocktailpeanut/fluxgym/blob/main/app.py"
    click ConfigStore "https://github.com/cocktailpeanut/fluxgym/blob/main/models.yaml"
    click ModelStore "https://github.com/cocktailpeanut/fluxgym/tree/main/models/"
    click CLIP "https://github.com/cocktailpeanut/fluxgym/tree/main/models/clip/"
    click UNET "https://github.com/cocktailpeanut/fluxgym/tree/main/models/unet/"
    click VAE "https://github.com/cocktailpeanut/fluxgym/tree/main/models/vae/"
    click OutputStore "https://github.com/cocktailpeanut/fluxgym/tree/main/outputs/"
    click Docker "https://github.com/cocktailpeanut/fluxgym/tree/main/Dockerfile"
    click AutoScripts "https://github.com/cocktailpeanut/fluxgym/blob/main/install.js"

    %% Legend
    subgraph Legend
        UI_L["UI Component"]:::ui
        App_L["Application Component"]:::app
        Process_L["Processing Component"]:::process
        Storage_L["Storage Component"]:::storage
        External_L["External Service"]:::external
        Infra_L["Infrastructure"]:::infra
    end
```
