# sanster/iopaint architecture

> Architecture diagram of the GitHub repository sanster/iopaint, 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/sanster/iopaint
- Repository: https://github.com/sanster/iopaint

## Overview

IOPaint is a self-hosted image inpainting and outpainting application: users load an image, define a mask and editing options, run a selected AI model, and save or browse results. Its backend also supports command-line batch processing and optional segmentation, background removal, upscaling, and face-restoration plugins. The graph preserves documented model families and plugin capabilities, but several of their internal connections are not evidenced by the sampled source; those links are omitted or marked unverified.

Main entry points: [`iopaint/model_manager.py`](https://github.com/sanster/iopaint/blob/main/iopaint/model_manager.py) (Model manager), [`iopaint/api.py`](https://github.com/sanster/iopaint/blob/main/iopaint/api.py) (HTTP API), [`web_app/src/App.tsx`](https://github.com/sanster/iopaint/blob/main/web_app/src/App.tsx) (Web app shell), [`iopaint/file_manager/file_manager.py`](https://github.com/sanster/iopaint/blob/main/iopaint/file_manager/file_manager.py) (File manager)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_ui["Editing interface"]
  node_editor["Image editor<br/>[Workspace.tsx]"]
  node_app["Web app shell<br/>[App.tsx]"]
  node_state["Editor state<br/>[states.ts]"]
  node_file_ui["File browser<br/>[FileManager.tsx]"]
end

subgraph group_service["Service and files"]
  node_api["HTTP API<br/>[api.py]"]
  node_schema["Request schema<br/>[schema.py]"]
  node_files["File manager<br/>[file_manager.py]"]
  node_storage["Filesystem storage"]
end

subgraph group_inference["AI inference"]
  node_model_manager["Model manager<br/>[model_manager.py]"]
  node_model_zoo["Erase model family"]
  node_anytext["AnyText"]
  node_brushnet["BrushNet<br/>[brushnet.py]"]
  node_powerpaint["PowerPaint"]
end

subgraph group_plugins["Image plugins"]
  node_plugin_set["Enhancement plugins"]
  node_sam2["SAM2 segmentation"]
end

subgraph group_batch["Batch use"]
  node_batch_cli["Batch command"]
end

node_web_actor(("Web user"))
node_cli_actor(("CLI user"))

node_web_actor -.->|"edits images"| node_app
node_app -->|"renders"| node_editor
node_app -->|"uses state"| node_state
node_file_ui -->|"updates state"| node_state
node_file_ui -.->|"requests media"| node_files
node_app -.->|"fetches config"| node_api
node_api -->|"dispatches inference"| node_model_manager
node_api -->|"registers file routes"| node_files
node_api -->|"uses requests"| node_schema
node_files -->|"reads and saves"| node_storage
node_model_manager -->|"loads models"| node_model_zoo
node_model_manager -->|"loads model"| node_anytext
node_model_manager -->|"loads model"| node_brushnet
node_model_manager -->|"loads model"| node_powerpaint
node_api -->|"registers plugins"| node_plugin_set
node_plugin_set -.->|"offers segmentation"| node_sam2
node_cli_actor -.->|"starts batch run"| node_batch_cli
node_batch_cli -.->|"runs model"| node_model_manager

click node_editor "https://github.com/sanster/iopaint/blob/main/web_app/src/components/Workspace.tsx"
click node_app "https://github.com/sanster/iopaint/blob/main/web_app/src/App.tsx"
click node_state "https://github.com/sanster/iopaint/blob/main/web_app/src/lib/states.ts"
click node_file_ui "https://github.com/sanster/iopaint/blob/main/web_app/src/components/FileManager.tsx"
click node_api "https://github.com/sanster/iopaint/blob/main/iopaint/api.py"
click node_schema "https://github.com/sanster/iopaint/blob/main/iopaint/schema.py"
click node_files "https://github.com/sanster/iopaint/blob/main/iopaint/file_manager/file_manager.py"
click node_storage "https://github.com/sanster/iopaint/blob/main/iopaint/file_manager/storage_backends.py"
click node_model_manager "https://github.com/sanster/iopaint/blob/main/iopaint/model_manager.py"
click node_model_zoo "https://github.com/sanster/iopaint/tree/main/iopaint/model"
click node_anytext "https://github.com/sanster/iopaint/blob/main/iopaint/model/anytext/anytext_pipeline.py"
click node_brushnet "https://github.com/sanster/iopaint/blob/main/iopaint/model/brushnet/brushnet.py"
click node_powerpaint "https://github.com/sanster/iopaint/blob/main/iopaint/model/power_paint/pipeline_powerpaint.py"
click node_plugin_set "https://github.com/sanster/iopaint/tree/main/iopaint/plugins"
click node_sam2 "https://github.com/sanster/iopaint/blob/main/iopaint/plugins/segment_anything2/sam2_image_predictor.py"
click node_batch_cli "https://github.com/sanster/iopaint/blob/main/iopaint/batch_processing.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_editor,node_app,node_state,node_file_ui,node_web_actor,node_cli_actor toneBlue
class node_api,node_schema,node_files,node_storage toneAmber
class node_model_manager,node_model_zoo,node_anytext,node_brushnet,node_powerpaint toneMint
class node_plugin_set,node_sam2 toneRose
class node_batch_cli toneIndigo
```

## Components

### Editing interface

- [Image editor](https://github.com/sanster/iopaint/blob/main/web_app/src/components/Workspace.tsx): `web_app/src/components/Workspace.tsx`
- [Web app shell](https://github.com/sanster/iopaint/blob/main/web_app/src/App.tsx): `web_app/src/App.tsx`
- [Editor state](https://github.com/sanster/iopaint/blob/main/web_app/src/lib/states.ts): `web_app/src/lib/states.ts`
- [File browser](https://github.com/sanster/iopaint/blob/main/web_app/src/components/FileManager.tsx): `web_app/src/components/FileManager.tsx`

### Service and files

- [HTTP API](https://github.com/sanster/iopaint/blob/main/iopaint/api.py): `iopaint/api.py`
- [Request schema](https://github.com/sanster/iopaint/blob/main/iopaint/schema.py): `iopaint/schema.py`
- [File manager](https://github.com/sanster/iopaint/blob/main/iopaint/file_manager/file_manager.py): `iopaint/file_manager/file_manager.py`
- [Filesystem storage](https://github.com/sanster/iopaint/blob/main/iopaint/file_manager/storage_backends.py): `iopaint/file_manager/storage_backends.py`

### AI inference

- [Model manager](https://github.com/sanster/iopaint/blob/main/iopaint/model_manager.py): `iopaint/model_manager.py`
- [Erase model family](https://github.com/sanster/iopaint/tree/main/iopaint/model): `iopaint/model`
- [AnyText](https://github.com/sanster/iopaint/blob/main/iopaint/model/anytext/anytext_pipeline.py): `iopaint/model/anytext/anytext_pipeline.py`
- [BrushNet](https://github.com/sanster/iopaint/blob/main/iopaint/model/brushnet/brushnet.py): `iopaint/model/brushnet/brushnet.py`
- [PowerPaint](https://github.com/sanster/iopaint/blob/main/iopaint/model/power_paint/pipeline_powerpaint.py): `iopaint/model/power_paint/pipeline_powerpaint.py`

### Image plugins

- [Enhancement plugins](https://github.com/sanster/iopaint/tree/main/iopaint/plugins): `iopaint/plugins`
- [SAM2 segmentation](https://github.com/sanster/iopaint/blob/main/iopaint/plugins/segment_anything2/sam2_image_predictor.py): `iopaint/plugins/segment_anything2/sam2_image_predictor.py`

### Batch use

- [Batch command](https://github.com/sanster/iopaint/blob/main/iopaint/batch_processing.py): `iopaint/batch_processing.py`

### Other components

- **Web user**
- **CLI user**

## Connections

- Web user → Web app shell: edits images (evidence: `README.md`)
- Web app shell → Image editor: renders (evidence: `web_app/src/App.tsx`)
- Web app shell → Editor state: uses state (evidence: `web_app/src/App.tsx`)
- File browser → Editor state: updates state (evidence: `web_app/src/components/FileManager.tsx`)
- File browser → File manager: requests media
- Web app shell → HTTP API: fetches config
- HTTP API → Model manager: dispatches inference (evidence: `iopaint/api.py`)
- HTTP API → File manager: registers file routes (evidence: `iopaint/api.py`)
- HTTP API → Request schema: uses requests (evidence: `iopaint/api.py`)
- File manager → Filesystem storage: reads and saves (evidence: `iopaint/file_manager/file_manager.py`)
- Model manager → Erase model family: loads models (evidence: `iopaint/model_manager.py`)
- Model manager → AnyText: loads model (evidence: `iopaint/model_manager.py`)
- Model manager → BrushNet: loads model (evidence: `iopaint/model_manager.py`)
- Model manager → PowerPaint: loads model (evidence: `iopaint/model_manager.py`)
- HTTP API → Enhancement plugins: registers plugins (evidence: `iopaint/api.py`)
- Enhancement plugins → SAM2 segmentation: offers segmentation (evidence: `iopaint/plugins/segment_anything2/sam2_image_predictor.py`)
- CLI user → Batch command: starts batch run (evidence: `README.md`)
- Batch command → Model manager: runs model
