# luxxxonly/stable-diffusion-webui architecture

> Architecture diagram of the GitHub repository luxxxonly/stable-diffusion-webui, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-10-02). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/luxxxonly/stable-diffusion-webui
- Repository: https://github.com/luxxxonly/stable-diffusion-webui

## Overview

Stable Diffusion web UI is a Gradio application for generating and editing images, with an API and extensible model tooling. Its main workflow takes a user request through a generation entry point, model and sampler configuration, then produces images with generation metadata. The README also documents editing, training, restoration, upscaling, and model-adaptation capabilities. Edges use README statements or SOURCE INDEX references; unsampled subsystems are represented where documented, without asserting unshown internal calls.

Main entry points: [`modules/processing.py`](https://github.com/luxxxonly/stable-diffusion-webui/blob/master/modules/processing.py) (Generation Processing), [`modules/ui.py`](https://github.com/luxxxonly/stable-diffusion-webui/blob/master/modules/ui.py) (Gradio UI), [`modules/sd_hijack.py`](https://github.com/luxxxonly/stable-diffusion-webui/blob/master/modules/sd_hijack.py) (Model Integration), [`modules/postprocessing.py`](https://github.com/luxxxonly/stable-diffusion-webui/blob/master/modules/postprocessing.py) (Image Postprocessing)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_experience["User Experience"]
  node_webui["Gradio UI<br/>[ui.py]"]
  node_api["HTTP API<br/>[api.py]"]
  node_scripts["Script Extensions<br/>[scripts.py]"]
  node_settings["Settings and State<br/>[shared.py]"]
end

subgraph group_generation["Generation Runtime"]
  node_txtimg["txt2img / img2img<br/>[txt2img.py]"]
  node_processing["Generation Processing<br/>[processing.py]"]
  node_prompt["Prompt Parsing<br/>[prompt_parser.py]"]
  node_samplers["Sampler Selection<br/>[sd_samplers.py]"]
  node_images["Image Output<br/>[images.py]"]
  node_infotext["Generation Metadata<br/>[infotext_utils.py]"]
end

subgraph group_models["Models and Conditioning"]
  node_checkpoints["Checkpoint Loading<br/>[sd_models.py]"]
  node_hijack["Model Integration<br/>[sd_hijack.py]"]
  node_vae["VAE Management<br/>[sd_vae.py]"]
  node_devices["Device Support<br/>[devices.py]"]
  node_textual["Textual Inversion"]
  node_hyper["Hypernetworks<br/>[hypernetwork.py]"]
  node_lora["LoRA Networks<br/>[networks.py]"]
end

subgraph group_capabilities["Extended Capabilities"]
  node_postprocess["Image Postprocessing<br/>[postprocessing.py]"]
  node_upscalers["Upscalers<br/>[upscaler.py]"]
  node_restoration["Face Restoration"]
  node_training["Embedding Training"]
end

node_user(("User"))

node_user -->|"uses"| node_webui
node_user -->|"requests generation"| node_api
node_webui -->|"selects mode"| node_txtimg
node_api -->|"serves generation"| node_processing
node_txtimg -.->|"starts processing"| node_processing
node_processing -->|"uses prompt parsing"| node_prompt
node_processing -->|"uses samplers"| node_samplers
node_processing -->|"uses model loading"| node_checkpoints
node_processing -->|"uses model hooks"| node_hijack
node_processing -->|"uses devices"| node_devices
node_processing -->|"uses VAE"| node_vae
node_processing -->|"produces images"| node_images
node_images -->|"stores parameters"| node_infotext
node_hijack -->|"integrates embeddings"| node_textual
node_hijack -->|"integrates hypernetworks"| node_hyper
node_processing -->|"supports LoRA"| node_lora
node_scripts -->|"extends processing"| node_processing
node_webui -->|"exposes settings"| node_settings
node_user -->|"requests extras"| node_postprocess
node_postprocess -->|"offers upscaling"| node_upscalers
node_postprocess -->|"offers restoration"| node_restoration
node_user -->|"trains embeddings"| node_training
node_training -->|"creates embeddings"| node_textual

click node_webui "https://github.com/luxxxonly/stable-diffusion-webui/blob/master/modules/ui.py"
click node_api "https://github.com/luxxxonly/stable-diffusion-webui/blob/master/modules/api/api.py"
click node_scripts "https://github.com/luxxxonly/stable-diffusion-webui/blob/master/modules/scripts.py"
click node_txtimg "https://github.com/luxxxonly/stable-diffusion-webui/blob/master/modules/txt2img.py"
click node_processing "https://github.com/luxxxonly/stable-diffusion-webui/blob/master/modules/processing.py"
click node_prompt "https://github.com/luxxxonly/stable-diffusion-webui/blob/master/modules/prompt_parser.py"
click node_samplers "https://github.com/luxxxonly/stable-diffusion-webui/blob/master/modules/sd_samplers.py"
click node_images "https://github.com/luxxxonly/stable-diffusion-webui/blob/master/modules/images.py"
click node_infotext "https://github.com/luxxxonly/stable-diffusion-webui/blob/master/modules/infotext_utils.py"
click node_checkpoints "https://github.com/luxxxonly/stable-diffusion-webui/blob/master/modules/sd_models.py"
click node_hijack "https://github.com/luxxxonly/stable-diffusion-webui/blob/master/modules/sd_hijack.py"
click node_vae "https://github.com/luxxxonly/stable-diffusion-webui/blob/master/modules/sd_vae.py"
click node_devices "https://github.com/luxxxonly/stable-diffusion-webui/blob/master/modules/devices.py"
click node_textual "https://github.com/luxxxonly/stable-diffusion-webui/blob/master/modules/textual_inversion/textual_inversion.py"
click node_hyper "https://github.com/luxxxonly/stable-diffusion-webui/blob/master/modules/hypernetworks/hypernetwork.py"
click node_lora "https://github.com/luxxxonly/stable-diffusion-webui/blob/master/extensions-builtin/Lora/networks.py"
click node_postprocess "https://github.com/luxxxonly/stable-diffusion-webui/blob/master/modules/postprocessing.py"
click node_upscalers "https://github.com/luxxxonly/stable-diffusion-webui/blob/master/modules/upscaler.py"
click node_restoration "https://github.com/luxxxonly/stable-diffusion-webui/blob/master/modules/face_restoration.py"
click node_training "https://github.com/luxxxonly/stable-diffusion-webui/blob/master/modules/textual_inversion/textual_inversion.py"
click node_settings "https://github.com/luxxxonly/stable-diffusion-webui/blob/master/modules/shared.py"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_webui,node_api,node_scripts,node_settings,node_user toneBlue
class node_txtimg,node_processing,node_prompt,node_samplers,node_images,node_infotext toneAmber
class node_checkpoints,node_hijack,node_vae,node_devices,node_textual,node_hyper,node_lora toneMint
class node_postprocess,node_upscalers,node_restoration,node_training toneRose
```

## Components

### User Experience

- [Gradio UI](https://github.com/luxxxonly/stable-diffusion-webui/blob/master/modules/ui.py): `modules/ui.py`
- [HTTP API](https://github.com/luxxxonly/stable-diffusion-webui/blob/master/modules/api/api.py): `modules/api/api.py`
- [Script Extensions](https://github.com/luxxxonly/stable-diffusion-webui/blob/master/modules/scripts.py): `modules/scripts.py`
- [Settings and State](https://github.com/luxxxonly/stable-diffusion-webui/blob/master/modules/shared.py): `modules/shared.py`

### Generation Runtime

- [txt2img / img2img](https://github.com/luxxxonly/stable-diffusion-webui/blob/master/modules/txt2img.py): `modules/txt2img.py`
- [Generation Processing](https://github.com/luxxxonly/stable-diffusion-webui/blob/master/modules/processing.py): `modules/processing.py`
- [Prompt Parsing](https://github.com/luxxxonly/stable-diffusion-webui/blob/master/modules/prompt_parser.py): `modules/prompt_parser.py`
- [Sampler Selection](https://github.com/luxxxonly/stable-diffusion-webui/blob/master/modules/sd_samplers.py): `modules/sd_samplers.py`
- [Image Output](https://github.com/luxxxonly/stable-diffusion-webui/blob/master/modules/images.py): `modules/images.py`
- [Generation Metadata](https://github.com/luxxxonly/stable-diffusion-webui/blob/master/modules/infotext_utils.py): `modules/infotext_utils.py`

### Models and Conditioning

- [Checkpoint Loading](https://github.com/luxxxonly/stable-diffusion-webui/blob/master/modules/sd_models.py): `modules/sd_models.py`
- [Model Integration](https://github.com/luxxxonly/stable-diffusion-webui/blob/master/modules/sd_hijack.py): `modules/sd_hijack.py`
- [VAE Management](https://github.com/luxxxonly/stable-diffusion-webui/blob/master/modules/sd_vae.py): `modules/sd_vae.py`
- [Device Support](https://github.com/luxxxonly/stable-diffusion-webui/blob/master/modules/devices.py): `modules/devices.py`
- [Textual Inversion](https://github.com/luxxxonly/stable-diffusion-webui/blob/master/modules/textual_inversion/textual_inversion.py): `modules/textual_inversion/textual_inversion.py`
- [Hypernetworks](https://github.com/luxxxonly/stable-diffusion-webui/blob/master/modules/hypernetworks/hypernetwork.py): `modules/hypernetworks/hypernetwork.py`
- [LoRA Networks](https://github.com/luxxxonly/stable-diffusion-webui/blob/master/extensions-builtin/Lora/networks.py): `extensions-builtin/Lora/networks.py`

### Extended Capabilities

- [Image Postprocessing](https://github.com/luxxxonly/stable-diffusion-webui/blob/master/modules/postprocessing.py): `modules/postprocessing.py`
- [Upscalers](https://github.com/luxxxonly/stable-diffusion-webui/blob/master/modules/upscaler.py): `modules/upscaler.py`
- [Face Restoration](https://github.com/luxxxonly/stable-diffusion-webui/blob/master/modules/face_restoration.py): `modules/face_restoration.py`
- [Embedding Training](https://github.com/luxxxonly/stable-diffusion-webui/blob/master/modules/textual_inversion/textual_inversion.py): `modules/textual_inversion/textual_inversion.py`

### Other components

- **User**

## Connections

- User → Gradio UI: uses (evidence: `README.md`)
- User → HTTP API: requests generation (evidence: `README.md`)
- Gradio UI → txt2img / img2img: selects mode (evidence: `README.md`)
- HTTP API → Generation Processing: serves generation (evidence: `modules/api/api.py`)
- txt2img / img2img → Generation Processing: starts processing
- Generation Processing → Prompt Parsing: uses prompt parsing (evidence: `modules/processing.py`)
- Generation Processing → Sampler Selection: uses samplers (evidence: `modules/processing.py`)
- Generation Processing → Checkpoint Loading: uses model loading (evidence: `modules/processing.py`)
- Generation Processing → Model Integration: uses model hooks (evidence: `modules/processing.py`)
- Generation Processing → Device Support: uses devices (evidence: `modules/processing.py`)
- Generation Processing → VAE Management: uses VAE (evidence: `modules/processing.py`)
- Generation Processing → Image Output: produces images (evidence: `modules/processing.py`)
- Image Output → Generation Metadata: stores parameters (evidence: `README.md`)
- Model Integration → Textual Inversion: integrates embeddings (evidence: `modules/sd_hijack.py`)
- Model Integration → Hypernetworks: integrates hypernetworks (evidence: `modules/sd_hijack.py`)
- Generation Processing → LoRA Networks: supports LoRA (evidence: `modules/processing.py`)
- Script Extensions → Generation Processing: extends processing (evidence: `modules/scripts.py`)
- Gradio UI → Settings and State: exposes settings (evidence: `modules/ui.py`)
- User → Image Postprocessing: requests extras (evidence: `README.md`)
- Image Postprocessing → Upscalers: offers upscaling (evidence: `README.md`)
- Image Postprocessing → Face Restoration: offers restoration (evidence: `README.md`)
- User → Embedding Training: trains embeddings (evidence: `README.md`)
- Embedding Training → Textual Inversion: creates embeddings (evidence: `modules/textual_inversion/textual_inversion.py`)
