# esimov/caire architecture

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

- Interactive diagram: https://gitdiagram.com/esimov/caire
- Repository: https://github.com/esimov/caire

## Overview

Caire is a content-aware image resizing library with a CLI. The principal workflow accepts a local image, URL, stdin stream, or directory; decodes and prepares images and optional masks; resizes by seam carving; then writes the selected output format. Resizing supports shrinking, enlargement, horizontal and vertical dimensions, face-aware protection, and masks. Optional GUI preview visualizes progress and debug overlays. The README documents several capabilities whose implementation details were not sampled; those are represented at the supported processor path, with only documented relationships shown.

Main entry points: [`processor.go`](https://github.com/esimov/caire/blob/master/processor.go) (Resize orchestration), [`exec.go`](https://github.com/esimov/caire/blob/master/exec.go) (Input/output execution), [`gui.go`](https://github.com/esimov/caire/blob/master/gui.go) (Progress preview), [`cmd/caire/main.go`](https://github.com/esimov/caire/blob/master/cmd/caire/main.go) (CLI options)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_interface["Entry and I/O"]
  node_cli["CLI options<br/>[main.go]"]
  node_execution["Input/output execution<br/>[exec.go]"]
  node_format["Image output formats<br/>[exec.go]"]
  node_download["URL download<br/>[download.go]"]
end

subgraph group_resize["Seam resizing"]
  node_processor["Resize orchestration<br/>[processor.go]"]
  node_carver["Seam energy and carving<br/>[carver.go]"]
  node_mask["Protect and remove masks<br/>[processor.go]"]
  node_faces["Face-aware protection<br/>[processor.go]"]
end

subgraph group_pixels["Image operations"]
  node_imageio["Image decode and convert<br/>[image.go]"]
  node_sobel["Sobel energy map<br/>[sobel.go]"]
  node_blur["Stack blur<br/>[stackblur.go]"]
end

subgraph group_preview["Preview and debug"]
  node_gui["Progress preview<br/>[gui.go]"]
  node_seamdraw["Seam visualization<br/>[draw.go]"]
  node_composition["Debug compositing<br/>[comp.go]"]
  node_blend["Debug blend modes<br/>[blend.go]"]
end

node_user(("User"))

node_user -->|"sets options"| node_cli
node_cli -->|"configures and starts"| node_processor
node_cli -->|"executes input"| node_execution
node_execution -->|"processes image"| node_processor
node_execution -->|"decodes masks"| node_imageio
node_execution -->|"downloads URL input"| node_download
node_execution -->|"encodes output"| node_format
node_processor -->|"finds and applies seams"| node_carver
node_carver -->|"computes energy"| node_sobel
node_processor -->|"uses image operations"| node_imageio
node_processor -.->|"applies masks"| node_mask
node_processor -.->|"detects faces"| node_faces
node_processor -.->|"blurs for detection"| node_blur
node_processor -->|"sends preview frames"| node_gui
node_gui -->|"draws seams"| node_seamdraw
node_gui -->|"composites debug view"| node_composition
node_gui -->|"uses blend modes"| node_blend

click node_cli "https://github.com/esimov/caire/blob/master/cmd/caire/main.go"
click node_execution "https://github.com/esimov/caire/blob/master/exec.go"
click node_imageio "https://github.com/esimov/caire/blob/master/image/image.go"
click node_processor "https://github.com/esimov/caire/blob/master/processor.go"
click node_carver "https://github.com/esimov/caire/blob/master/carver.go"
click node_sobel "https://github.com/esimov/caire/blob/master/image/sobel.go"
click node_blur "https://github.com/esimov/caire/blob/master/image/stackblur.go"
click node_mask "https://github.com/esimov/caire/blob/master/processor.go"
click node_faces "https://github.com/esimov/caire/blob/master/processor.go"
click node_format "https://github.com/esimov/caire/blob/master/exec.go"
click node_gui "https://github.com/esimov/caire/blob/master/gui.go"
click node_seamdraw "https://github.com/esimov/caire/blob/master/draw.go"
click node_composition "https://github.com/esimov/caire/blob/master/imop/comp.go"
click node_blend "https://github.com/esimov/caire/blob/master/imop/blend.go"
click node_download "https://github.com/esimov/caire/blob/master/utils/download.go"

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_cli,node_execution,node_format,node_download,node_user toneBlue
class node_processor,node_carver,node_mask,node_faces toneAmber
class node_imageio,node_sobel,node_blur toneMint
class node_gui,node_seamdraw,node_composition,node_blend toneRose
```

## Components

### Entry and I/O

- [CLI options](https://github.com/esimov/caire/blob/master/cmd/caire/main.go): `cmd/caire/main.go`
- [Input/output execution](https://github.com/esimov/caire/blob/master/exec.go): `exec.go`
- [Image output formats](https://github.com/esimov/caire/blob/master/exec.go): `exec.go`
- [URL download](https://github.com/esimov/caire/blob/master/utils/download.go): `utils/download.go`

### Seam resizing

- [Resize orchestration](https://github.com/esimov/caire/blob/master/processor.go): `processor.go`
- [Seam energy and carving](https://github.com/esimov/caire/blob/master/carver.go): `carver.go`
- [Protect and remove masks](https://github.com/esimov/caire/blob/master/processor.go): `processor.go`
- [Face-aware protection](https://github.com/esimov/caire/blob/master/processor.go): `processor.go`

### Image operations

- [Image decode and convert](https://github.com/esimov/caire/blob/master/image/image.go): `image/image.go`
- [Sobel energy map](https://github.com/esimov/caire/blob/master/image/sobel.go): `image/sobel.go`
- [Stack blur](https://github.com/esimov/caire/blob/master/image/stackblur.go): `image/stackblur.go`

### Preview and debug

- [Progress preview](https://github.com/esimov/caire/blob/master/gui.go): `gui.go`
- [Seam visualization](https://github.com/esimov/caire/blob/master/draw.go): `draw.go`
- [Debug compositing](https://github.com/esimov/caire/blob/master/imop/comp.go): `imop/comp.go`
- [Debug blend modes](https://github.com/esimov/caire/blob/master/imop/blend.go): `imop/blend.go`

### Other components

- **User**

## Connections

- User → CLI options: sets options (evidence: `cmd/caire/main.go`)
- CLI options → Resize orchestration: configures and starts (evidence: `cmd/caire/main.go`)
- CLI options → Input/output execution: executes input (evidence: `cmd/caire/main.go`)
- Input/output execution → Resize orchestration: processes image (evidence: `exec.go`)
- Input/output execution → Image decode and convert: decodes masks (evidence: `exec.go`)
- Input/output execution → URL download: downloads URL input (evidence: `exec.go`)
- Input/output execution → Image output formats: encodes output (evidence: `exec.go`)
- Resize orchestration → Seam energy and carving: finds and applies seams (evidence: `processor.go`)
- Seam energy and carving → Sobel energy map: computes energy (evidence: `carver.go`)
- Resize orchestration → Image decode and convert: uses image operations (evidence: `processor.go`)
- Resize orchestration → Protect and remove masks: applies masks (evidence: `processor.go`)
- Resize orchestration → Face-aware protection: detects faces (evidence: `processor.go`)
- Resize orchestration → Stack blur: blurs for detection
- Resize orchestration → Progress preview: sends preview frames (evidence: `processor.go`)
- Progress preview → Seam visualization: draws seams (evidence: `draw.go`)
- Progress preview → Debug compositing: composites debug view (evidence: `gui.go`)
- Progress preview → Debug blend modes: uses blend modes (evidence: `gui.go`)
