# divamgupta/diffusionbee-stable-diffusion-ui architecture

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

- Interactive diagram: https://gitdiagram.com/divamgupta/diffusionbee-stable-diffusion-ui
- Repository: https://github.com/divamgupta/diffusionbee-stable-diffusion-ui

## Overview

##### Main Components Overview

a) Frontend (Electron App)
- Located in /electron_app
- Vue.js-based UI components
- Native bridge interfaces

b) Backend Services
- Model Converter (/backends/model_converter)
- Stable Diffusion Implementation (/backends/stable_diffusion)
- TensorFlow Models (/backends/stable_diffusion_tf_models)

c) Plugin System
- Located in /backends/stable_diffusion/stable_diffusion/plugins
- Handles various AI features (ControlNet, Inpainting, etc.)

- Electron App  |
- (Vue.js UI)   |

- Native Bridge   |
- (Python <-> JS)  |

- Model         |  | Stable Diffusion |  | TensorFlow  |
- Converter     |  | Backend         |  | Models      |

##### Component Details

Frontend Components:
- Main application pages (txt2img, img2img, inpainting)
- Asset management
- Model store interface
- Generation history
- Settings management

Backend Services:
- Model conversion pipeline
- Stable Diffusion core
- Scheduler system
- Plugin architecture
- Control processors
- CLIP tokenizer

##### Data Flow Indicators

- User input flow (UI → Backend)
- Image generation pipeline
- Model loading/conversion paths
- Plugin integration points

##### Technical Details to Note

Annotations for:
- Supported model types (SD 1.x, 2.x, SDXL)
- Platform-specific optimizations (M1/Intel)
- Key dependencies
- File format handling

##### Local processing nature of the application

Keep the abstraction level high enough to be understandable but detailed enough to show the sophisticated nature of the application's architecture, particularly its plugin system and model handling capabilities.

Remember to highlight the privacy-focused architecture where all processing happens locally, as this is a key feature of the application.

## Diagram (Mermaid)

```mermaid
graph TB
    subgraph Frontend
        EA["Electron App"]:::frontend
        click EA "https://github.com/divamgupta/diffusionbee-stable-diffusion-ui/tree/master/electron_app/src/"
        
        subgraph MainPages
            T2I["Text to Image"]:::page
            click T2I "https://github.com/divamgupta/diffusionbee-stable-diffusion-ui/blob/master/electron_app/src/pages/Txt2Img.vue"
            I2I["Image to Image"]:::page
            click I2I "https://github.com/divamgupta/diffusionbee-stable-diffusion-ui/blob/master/electron_app/src/pages/Img2Img.vue"
            INP["Inpainting"]:::page
            click INP "https://github.com/divamgupta/diffusionbee-stable-diffusion-ui/blob/master/electron_app/src/pages/Inpainting.vue"
            MS["Model Store"]:::page
            click MS "https://github.com/divamgupta/diffusionbee-stable-diffusion-ui/blob/master/electron_app/src/pages/ModelStore.vue"
            SET["Settings"]:::page
            click SET "https://github.com/divamgupta/diffusionbee-stable-diffusion-ui/blob/master/electron_app/src/pages/Settings.vue"
        end
        
        AM["Asset Manager"]:::component
        click AM "https://github.com/divamgupta/diffusionbee-stable-diffusion-ui/blob/master/electron_app/src/AssetsManager.vue"
        UI["UI Components"]:::component
        click UI "https://github.com/divamgupta/diffusionbee-stable-diffusion-ui/tree/master/electron_app/src/components/"
    end

    subgraph Bridge
        NB["Native Bridge"]:::bridge
        click NB "https://github.com/divamgupta/diffusionbee-stable-diffusion-ui/blob/master/electron_app/src/py_vue_bridge.js"
        SDB["SD Bridge"]:::bridge
        click SDB "https://github.com/divamgupta/diffusionbee-stable-diffusion-ui/blob/master/electron_app/src/stable_diffusion_bridge.js"
        NF["Native Functions"]:::bridge
        click NF "https://github.com/divamgupta/diffusionbee-stable-diffusion-ui/blob/master/electron_app/src/native_functions.js"
    end

    subgraph Backend
        subgraph ModelServices
            MC["Model Converter"]:::model
            click MC "https://github.com/divamgupta/diffusionbee-stable-diffusion-ui/tree/master/backends/model_converter/"
            TFM["TensorFlow Models"]:::model
            click TFM "https://github.com/divamgupta/diffusionbee-stable-diffusion-ui/tree/master/backends/stable_diffusion_tf_models/"
            
            subgraph TFComponents
                DM["Diffusion Model"]:::model
                click DM "https://github.com/divamgupta/diffusionbee-stable-diffusion-ui/blob/master/backends/stable_diffusion_tf_models/diffusion_model.py"
                CE["CLIP Encoder"]:::model
                click CE "https://github.com/divamgupta/diffusionbee-stable-diffusion-ui/blob/master/backends/stable_diffusion_tf_models/clip_encoder.py"
                AE["Autoencoder"]:::model
                click AE "https://github.com/divamgupta/diffusionbee-stable-diffusion-ui/blob/master/backends/stable_diffusion_tf_models/autoencoder_kl.py"
            end
        end

        subgraph StableDiffusion
            SDC["SD Core"]:::core
            click SDC "https://github.com/divamgupta/diffusionbee-stable-diffusion-ui/tree/master/backends/stable_diffusion/stable_diffusion/"
            
            subgraph Plugins
                PS["Plugin System"]:::plugin
                click PS "https://github.com/divamgupta/diffusionbee-stable-diffusion-ui/blob/master/backends/stable_diffusion/stable_diffusion/plugins/plugin_system.py"
                CN["ControlNet"]:::plugin
                click CN "https://github.com/divamgupta/diffusionbee-stable-diffusion-ui/blob/master/backends/stable_diffusion/stable_diffusion/plugins/controlnet.py"
                IP["Inpainting"]:::plugin
                click IP "https://github.com/divamgupta/diffusionbee-stable-diffusion-ui/blob/master/backends/stable_diffusion/stable_diffusion/plugins/inpainting.py"
            end

            subgraph CoreComponents
                CT["CLIP Tokenizer"]:::component
                click CT "https://github.com/divamgupta/diffusionbee-stable-diffusion-ui/tree/master/backends/stable_diffusion/stable_diffusion/clip_tokenizer/"
                SCH["Schedulers"]:::component
                click SCH "https://github.com/divamgupta/diffusionbee-stable-diffusion-ui/tree/master/backends/stable_diffusion/stable_diffusion/schedulers/"
                CP["Control Processors"]:::component
                click CP "https://github.com/divamgupta/diffusionbee-stable-diffusion-ui/tree/master/backends/stable_diffusion/stable_diffusion/control_processors/"
            end
        end
    end

    %% Frontend Connections
    EA --> T2I & I2I & INP & MS & SET
    EA --> AM
    EA --> UI

    %% Bridge Connections
    EA --> NB
    EA --> SDB
    EA --> NF
    NB --> SDC
    SDB --> SDC
    NF --> SDC

    %% Backend Connections
    MC --> TFM
    TFM --> DM & CE & AE
    SDC --> PS
    PS --> CN & IP
    SDC --> CT & SCH & CP
    SDC --> TFM

    %% Styles
    classDef frontend fill:#3498db,stroke:#2980b9,color:white
    classDef page fill:#2ecc71,stroke:#27ae60,color:white
    classDef component fill:#e74c3c,stroke:#c0392b,color:white
    classDef bridge fill:#9b59b6,stroke:#8e44ad,color:white
    classDef model fill:#f1c40f,stroke:#f39c12,color:black
    classDef core fill:#1abc9c,stroke:#16a085,color:white
    classDef plugin fill:#e67e22,stroke:#d35400,color:white

    %% Legend
    subgraph Legend
        L1["Frontend Component"]:::frontend
        L2["Page Component"]:::page
        L3["UI Component"]:::component
        L4["Bridge Component"]:::bridge
        L5["Model Component"]:::model
        L6["Core Component"]:::core
        L7["Plugin Component"]:::plugin
    end
```
