# wanthinnn/stylio architecture

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

- Interactive diagram: https://gitdiagram.com/wanthinnn/stylio
- Repository: https://github.com/wanthinnn/stylio

## Overview

Stylio is a local-first browser/PWA photo editor whose main workflow is selecting a photo, optionally applying AI enhancements, processing and preserving photo resources, then saving an Apple Photos-compatible result. Its documented capabilities include HEIC/JPEG/PNG/DNG import, Photographic Styles, Texture/Grain, editable AI Portrait, Smart Enhance, and offline-friendly local processing. The graph combines README-documented product flows with relationships visible in the supplied source index and excerpts; unsampled subsystem internals are represented at directory level.

Main entry points: [`web/src/media/heic-worker.js`](https://github.com/wanthinnn/stylio/blob/master/web/src/media/heic-worker.js) (HEIC processing), [`web/src/app/processing/file-processor.js`](https://github.com/wanthinnn/stylio/blob/master/web/src/app/processing/file-processor.js) (File processing), [`web/src/app/application.js`](https://github.com/wanthinnn/stylio/blob/master/web/src/app/application.js) (App workflow), [`web/src/styles/port.js`](https://github.com/wanthinnn/stylio/blob/master/web/src/styles/port.js) (Style porting)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_experience["App experience"]
  node_application["App workflow<br/>[application.js]"]
  node_ui["PWA and UI"]
  node_history[("History and results<br/>[history-store.js]")]
end

subgraph group_intake["Photo intake"]
  node_file_processing["File processing<br/>[file-processor.js]"]
  node_photo_decode["Photo decoding<br/>[decode.js]"]
  node_dng["DNG import"]
end

subgraph group_enhance["Enhancement"]
  node_styles_port["Style porting<br/>[port.js]"]
  node_style_graft["Style grafting<br/>[graft.js]"]
  node_texture["Texture and Grain<br/>[texture.js]"]
  node_style_recommend["Adaptive Styles"]
  node_portrait["AI Portrait"]
  node_portrait_controller["Portrait orchestration"]
  node_detail["Detail restoration"]
end

subgraph group_format["Format and preservation"]
  node_heic_worker["HEIC processing<br/>[heic-worker.js]"]
  node_heif_parser["HEIF parsing<br/>[heif.js]"]
  node_box_format["Box primitives<br/>[box.js]"]
  node_exif["Exif preservation<br/>[exif.js]"]
  node_raster_heif["Raster HEIF<br/>[heif.js]"]
  node_hevc["HEVC codec<br/>[ffmpeg-hevc.js]"]
end

subgraph group_runtime["Runtime services"]
  node_models["Model downloads<br/>[model-download.js]"]
  node_service_worker["PWA service worker<br/>[sw.js]"]
end

node_user(("Photo editor"))
node_output["Processed photo"]

node_user -->|"opens and selects"| node_application
node_application -->|"presents workflow"| node_ui
node_application -.->|"dispatches processing"| node_file_processing
node_file_processing -.->|"decodes input"| node_photo_decode
node_file_processing -.->|"imports DNG"| node_dng
node_photo_decode -->|"reads HEIF"| node_heif_parser
node_file_processing -.->|"analyzes style"| node_style_recommend
node_file_processing -.->|"restores detail"| node_detail
node_portrait_controller -->|"creates portrait"| node_portrait
node_portrait -->|"downloads models"| node_models
node_style_recommend -->|"downloads models"| node_models
node_file_processing -.->|"processes HEIC"| node_heic_worker
node_heic_worker -->|"applies style port"| node_styles_port
node_styles_port -->|"grafts resources"| node_style_graft
node_heic_worker -->|"adds texture"| node_texture
node_heic_worker -->|"validates recommendation"| node_style_recommend
node_heic_worker -.->|"preserves metadata"| node_exif
node_styles_port -->|"edits HEIF structure"| node_heif_parser
node_heif_parser -->|"uses box parsing"| node_box_format
node_heic_worker -.->|"repairs HDR output"| node_raster_heif
node_portrait_controller -->|"releases encoder"| node_hevc
node_application -.->|"manages history"| node_history
node_application -.->|"runs as PWA"| node_service_worker
node_ui -->|"saves result"| node_output
node_heic_worker -.->|"produces edited file"| node_output

click node_application "https://github.com/wanthinnn/stylio/blob/master/web/src/app/application.js"
click node_ui "https://github.com/wanthinnn/stylio/tree/master/web/src/ui"
click node_history "https://github.com/wanthinnn/stylio/blob/master/web/src/ui/history-store.js"
click node_file_processing "https://github.com/wanthinnn/stylio/blob/master/web/src/app/processing/file-processor.js"
click node_photo_decode "https://github.com/wanthinnn/stylio/blob/master/web/src/media/decode.js"
click node_dng "https://github.com/wanthinnn/stylio/tree/master/web/src/dng"
click node_heic_worker "https://github.com/wanthinnn/stylio/blob/master/web/src/media/heic-worker.js"
click node_heif_parser "https://github.com/wanthinnn/stylio/blob/master/web/src/core/heif.js"
click node_box_format "https://github.com/wanthinnn/stylio/blob/master/web/src/core/box.js"
click node_exif "https://github.com/wanthinnn/stylio/blob/master/web/src/core/exif.js"
click node_raster_heif "https://github.com/wanthinnn/stylio/blob/master/web/src/raster/heif.js"
click node_styles_port "https://github.com/wanthinnn/stylio/blob/master/web/src/styles/port.js"
click node_style_graft "https://github.com/wanthinnn/stylio/blob/master/web/src/styles/graft.js"
click node_texture "https://github.com/wanthinnn/stylio/blob/master/web/src/styles/texture.js"
click node_style_recommend "https://github.com/wanthinnn/stylio/tree/master/web/src/recommend"
click node_portrait "https://github.com/wanthinnn/stylio/tree/master/web/src/portrait"
click node_portrait_controller "https://github.com/wanthinnn/stylio/blob/master/web/src/app/processing/portrait-controller.js"
click node_detail "https://github.com/wanthinnn/stylio/tree/master/web/src/detail"
click node_hevc "https://github.com/wanthinnn/stylio/blob/master/web/src/codecs/ffmpeg-hevc.js"
click node_models "https://github.com/wanthinnn/stylio/blob/master/web/src/core/model-download.js"
click node_service_worker "https://github.com/wanthinnn/stylio/blob/master/web/sw.js"

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_application,node_ui,node_history toneBlue
class node_file_processing,node_photo_decode,node_dng toneAmber
class node_styles_port,node_style_graft,node_texture,node_style_recommend,node_portrait,node_portrait_controller,node_detail toneMint
class node_heic_worker,node_heif_parser,node_box_format,node_exif,node_raster_heif,node_hevc toneRose
class node_models,node_service_worker,node_user,node_output toneIndigo
```

## Components

### App experience

- [App workflow](https://github.com/wanthinnn/stylio/blob/master/web/src/app/application.js): `web/src/app/application.js`
- [PWA and UI](https://github.com/wanthinnn/stylio/tree/master/web/src/ui): `web/src/ui`
- [History and results](https://github.com/wanthinnn/stylio/blob/master/web/src/ui/history-store.js): `web/src/ui/history-store.js`

### Photo intake

- [File processing](https://github.com/wanthinnn/stylio/blob/master/web/src/app/processing/file-processor.js): `web/src/app/processing/file-processor.js`
- [Photo decoding](https://github.com/wanthinnn/stylio/blob/master/web/src/media/decode.js): `web/src/media/decode.js`
- [DNG import](https://github.com/wanthinnn/stylio/tree/master/web/src/dng): `web/src/dng`

### Enhancement

- [Style porting](https://github.com/wanthinnn/stylio/blob/master/web/src/styles/port.js): `web/src/styles/port.js`
- [Style grafting](https://github.com/wanthinnn/stylio/blob/master/web/src/styles/graft.js): `web/src/styles/graft.js`
- [Texture and Grain](https://github.com/wanthinnn/stylio/blob/master/web/src/styles/texture.js): `web/src/styles/texture.js`
- [Adaptive Styles](https://github.com/wanthinnn/stylio/tree/master/web/src/recommend): `web/src/recommend`
- [AI Portrait](https://github.com/wanthinnn/stylio/tree/master/web/src/portrait): `web/src/portrait`
- [Portrait orchestration](https://github.com/wanthinnn/stylio/blob/master/web/src/app/processing/portrait-controller.js): `web/src/app/processing/portrait-controller.js`
- [Detail restoration](https://github.com/wanthinnn/stylio/tree/master/web/src/detail): `web/src/detail`

### Format and preservation

- [HEIC processing](https://github.com/wanthinnn/stylio/blob/master/web/src/media/heic-worker.js): `web/src/media/heic-worker.js`
- [HEIF parsing](https://github.com/wanthinnn/stylio/blob/master/web/src/core/heif.js): `web/src/core/heif.js`
- [Box primitives](https://github.com/wanthinnn/stylio/blob/master/web/src/core/box.js): `web/src/core/box.js`
- [Exif preservation](https://github.com/wanthinnn/stylio/blob/master/web/src/core/exif.js): `web/src/core/exif.js`
- [Raster HEIF](https://github.com/wanthinnn/stylio/blob/master/web/src/raster/heif.js): `web/src/raster/heif.js`
- [HEVC codec](https://github.com/wanthinnn/stylio/blob/master/web/src/codecs/ffmpeg-hevc.js): `web/src/codecs/ffmpeg-hevc.js`

### Runtime services

- [Model downloads](https://github.com/wanthinnn/stylio/blob/master/web/src/core/model-download.js): `web/src/core/model-download.js`
- [PWA service worker](https://github.com/wanthinnn/stylio/blob/master/web/sw.js): `web/sw.js`

### Other components

- **Photo editor**
- **Processed photo**

## Connections

- Photo editor → App workflow: opens and selects (evidence: `README.md`)
- App workflow → PWA and UI: presents workflow (evidence: `web/src/app/application.js`)
- App workflow → File processing: dispatches processing (evidence: `web/src/app/application.js`)
- File processing → Photo decoding: decodes input
- File processing → DNG import: imports DNG (evidence: `README.md`)
- Photo decoding → HEIF parsing: reads HEIF (evidence: `web/src/media/decode.js`)
- File processing → Adaptive Styles: analyzes style (evidence: `README.md`)
- File processing → Detail restoration: restores detail (evidence: `README.md`)
- Portrait orchestration → AI Portrait: creates portrait (evidence: `web/src/app/processing/portrait-controller.js`)
- AI Portrait → Model downloads: downloads models (evidence: `web/src/portrait/ai-inference-worker.js`)
- Adaptive Styles → Model downloads: downloads models (evidence: `web/src/recommend/style-inference-worker.js`)
- File processing → HEIC processing: processes HEIC (evidence: `README.md`)
- HEIC processing → Style porting: applies style port (evidence: `web/src/media/heic-worker.js`)
- Style porting → Style grafting: grafts resources (evidence: `web/src/styles/port.js`)
- HEIC processing → Texture and Grain: adds texture (evidence: `web/src/media/heic-worker.js`)
- HEIC processing → Adaptive Styles: validates recommendation (evidence: `web/src/media/heic-worker.js`)
- HEIC processing → Exif preservation: preserves metadata
- Style porting → HEIF parsing: edits HEIF structure (evidence: `web/src/styles/port.js`)
- HEIF parsing → Box primitives: uses box parsing (evidence: `web/src/core/heif.js`)
- HEIC processing → Raster HEIF: repairs HDR output
- Portrait orchestration → HEVC codec: releases encoder (evidence: `web/src/app/processing/portrait-controller.js`)
- App workflow → History and results: manages history (evidence: `web/src/app/application.js`)
- App workflow → PWA service worker: runs as PWA (evidence: `README.md`)
- PWA and UI → Processed photo: saves result (evidence: `README.md`)
- HEIC processing → Processed photo: produces edited file (evidence: `README.md`)
