# qurle/compare architecture

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

- Interactive diagram: https://gitdiagram.com/qurle/compare
- Repository: https://github.com/qurle/compare

## Overview

Difference for Figma is a Figma plugin that compares two selected frames pixel by pixel and creates a comparison frame. The main flow validates and orders the selection, exports PNG snapshots, delegates image processing to a hidden UI iframe, then creates and selects a layered result and reports changed pixels. Settings and small shared utilities support that flow. The README describes the iframe’s decoding, diffing and encoding; its implementation was not excerpted, so details of that stage are limited to the documentation.

Main entry points: [`src/code.ts`](https://github.com/qurle/compare/blob/main/src/code.ts) (Selection and export), [`src/pages/index.astro`](https://github.com/qurle/compare/blob/main/src/pages/index.astro) (PNG diff worker), [`src/helpers/misc.ts`](https://github.com/qurle/compare/blob/main/src/helpers/misc.ts) (Shared utilities), [`src/config.ts`](https://github.com/qurle/compare/blob/main/src/config.ts) (Comparison settings)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_plugin["Plugin workflow"]
  node_orchestrator["Selection and export<br/>[code.ts]"]
  node_figma["Figma document"]
  node_comparison["Comparison frame<br/>[code.ts]"]
  node_report["Result summary<br/>[code.ts]"]
end

subgraph group_ui["Image processing"]
  node_image_worker["PNG diff worker<br/>[index.astro]"]
end

subgraph group_support["Shared support"]
  node_settings["Comparison settings<br/>[config.ts]"]
  node_utilities["Shared utilities<br/>[misc.ts]"]
  node_notifications["Notification helpers<br/>[notifications.ts]"]
end

node_user(("Plugin user"))

node_user -->|"runs plugin"| node_orchestrator
node_orchestrator -->|"reads settings"| node_settings
node_orchestrator -->|"exports snapshots"| node_figma
node_orchestrator -->|"sends PNGs"| node_image_worker
node_image_worker -->|"returns diff"| node_orchestrator
node_orchestrator -->|"creates result"| node_comparison
node_orchestrator -->|"formats summary"| node_report
node_orchestrator -->|"logs errors"| node_utilities
node_utilities -->|"reads logging flag"| node_settings

click node_orchestrator "https://github.com/qurle/compare/blob/main/src/code.ts"
click node_comparison "https://github.com/qurle/compare/blob/main/src/code.ts"
click node_report "https://github.com/qurle/compare/blob/main/src/code.ts"
click node_image_worker "https://github.com/qurle/compare/blob/main/src/pages/index.astro"
click node_settings "https://github.com/qurle/compare/blob/main/src/config.ts"
click node_utilities "https://github.com/qurle/compare/blob/main/src/helpers/misc.ts"
click node_notifications "https://github.com/qurle/compare/blob/main/src/helpers/notifications.ts"

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_orchestrator,node_figma,node_comparison,node_report,node_user toneBlue
class node_image_worker toneAmber
class node_settings,node_utilities,node_notifications toneMint
```

## Components

### Plugin workflow

- [Selection and export](https://github.com/qurle/compare/blob/main/src/code.ts): `src/code.ts`
- **Figma document**
- [Comparison frame](https://github.com/qurle/compare/blob/main/src/code.ts): `src/code.ts`
- [Result summary](https://github.com/qurle/compare/blob/main/src/code.ts): `src/code.ts`

### Image processing

- [PNG diff worker](https://github.com/qurle/compare/blob/main/src/pages/index.astro): `src/pages/index.astro`

### Shared support

- [Comparison settings](https://github.com/qurle/compare/blob/main/src/config.ts): `src/config.ts`
- [Shared utilities](https://github.com/qurle/compare/blob/main/src/helpers/misc.ts): `src/helpers/misc.ts`
- [Notification helpers](https://github.com/qurle/compare/blob/main/src/helpers/notifications.ts): `src/helpers/notifications.ts`

### Other components

- **Plugin user**

## Connections

- Plugin user → Selection and export: runs plugin (evidence: `readme.md`)
- Selection and export → Comparison settings: reads settings (evidence: `src/code.ts`)
- Selection and export → Figma document: exports snapshots (evidence: `src/code.ts`)
- Selection and export → PNG diff worker: sends PNGs (evidence: `src/code.ts`)
- PNG diff worker → Selection and export: returns diff (evidence: `readme.md`)
- Selection and export → Comparison frame: creates result (evidence: `src/code.ts`)
- Selection and export → Result summary: formats summary (evidence: `src/code.ts`)
- Selection and export → Shared utilities: logs errors (evidence: `src/code.ts`)
- Shared utilities → Comparison settings: reads logging flag (evidence: `src/helpers/misc.ts`)
