# automatic1111/stable-diffusion-webui architecture

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

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

## Overview

Stable Diffusion web UI is a Gradio application for generating and editing images, with an API and extensible scripts. The main user journey is entering prompts and generation settings, running txt2img or img2img, then viewing or saving images with generation metadata. The graph also preserves documented model, sampler, restoration, upscaling, training, and extension capabilities. Several subsystem paths come from the tree and README rather than inspected implementation; edges are limited to documented behavior or relationships listed in the source index.

Main entry points: [`modules/processing.py`](https://github.com/automatic1111/stable-diffusion-webui/blob/master/modules/processing.py) (Processing pipeline), [`modules/ui.py`](https://github.com/automatic1111/stable-diffusion-webui/blob/master/modules/ui.py) (Gradio UI), [`modules/api/api.py`](https://github.com/automatic1111/stable-diffusion-webui/blob/master/modules/api/api.py) (Generation API), [`modules/sd_models.py`](https://github.com/automatic1111/stable-diffusion-webui/blob/master/modules/sd_models.py) (Checkpoint loading)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_interface["User interfaces"]
  node_webui["Gradio UI<br/>[ui.py]"]
  node_api["Generation API<br/>[api.py]"]
  node_metadata["Image parameters<br/>[infotext_utils.py]"]
end

subgraph group_generation["Image generation"]
  node_txtimg["Text-to-image<br/>[txt2img.py]"]
  node_img2img["Image-to-image<br/>[img2img.py]"]
  node_processing["Processing pipeline<br/>[processing.py]"]
  node_samplers["Samplers<br/>[sd_samplers.py]"]
  node_images["Image handling<br/>[images.py]"]
end

subgraph group_models["Models and conditioning"]
  node_checkpoint["Checkpoint loading<br/>[sd_models.py]"]
  node_vae["VAE loading<br/>[sd_vae.py]"]
  node_hijack["Model conditioning<br/>[sd_hijack.py]"]
  node_devices["Device support<br/>[devices.py]"]
end

subgraph group_capabilities["Extensions and tools"]
  node_textual["Textual inversion"]
  node_hypernet["Hypernetworks<br/>[hypernetwork.py]"]
  node_lora["LoRA networks<br/>[networks.py]"]
  node_extras["Extras processing<br/>[extras.py]"]
  node_postprocessing["Postprocessing<br/>[postprocessing.py]"]
  node_training["Embedding training"]
  node_scripts["Custom scripts<br/>[scripts.py]"]
  node_upscalers["Upscalers<br/>[upscaler.py]"]
end

node_user(("User"))

node_user -->|"sets options"| node_webui
node_user -->|"requests generation"| node_api
node_processing -->|"uses samplers"| node_samplers
node_processing -->|"uses conditioning"| node_hijack
node_processing -->|"uses devices"| node_devices
node_processing -->|"applies networks"| node_textual
node_checkpoint -->|"loads VAE"| node_vae
node_checkpoint -->|"uses devices"| node_devices
node_checkpoint -->|"coordinates reloads"| node_processing
node_hijack -->|"uses embeddings"| node_textual
node_hijack -->|"uses hypernetworks"| node_hypernet
node_textual -->|"uses image tools"| node_images
node_api -->|"uses samplers"| node_samplers
node_api -->|"uses image tools"| node_images
node_api -->|"invokes postprocessing"| node_postprocessing
node_webui -->|"loads scripts"| node_scripts
node_webui -->|"supports checkpoint selection"| node_checkpoint
node_webui -->|"offers Extras"| node_extras
node_extras -->|"offers upscaling"| node_upscalers
node_user -->|"trains embeddings"| node_training
node_images -->|"reads image parameters"| node_metadata
node_user -->|"generates images"| node_txtimg
node_user -->|"edits images"| node_img2img
node_user -->|"uses LoRAs"| node_lora

click node_webui "https://github.com/automatic1111/stable-diffusion-webui/blob/master/modules/ui.py"
click node_api "https://github.com/automatic1111/stable-diffusion-webui/blob/master/modules/api/api.py"
click node_metadata "https://github.com/automatic1111/stable-diffusion-webui/blob/master/modules/infotext_utils.py"
click node_txtimg "https://github.com/automatic1111/stable-diffusion-webui/blob/master/modules/txt2img.py"
click node_img2img "https://github.com/automatic1111/stable-diffusion-webui/blob/master/modules/img2img.py"
click node_processing "https://github.com/automatic1111/stable-diffusion-webui/blob/master/modules/processing.py"
click node_samplers "https://github.com/automatic1111/stable-diffusion-webui/blob/master/modules/sd_samplers.py"
click node_images "https://github.com/automatic1111/stable-diffusion-webui/blob/master/modules/images.py"
click node_checkpoint "https://github.com/automatic1111/stable-diffusion-webui/blob/master/modules/sd_models.py"
click node_vae "https://github.com/automatic1111/stable-diffusion-webui/blob/master/modules/sd_vae.py"
click node_hijack "https://github.com/automatic1111/stable-diffusion-webui/blob/master/modules/sd_hijack.py"
click node_devices "https://github.com/automatic1111/stable-diffusion-webui/blob/master/modules/devices.py"
click node_textual "https://github.com/automatic1111/stable-diffusion-webui/blob/master/modules/textual_inversion/textual_inversion.py"
click node_hypernet "https://github.com/automatic1111/stable-diffusion-webui/blob/master/modules/hypernetworks/hypernetwork.py"
click node_lora "https://github.com/automatic1111/stable-diffusion-webui/blob/master/extensions-builtin/Lora/networks.py"
click node_extras "https://github.com/automatic1111/stable-diffusion-webui/blob/master/modules/extras.py"
click node_postprocessing "https://github.com/automatic1111/stable-diffusion-webui/blob/master/modules/postprocessing.py"
click node_training "https://github.com/automatic1111/stable-diffusion-webui/blob/master/modules/textual_inversion/textual_inversion.py"
click node_scripts "https://github.com/automatic1111/stable-diffusion-webui/blob/master/modules/scripts.py"
click node_upscalers "https://github.com/automatic1111/stable-diffusion-webui/blob/master/modules/upscaler.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_metadata,node_user toneBlue
class node_txtimg,node_img2img,node_processing,node_samplers,node_images toneAmber
class node_checkpoint,node_vae,node_hijack,node_devices toneMint
class node_textual,node_hypernet,node_lora,node_extras,node_postprocessing,node_training,node_scripts,node_upscalers toneRose
```

## Components

### User interfaces

- [Gradio UI](https://github.com/automatic1111/stable-diffusion-webui/blob/master/modules/ui.py): `modules/ui.py`
- [Generation API](https://github.com/automatic1111/stable-diffusion-webui/blob/master/modules/api/api.py): `modules/api/api.py`
- [Image parameters](https://github.com/automatic1111/stable-diffusion-webui/blob/master/modules/infotext_utils.py): `modules/infotext_utils.py`

### Image generation

- [Text-to-image](https://github.com/automatic1111/stable-diffusion-webui/blob/master/modules/txt2img.py): `modules/txt2img.py`
- [Image-to-image](https://github.com/automatic1111/stable-diffusion-webui/blob/master/modules/img2img.py): `modules/img2img.py`
- [Processing pipeline](https://github.com/automatic1111/stable-diffusion-webui/blob/master/modules/processing.py): `modules/processing.py`
- [Samplers](https://github.com/automatic1111/stable-diffusion-webui/blob/master/modules/sd_samplers.py): `modules/sd_samplers.py`
- [Image handling](https://github.com/automatic1111/stable-diffusion-webui/blob/master/modules/images.py): `modules/images.py`

### Models and conditioning

- [Checkpoint loading](https://github.com/automatic1111/stable-diffusion-webui/blob/master/modules/sd_models.py): `modules/sd_models.py`
- [VAE loading](https://github.com/automatic1111/stable-diffusion-webui/blob/master/modules/sd_vae.py): `modules/sd_vae.py`
- [Model conditioning](https://github.com/automatic1111/stable-diffusion-webui/blob/master/modules/sd_hijack.py): `modules/sd_hijack.py`
- [Device support](https://github.com/automatic1111/stable-diffusion-webui/blob/master/modules/devices.py): `modules/devices.py`

### Extensions and tools

- [Textual inversion](https://github.com/automatic1111/stable-diffusion-webui/blob/master/modules/textual_inversion/textual_inversion.py): `modules/textual_inversion/textual_inversion.py`
- [Hypernetworks](https://github.com/automatic1111/stable-diffusion-webui/blob/master/modules/hypernetworks/hypernetwork.py): `modules/hypernetworks/hypernetwork.py`
- [LoRA networks](https://github.com/automatic1111/stable-diffusion-webui/blob/master/extensions-builtin/Lora/networks.py): `extensions-builtin/Lora/networks.py`
- [Extras processing](https://github.com/automatic1111/stable-diffusion-webui/blob/master/modules/extras.py): `modules/extras.py`
- [Postprocessing](https://github.com/automatic1111/stable-diffusion-webui/blob/master/modules/postprocessing.py): `modules/postprocessing.py`
- [Embedding training](https://github.com/automatic1111/stable-diffusion-webui/blob/master/modules/textual_inversion/textual_inversion.py): `modules/textual_inversion/textual_inversion.py`
- [Custom scripts](https://github.com/automatic1111/stable-diffusion-webui/blob/master/modules/scripts.py): `modules/scripts.py`
- [Upscalers](https://github.com/automatic1111/stable-diffusion-webui/blob/master/modules/upscaler.py): `modules/upscaler.py`

### Other components

- **User**

## Connections

- User → Gradio UI: sets options (evidence: `README.md`)
- User → Generation API: requests generation (evidence: `README.md`)
- Processing pipeline → Samplers: uses samplers (evidence: `modules/processing.py`)
- Processing pipeline → Model conditioning: uses conditioning (evidence: `modules/processing.py`)
- Processing pipeline → Device support: uses devices (evidence: `modules/processing.py`)
- Processing pipeline → Textual inversion: applies networks (evidence: `modules/processing.py`)
- Checkpoint loading → VAE loading: loads VAE (evidence: `modules/sd_models.py`)
- Checkpoint loading → Device support: uses devices (evidence: `modules/sd_models.py`)
- Checkpoint loading → Processing pipeline: coordinates reloads (evidence: `modules/sd_models.py`)
- Model conditioning → Textual inversion: uses embeddings (evidence: `modules/sd_hijack.py`)
- Model conditioning → Hypernetworks: uses hypernetworks (evidence: `modules/sd_hijack.py`)
- Textual inversion → Image handling: uses image tools (evidence: `modules/textual_inversion/textual_inversion.py`)
- Generation API → Samplers: uses samplers (evidence: `modules/api/api.py`)
- Generation API → Image handling: uses image tools (evidence: `modules/api/api.py`)
- Generation API → Postprocessing: invokes postprocessing (evidence: `modules/api/api.py`)
- Gradio UI → Custom scripts: loads scripts (evidence: `modules/ui.py`)
- Gradio UI → Checkpoint loading: supports checkpoint selection (evidence: `modules/ui.py`)
- Gradio UI → Extras processing: offers Extras (evidence: `README.md`)
- Extras processing → Upscalers: offers upscaling (evidence: `README.md`)
- User → Embedding training: trains embeddings (evidence: `README.md`)
- Image handling → Image parameters: reads image parameters (evidence: `modules/infotext_utils.py`)
- User → Text-to-image: generates images (evidence: `README.md`)
- User → Image-to-image: edits images (evidence: `README.md`)
- User → LoRA networks: uses LoRAs (evidence: `README.md`)
