# elkeipy/agsnaptool architecture

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

## Overview

AgSnapTool is a Windows tray screenshot utility. A user gesture selects a control, region, or window; the app captures and saves a PNG, then exposes it in a searchable, annotated gallery for copying, OCR/Markdown, magnification, and editing. The graph separates capture, gallery/tool windows, and persisted library state. Several command implementations and UI-to-command bindings were not fully excerpted, so those documented relationships cite the README rather than implying the unsampled call details were inspected.

Main entry points: [`src/main.rs`](https://github.com/elkeipy/agsnaptool/blob/master/src/main.rs) (Gallery commands), [`src/win.rs`](https://github.com/elkeipy/agsnaptool/blob/master/src/win.rs) (Capture hooks), [`ui/app.js`](https://github.com/elkeipy/agsnaptool/blob/master/ui/app.js) (Gallery UI), [`src/logic.rs`](https://github.com/elkeipy/agsnaptool/blob/master/src/logic.rs) (Settings and rules)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_capture["Capture"]
  node_capture_hooks["Capture hooks<br/>[win.rs]"]
  node_capture_geometry["Capture geometry<br/>[rect.rs]"]
  node_shot_files[("Shot PNG files<br/>[win.rs]")]
end

subgraph group_gallery["Gallery and tools"]
  node_gallery_ui["Gallery UI<br/>[app.js]"]
  node_gallery_commands["Gallery commands<br/>[main.rs]"]
  node_lens_ui["Magnifier UI<br/>[app.js]"]
  node_editor_ui["Editor UI<br/>[app.js]"]
  node_image_commands["Image commands<br/>[main.rs]"]
  node_ocr_engine["Windows OCR<br/>[ocr.rs]"]
  node_markdown_tools["Markdown tools<br/>[main.rs]"]
end

subgraph group_library["Library and settings"]
  node_settings_logic["Settings and rules<br/>[logic.rs]"]
  node_settings_file[("Settings file<br/>[logic.rs]")]
  node_notes_logic["Notes and tags<br/>[logic.rs]"]
  node_notes_file[("Notes file<br/>[logic.rs]")]
end

subgraph group_platform["Platform support"]
  node_tray_runtime["Tray runtime<br/>[main.rs]"]
  node_localization["Localization<br/>[strings.rs]"]
  node_native_dialogs["Native dialogs<br/>[dialogs.rs]"]
  node_windows_api["Windows integration<br/>[win.rs]"]
end

node_user(("User"))

node_user -->|"gestures"| node_capture_hooks
node_capture_hooks -->|"uses bounds"| node_capture_geometry
node_capture_hooks -->|"saves PNG"| node_shot_files
node_capture_hooks -->|"sends notices"| node_tray_runtime
node_tray_runtime -->|"starts capture"| node_capture_hooks
node_user -->|"opens gallery"| node_tray_runtime
node_gallery_ui -.->|"requests gallery"| node_gallery_commands
node_gallery_commands -->|"lists shots"| node_shot_files
node_gallery_ui -.->|"searches notes"| node_notes_logic
node_gallery_commands -.->|"loads settings"| node_settings_logic
node_settings_logic -.->|"reads and writes"| node_settings_file
node_gallery_commands -.->|"updates notes"| node_notes_logic
node_notes_logic -->|"reads and writes"| node_notes_file
node_user -->|"opens magnifier"| node_lens_ui
node_gallery_commands -->|"opens window"| node_lens_ui
node_user -->|"edits image"| node_editor_ui
node_gallery_commands -->|"opens window"| node_editor_ui
node_gallery_ui -.->|"requests image actions"| node_image_commands
node_image_commands -->|"reads and saves"| node_shot_files
node_image_commands -->|"recognizes text"| node_ocr_engine
node_user -->|"copies or saves"| node_markdown_tools
node_markdown_tools -->|"gets OCR text"| node_ocr_engine
node_markdown_tools -->|"reads images"| node_shot_files
node_native_dialogs -->|"normalizes days"| node_settings_logic
node_native_dialogs -->|"gets dialog text"| node_localization
node_capture_hooks -->|"uses native capture"| node_windows_api

click node_capture_hooks "https://github.com/elkeipy/agsnaptool/blob/master/src/win.rs"
click node_capture_geometry "https://github.com/elkeipy/agsnaptool/blob/master/src/rect.rs"
click node_shot_files "https://github.com/elkeipy/agsnaptool/blob/master/src/win.rs"
click node_tray_runtime "https://github.com/elkeipy/agsnaptool/blob/master/src/main.rs"
click node_gallery_ui "https://github.com/elkeipy/agsnaptool/blob/master/ui/app.js"
click node_gallery_commands "https://github.com/elkeipy/agsnaptool/blob/master/src/main.rs"
click node_lens_ui "https://github.com/elkeipy/agsnaptool/blob/master/ui/app.js"
click node_editor_ui "https://github.com/elkeipy/agsnaptool/blob/master/ui/app.js"
click node_image_commands "https://github.com/elkeipy/agsnaptool/blob/master/src/main.rs"
click node_ocr_engine "https://github.com/elkeipy/agsnaptool/blob/master/src/ocr.rs"
click node_markdown_tools "https://github.com/elkeipy/agsnaptool/blob/master/src/main.rs"
click node_settings_logic "https://github.com/elkeipy/agsnaptool/blob/master/src/logic.rs"
click node_settings_file "https://github.com/elkeipy/agsnaptool/blob/master/src/logic.rs"
click node_notes_logic "https://github.com/elkeipy/agsnaptool/blob/master/src/logic.rs"
click node_notes_file "https://github.com/elkeipy/agsnaptool/blob/master/src/logic.rs"
click node_localization "https://github.com/elkeipy/agsnaptool/blob/master/src/strings.rs"
click node_native_dialogs "https://github.com/elkeipy/agsnaptool/blob/master/src/dialogs.rs"
click node_windows_api "https://github.com/elkeipy/agsnaptool/blob/master/src/win.rs"

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_capture_hooks,node_capture_geometry,node_shot_files,node_user toneBlue
class node_gallery_ui,node_gallery_commands,node_lens_ui,node_editor_ui,node_image_commands,node_ocr_engine,node_markdown_tools toneAmber
class node_settings_logic,node_settings_file,node_notes_logic,node_notes_file toneMint
class node_tray_runtime,node_localization,node_native_dialogs,node_windows_api toneRose
```

## Components

### Capture

- [Capture hooks](https://github.com/elkeipy/agsnaptool/blob/master/src/win.rs): `src/win.rs`
- [Capture geometry](https://github.com/elkeipy/agsnaptool/blob/master/src/rect.rs): `src/rect.rs`
- [Shot PNG files](https://github.com/elkeipy/agsnaptool/blob/master/src/win.rs): `src/win.rs`

### Gallery and tools

- [Gallery UI](https://github.com/elkeipy/agsnaptool/blob/master/ui/app.js): `ui/app.js`
- [Gallery commands](https://github.com/elkeipy/agsnaptool/blob/master/src/main.rs): `src/main.rs`
- [Magnifier UI](https://github.com/elkeipy/agsnaptool/blob/master/ui/app.js): `ui/app.js`
- [Editor UI](https://github.com/elkeipy/agsnaptool/blob/master/ui/app.js): `ui/app.js`
- [Image commands](https://github.com/elkeipy/agsnaptool/blob/master/src/main.rs): `src/main.rs`
- [Windows OCR](https://github.com/elkeipy/agsnaptool/blob/master/src/ocr.rs): `src/ocr.rs`
- [Markdown tools](https://github.com/elkeipy/agsnaptool/blob/master/src/main.rs): `src/main.rs`

### Library and settings

- [Settings and rules](https://github.com/elkeipy/agsnaptool/blob/master/src/logic.rs): `src/logic.rs`
- [Settings file](https://github.com/elkeipy/agsnaptool/blob/master/src/logic.rs): `src/logic.rs`
- [Notes and tags](https://github.com/elkeipy/agsnaptool/blob/master/src/logic.rs): `src/logic.rs`
- [Notes file](https://github.com/elkeipy/agsnaptool/blob/master/src/logic.rs): `src/logic.rs`

### Platform support

- [Tray runtime](https://github.com/elkeipy/agsnaptool/blob/master/src/main.rs): `src/main.rs`
- [Localization](https://github.com/elkeipy/agsnaptool/blob/master/src/strings.rs): `src/strings.rs`
- [Native dialogs](https://github.com/elkeipy/agsnaptool/blob/master/src/dialogs.rs): `src/dialogs.rs`
- [Windows integration](https://github.com/elkeipy/agsnaptool/blob/master/src/win.rs): `src/win.rs`

### Other components

- **User**

## Connections

- User → Capture hooks: gestures (evidence: `README.md`)
- Capture hooks → Capture geometry: uses bounds (evidence: `src/win.rs`)
- Capture hooks → Shot PNG files: saves PNG (evidence: `README.md`)
- Capture hooks → Tray runtime: sends notices (evidence: `src/win.rs`)
- Tray runtime → Capture hooks: starts capture (evidence: `src/main.rs`)
- User → Tray runtime: opens gallery (evidence: `README.md`)
- Gallery UI → Gallery commands: requests gallery (evidence: `README.md`)
- Gallery commands → Shot PNG files: lists shots (evidence: `README.md`)
- Gallery UI → Notes and tags: searches notes (evidence: `README.md`)
- Gallery commands → Settings and rules: loads settings (evidence: `README.md`)
- Settings and rules → Settings file: reads and writes (evidence: `README.md`)
- Gallery commands → Notes and tags: updates notes (evidence: `README.md`)
- Notes and tags → Notes file: reads and writes (evidence: `src/logic.rs`)
- User → Magnifier UI: opens magnifier (evidence: `README.md`)
- Gallery commands → Magnifier UI: opens window (evidence: `src/main.rs`)
- User → Editor UI: edits image (evidence: `README.md`)
- Gallery commands → Editor UI: opens window (evidence: `src/main.rs`)
- Gallery UI → Image commands: requests image actions (evidence: `README.md`)
- Image commands → Shot PNG files: reads and saves (evidence: `README.md`)
- Image commands → Windows OCR: recognizes text (evidence: `src/main.rs`)
- User → Markdown tools: copies or saves (evidence: `README.md`)
- Markdown tools → Windows OCR: gets OCR text (evidence: `src/main.rs`)
- Markdown tools → Shot PNG files: reads images (evidence: `README.md`)
- Native dialogs → Settings and rules: normalizes days (evidence: `src/dialogs.rs`)
- Native dialogs → Localization: gets dialog text (evidence: `src/dialogs.rs`)
- Capture hooks → Windows integration: uses native capture (evidence: `src/win.rs`)
