# napat1203/image-processing architecture

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

- Interactive diagram: https://gitdiagram.com/napat1203/image-processing
- Repository: https://github.com/napat1203/image-processing

## Overview

Image-Processing is a Flask image-editing application with browser-based image and webcam workflows, account/admin features, and AI-assisted generation and editing. The visible workflow sends an uploaded or captured image from the browser to Flask, which dispatches supported image jobs and returns a result; recoloring and inpainting can use a selected point. The README provides no further product detail. Edges reflect shown calls/imports or the frontend’s visible API requests; other route wiring and the text-to-image path are not inferred from incomplete excerpts.

Main entry points: [`ai/process.py`](https://github.com/napat1203/image-processing/blob/main/ai/process.py) (Image job dispatch), [`backend/app.py`](https://github.com/napat1203/image-processing/blob/main/backend/app.py) (Flask routes), [`ai/inpaint.py`](https://github.com/napat1203/image-processing/blob/main/ai/inpaint.py) (Image inpainting), [`ai/forge_client.py`](https://github.com/napat1203/image-processing/blob/main/ai/forge_client.py) (Forge client)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_web["Browser experience"]
  node_web_ui["Image and webcam UI<br/>[script.js]"]
  node_web_pages["Application pages"]
end

subgraph group_app["Application and accounts"]
  node_routes["Flask routes<br/>[app.py]"]
  node_accounts["Account management<br/>[app.py]"]
end

subgraph group_ai["Image processing"]
  node_job_dispatch["Image job dispatch<br/>[process.py]"]
  node_recolor["Region recoloring<br/>[segment.py]"]
  node_background["Background removal"]
  node_pose["Pose generation<br/>[controlnet.py]"]
  node_inpaint["Image inpainting<br/>[inpaint.py]"]
end

subgraph group_services["Persistence and AI service"]
  node_forge_client["Forge client<br/>[forge_client.py]"]
  node_user_store[("User database<br/>[db.py]")]
end

node_user(("User"))
node_forge{{"Forge API"}}

node_user -->|"interacts"| node_web_ui
node_web_ui -->|"posts images"| node_routes
node_routes -->|"dispatches jobs"| node_job_dispatch
node_routes -->|"queries accounts"| node_user_store
node_job_dispatch -->|"calls for recoloring"| node_recolor
node_job_dispatch -->|"calls for removal"| node_background
node_job_dispatch -->|"calls for pose"| node_pose
node_job_dispatch -->|"calls for inpainting"| node_inpaint
node_inpaint -->|"uses segmentation"| node_recolor
node_pose -->|"submits generation"| node_forge_client
node_inpaint -->|"submits inpainting"| node_forge_client
node_forge_client -->|"sends HTTP request"| node_forge

click node_web_ui "https://github.com/napat1203/image-processing/blob/main/frontend/static/js/script.js"
click node_web_pages "https://github.com/napat1203/image-processing/tree/main/frontend/templates"
click node_routes "https://github.com/napat1203/image-processing/blob/main/backend/app.py"
click node_accounts "https://github.com/napat1203/image-processing/blob/main/backend/app.py"
click node_job_dispatch "https://github.com/napat1203/image-processing/blob/main/ai/process.py"
click node_recolor "https://github.com/napat1203/image-processing/blob/main/ai/segment.py"
click node_background "https://github.com/napat1203/image-processing/blob/main/ai/remove_background.py"
click node_pose "https://github.com/napat1203/image-processing/blob/main/ai/controlnet.py"
click node_inpaint "https://github.com/napat1203/image-processing/blob/main/ai/inpaint.py"
click node_forge_client "https://github.com/napat1203/image-processing/blob/main/ai/forge_client.py"
click node_user_store "https://github.com/napat1203/image-processing/blob/main/backend/db.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_web_ui,node_web_pages,node_user toneBlue
class node_routes,node_accounts toneAmber
class node_job_dispatch,node_recolor,node_background,node_pose,node_inpaint,node_forge toneMint
class node_forge_client,node_user_store toneRose
```

## Components

### Browser experience

- [Image and webcam UI](https://github.com/napat1203/image-processing/blob/main/frontend/static/js/script.js): `frontend/static/js/script.js`
- [Application pages](https://github.com/napat1203/image-processing/tree/main/frontend/templates): `frontend/templates`

### Application and accounts

- [Flask routes](https://github.com/napat1203/image-processing/blob/main/backend/app.py): `backend/app.py`
- [Account management](https://github.com/napat1203/image-processing/blob/main/backend/app.py): `backend/app.py`

### Image processing

- [Image job dispatch](https://github.com/napat1203/image-processing/blob/main/ai/process.py): `ai/process.py`
- [Region recoloring](https://github.com/napat1203/image-processing/blob/main/ai/segment.py): `ai/segment.py`
- [Background removal](https://github.com/napat1203/image-processing/blob/main/ai/remove_background.py): `ai/remove_background.py`
- [Pose generation](https://github.com/napat1203/image-processing/blob/main/ai/controlnet.py): `ai/controlnet.py`
- [Image inpainting](https://github.com/napat1203/image-processing/blob/main/ai/inpaint.py): `ai/inpaint.py`

### Persistence and AI service

- [Forge client](https://github.com/napat1203/image-processing/blob/main/ai/forge_client.py): `ai/forge_client.py`
- [User database](https://github.com/napat1203/image-processing/blob/main/backend/db.py): `backend/db.py`

### Other components

- **User**
- **Forge API**

## Connections

- User → Image and webcam UI: interacts (evidence: `frontend/static/js/script.js`)
- Image and webcam UI → Flask routes: posts images (evidence: `frontend/static/js/script.js`)
- Flask routes → Image job dispatch: dispatches jobs (evidence: `backend/app.py`)
- Flask routes → User database: queries accounts (evidence: `backend/app.py`)
- Image job dispatch → Region recoloring: calls for recoloring (evidence: `ai/process.py`)
- Image job dispatch → Background removal: calls for removal (evidence: `ai/process.py`)
- Image job dispatch → Pose generation: calls for pose (evidence: `ai/process.py`)
- Image job dispatch → Image inpainting: calls for inpainting (evidence: `ai/process.py`)
- Image inpainting → Region recoloring: uses segmentation (evidence: `ai/inpaint.py`)
- Pose generation → Forge client: submits generation (evidence: `ai/controlnet.py`)
- Image inpainting → Forge client: submits inpainting (evidence: `ai/inpaint.py`)
- Forge client → Forge API: sends HTTP request (evidence: `ai/forge_client.py`)
