# kevinggundersen/thumbnail-animator architecture

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

- Interactive diagram: https://gitdiagram.com/kevinggundersen/thumbnail-animator
- Repository: https://github.com/kevinggundersen/thumbnail-animator

## Overview

1. **Overall shape**
   - This is a local-first Electron desktop app for browsing media folders, not a client/server system.
   - The core architecture is split into the standard Electron boundaries: **main process**, **renderer process**, **preload bridge**, plus a large set of **worker threads** for expensive media/indexing work.

2. **Main process**
   - `main.js` is the central orchestration layer: window lifecycle, app startup/shutdown, IPC endpoints, and OS-level file actions.
   - It is also the natural boundary for privileged operations such as opening folders/files, shell interactions, and coordinating native integrations.

3. **Renderer/UI shell**
   - `renderer.js` drives the visible application: folder browsing, thumbnail grid, filters/search, lightbox playback, settings, tabs, and navigation.
   - The rest of the UI is decomposed into feature modules such as `sidebar-tree.js`, `selection-manager.js`, `lightbox.js`, `filmstrip-scrubber.js`, `command-palette.js`, `context-menu.js`, `playback-controller.js`, and `settings-ui.js`.
   - `index.html` and `styles.css` provide the static shell and visual system; `themes.js` and `icons.js` handle theme/icon presentation.

4. **Secure renderer-to-main boundary**
   - `preload.js` is the security layer: it exposes a limited IPC API while keeping Node integration disabled and context isolation enabled.
   - This means the renderer owns UI state and interaction logic, but privileged filesystem/OS calls go through the preload → IPC → main-process path.

5. **Media indexing and processing pipeline**
   - The app offloads CPU-heavy work to dedicated workers: thumbnail generation, image decoding, dimension extraction, hashing, filter/sort, and clip preprocessing/inference.
   - Key files here include `thumbnail-worker.js`, `image-decode-worker.js`, `dimension-worker.js`, `hash-worker.js`, `filter-sort-worker.js`, `clip-preprocess-worker.js`, and `clip-inference-worker.js`.
   - `worker-pool.js` and helpers like `thumbnail-pool.js`, `hash-pool.js`, and `clip-preprocess-pool.js` manage concurrency and reuse.

6. **Data flow from folder to UI**
   - A folder selection or navigation action triggers scanning/indexing of local files.
   - Metadata and derived assets flow back into renderer state, which updates the sidebar tree, grid, filters, and lightbox.
   - Progressive/batched updates are important for large folders, so the UI can render before all derived data is ready.

7. **Persistence and caching**
   - `database.js`, `database-worker.js`, and `database-proxy.js` implement local persistence and async access patterns for cached metadata and app state.
   - The README’s 3-tier cache is reflected in the architecture: **memory cache → IndexedDB → disk cache**, reducing recomputation for thumbnails and metadata.
   - This is a single-user local data store, not a remote database.

8. **Plugin architecture**
   - `plugins/plugin-api.js` and `plugins/plugin-registry.js` provide an extension boundary for media-specific features.
   - Built-in plugins live under `plugins/builtin/` and cover metadata extraction/cleanup and format-specific inspection, including EXIF, Stable Diffusion metadata, ComfyUI workflows, PDF/PSD preview, and SVG inspection.
   - Plugins are a clear extension point for adding file-type-specific behavior without changing the core browser.

9. **Native and binary integrations**
   - `native-scanner/` is a Rust-based native module, likely used to accelerate scanning or hardware/GPU probing; it includes a small bundled ONNX asset (`gpu_probe.onnx`).
   - `webpxmux.wasm` indicates a WebAssembly codec/tooling path for image/video-related processing.
   - `fuse.vendor.js` and `gifuct-js-bundle.js` suggest vendored third-party code for search/image/GIF handling rather than a separate service boundary.

10. **File-system and OS actions**
    - The app is tightly coupled to the local filesystem: browsing folders, watching for changes, opening/revealing files, renaming, deleting, and organizing media.
    - These actions are surfaced through context menus and the lightbox, but the privileged file mutations are routed through the Electron main process.
    - Real-time folder updates are part of the runtime model, so the UI is reactive to filesystem changes.

11. **Performance-oriented subsystems**
    - `perf-dashboard.js` exposes runtime observability for caching, rendering, and processing throughput.
    - `duplicate-detection.js`, `webgpu-hamming.js`, and the hash pipeline suggest a focus on content comparison and accelerated similarity operations.
    - `canvas-grid.js`, `filter-sort-helpers.js`, and `renderer-features.js` support large-scale UI rendering and feature toggles.

12. **Packaging and release**
    - The app is packaged with Electron Builder, with Windows NSIS installer assets in `build/`.
    - `.github/workflows/release.yml` indicates an automated release pipeline, while `build/afterPack.js` and `build/installer.nsh` customize distribution packaging.
    - The repo is therefore organized as a desktop product with a local runtime plus release automation, not as a hosted backend system.

Main entry points: [`renderer.js`](https://github.com/kevinggundersen/thumbnail-animator/blob/main/renderer.js) (renderer.js), [`worker-pool.js`](https://github.com/kevinggundersen/thumbnail-animator/blob/main/worker-pool.js) (worker pool), [`main.js`](https://github.com/kevinggundersen/thumbnail-animator/blob/main/main.js) (main.js), [`database.js`](https://github.com/kevinggundersen/thumbnail-animator/blob/main/database.js) (database.js)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_g_main["Main process"]
  node_n_main["main.js<br/>electron main<br/>[main.js]"]
  node_n_preload["preload.js<br/>bridge<br/>[preload.js]"]
end

subgraph group_g_renderer["Renderer UI"]
  node_n_renderer["renderer.js<br/>ui shell<br/>[renderer.js]"]
  node_n_sidebar["sidebar tree<br/>ui module<br/>[sidebar-tree.js]"]
  node_n_lightbox["lightbox<br/>viewer<br/>[lightbox.js]"]
  node_n_scrubber["filmstrip<br/>ui module"]
  node_n_palette["command palette<br/>ui module<br/>[command-palette.js]"]
  node_n_context["context menu<br/>ui module<br/>[context-menu.js]"]
  node_n_settings_ui["settings UI<br/>ui module<br/>[settings-ui.js]"]
end

subgraph group_g_workers["Workers"]
  node_n_worker_pool["worker pool<br/>concurrency<br/>[worker-pool.js]"]
  node_n_thumb_worker["thumbnail worker<br/>image pipeline"]
  node_n_decode_worker["decode worker<br/>image pipeline"]
  node_n_hash_worker["hash worker<br/>analysis<br/>[hash-worker.js]"]
  node_n_clip_infer["clip inference<br/>ml worker"]
end

subgraph group_g_data["Data layer"]
  node_n_database[("database.js<br/>local store<br/>[database.js]")]
  node_n_db_worker["database worker<br/>async store<br/>[database-worker.js]"]
end

subgraph group_g_plugins["Plugins"]
  node_n_plugins_api["plugin API<br/>extension api<br/>[plugin-api.js]"]
  node_n_plugin_registry["plugin registry<br/>extension host<br/>[plugin-registry.js]"]
end

subgraph group_g_native["Native/binary"]
  node_n_native_scanner["native scanner<br/>rust addon<br/>[lib.rs]"]
  node_n_webpxmux["webpxmux.wasm<br/>wasm codec<br/>[webpxmux.wasm]"]
end

subgraph group_g_packaging["Packaging"]
  node_n_release["release workflow<br/>packaging<br/>[release.yml]"]
end

node_n_preload -->|"IPC calls"| node_n_main
node_n_renderer -->|"uses API"| node_n_preload
node_n_renderer -->|"composes"| node_n_sidebar
node_n_renderer -->|"opens viewer"| node_n_lightbox
node_n_renderer -->|"scrubs"| node_n_scrubber
node_n_renderer -->|"commands"| node_n_palette
node_n_renderer -->|"menus"| node_n_context
node_n_renderer -->|"preferences"| node_n_settings_ui
node_n_renderer -->|"reads cache"| node_n_database
node_n_main -->|"orchestrates"| node_n_database
node_n_database -->|"offloads"| node_n_db_worker
node_n_renderer -->|"dispatches"| node_n_worker_pool
node_n_worker_pool -->|"runs"| node_n_thumb_worker
node_n_worker_pool -->|"runs"| node_n_decode_worker
node_n_worker_pool -->|"runs"| node_n_hash_worker
node_n_worker_pool -->|"runs"| node_n_clip_infer
node_n_renderer -->|"extends"| node_n_plugins_api
node_n_plugin_registry -->|"implements"| node_n_plugins_api
node_n_plugin_registry -->|"adds features"| node_n_renderer
node_n_main -->|"loads"| node_n_native_scanner
node_n_renderer -.->|"uses codec"| node_n_webpxmux
node_n_main -->|"packages"| node_n_release

click node_n_main "https://github.com/kevinggundersen/thumbnail-animator/blob/main/main.js"
click node_n_preload "https://github.com/kevinggundersen/thumbnail-animator/blob/main/preload.js"
click node_n_renderer "https://github.com/kevinggundersen/thumbnail-animator/blob/main/renderer.js"
click node_n_sidebar "https://github.com/kevinggundersen/thumbnail-animator/blob/main/sidebar-tree.js"
click node_n_lightbox "https://github.com/kevinggundersen/thumbnail-animator/blob/main/lightbox.js"
click node_n_scrubber "https://github.com/kevinggundersen/thumbnail-animator/blob/main/filmstrip-scrubber.js"
click node_n_palette "https://github.com/kevinggundersen/thumbnail-animator/blob/main/command-palette.js"
click node_n_context "https://github.com/kevinggundersen/thumbnail-animator/blob/main/context-menu.js"
click node_n_settings_ui "https://github.com/kevinggundersen/thumbnail-animator/blob/main/settings-ui.js"
click node_n_worker_pool "https://github.com/kevinggundersen/thumbnail-animator/blob/main/worker-pool.js"
click node_n_thumb_worker "https://github.com/kevinggundersen/thumbnail-animator/blob/main/thumbnail-worker.js"
click node_n_decode_worker "https://github.com/kevinggundersen/thumbnail-animator/blob/main/image-decode-worker.js"
click node_n_hash_worker "https://github.com/kevinggundersen/thumbnail-animator/blob/main/hash-worker.js"
click node_n_clip_infer "https://github.com/kevinggundersen/thumbnail-animator/blob/main/clip-inference-worker.js"
click node_n_database "https://github.com/kevinggundersen/thumbnail-animator/blob/main/database.js"
click node_n_db_worker "https://github.com/kevinggundersen/thumbnail-animator/blob/main/database-worker.js"
click node_n_plugins_api "https://github.com/kevinggundersen/thumbnail-animator/blob/main/plugins/plugin-api.js"
click node_n_plugin_registry "https://github.com/kevinggundersen/thumbnail-animator/blob/main/plugins/plugin-registry.js"
click node_n_native_scanner "https://github.com/kevinggundersen/thumbnail-animator/blob/main/native-scanner/src/lib.rs"
click node_n_webpxmux "https://github.com/kevinggundersen/thumbnail-animator/blob/main/webpxmux.wasm"
click node_n_release "https://github.com/kevinggundersen/thumbnail-animator/blob/main/.github/workflows/release.yml"

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_n_main,node_n_preload,node_n_release toneBlue
class node_n_renderer,node_n_sidebar,node_n_lightbox,node_n_scrubber,node_n_palette,node_n_context,node_n_settings_ui toneAmber
class node_n_worker_pool,node_n_thumb_worker,node_n_decode_worker,node_n_hash_worker,node_n_clip_infer toneMint
class node_n_database,node_n_db_worker toneRose
class node_n_plugins_api,node_n_plugin_registry toneIndigo
class node_n_native_scanner,node_n_webpxmux toneTeal
```

## Components

### Main process

Electron privileged process, app lifecycle, IPC, and OS/file actions.

- [main.js](https://github.com/kevinggundersen/thumbnail-animator/blob/main/main.js): electron main · Window lifecycle, startup/shutdown, IPC handlers, and privileged OS/file actions. · `main.js`
- [preload.js](https://github.com/kevinggundersen/thumbnail-animator/blob/main/preload.js): bridge · Securely exposes a limited IPC API to the renderer with context isolation. · `preload.js`

### Renderer UI

Browser-side application shell and feature modules.

- [renderer.js](https://github.com/kevinggundersen/thumbnail-animator/blob/main/renderer.js): ui shell · Top-level browsing UI: navigation, grid, search, filters, and application state. · `renderer.js`
- [sidebar tree](https://github.com/kevinggundersen/thumbnail-animator/blob/main/sidebar-tree.js): ui module · Folder tree and browsing navigation for local media collections. · `sidebar-tree.js`
- [lightbox](https://github.com/kevinggundersen/thumbnail-animator/blob/main/lightbox.js): viewer · Full-screen/overlay media viewing and playback interactions. · `lightbox.js`
- [filmstrip](https://github.com/kevinggundersen/thumbnail-animator/blob/main/filmstrip-scrubber.js): ui module · Timeline/filmstrip scrubber for previewing animated media. · `filmstrip-scrubber.js`
- [command palette](https://github.com/kevinggundersen/thumbnail-animator/blob/main/command-palette.js): ui module · Keyboard-driven command launcher and quick actions. · `command-palette.js`
- [context menu](https://github.com/kevinggundersen/thumbnail-animator/blob/main/context-menu.js): ui module · Right-click actions for files, folders, and media items. · `context-menu.js`
- [settings UI](https://github.com/kevinggundersen/thumbnail-animator/blob/main/settings-ui.js): ui module · In-app preferences and configuration surfaces. · `settings-ui.js`

### Workers

CPU-heavy media processing and indexing tasks.

- [worker pool](https://github.com/kevinggundersen/thumbnail-animator/blob/main/worker-pool.js): concurrency · Shared worker management and task dispatch for expensive processing. · `worker-pool.js`
- [thumbnail worker](https://github.com/kevinggundersen/thumbnail-animator/blob/main/thumbnail-worker.js): image pipeline · Generates previews and derived thumbnail assets. · `thumbnail-worker.js`
- [decode worker](https://github.com/kevinggundersen/thumbnail-animator/blob/main/image-decode-worker.js): image pipeline · Decodes images for downstream processing and preview generation. · `image-decode-worker.js`
- [hash worker](https://github.com/kevinggundersen/thumbnail-animator/blob/main/hash-worker.js): analysis · Computes content hashes for duplicate detection and similarity features. · `hash-worker.js`
- [clip inference](https://github.com/kevinggundersen/thumbnail-animator/blob/main/clip-inference-worker.js): ml worker · Runs clip-based inference/preprocessing for media understanding. · `clip-inference-worker.js`

### Data layer

Local persistence, caches, and async database access.

- [database.js](https://github.com/kevinggundersen/thumbnail-animator/blob/main/database.js): local store · Local persistence for cached metadata and app state. · `database.js`
- [database worker](https://github.com/kevinggundersen/thumbnail-animator/blob/main/database-worker.js): async store · Background execution for persistence and cache access. · `database-worker.js`

### Plugins

Extension boundary and built-in file-type/media handlers.

- [plugin API](https://github.com/kevinggundersen/thumbnail-animator/blob/main/plugins/plugin-api.js): extension api · Contracts for media plugins and feature hooks. · `plugins/plugin-api.js`
- [plugin registry](https://github.com/kevinggundersen/thumbnail-animator/blob/main/plugins/plugin-registry.js): extension host · Loads and coordinates built-in plugins and plugin metadata. · `plugins/plugin-registry.js`

### Native/binary

Rust, WASM, and vendored accelerators used by the app.

- [native scanner](https://github.com/kevinggundersen/thumbnail-animator/blob/main/native-scanner/src/lib.rs): rust addon · Rust-based native module for accelerated scanning or probing. · `native-scanner/src/lib.rs`
- [webpxmux.wasm](https://github.com/kevinggundersen/thumbnail-animator/blob/main/webpxmux.wasm): wasm codec · WASM-based media processing/codec support. · `webpxmux.wasm`

### Packaging

Build and release automation for the desktop app.

- [release workflow](https://github.com/kevinggundersen/thumbnail-animator/blob/main/.github/workflows/release.yml): packaging · Electron Builder packaging and GitHub release automation. · `.github/workflows/release.yml`

## Connections

- preload.js → main.js: IPC calls · Renderer requests privileged operations through the secure bridge.
- renderer.js → preload.js: uses API · UI invokes the exposed bridge for filesystem and app actions.
- renderer.js → sidebar tree: composes · The shell renders folder navigation and browsing state.
- renderer.js → lightbox: opens viewer · Selected media flows into the overlay playback/viewing surface.
- renderer.js → filmstrip: scrubs · Animated media playback is coordinated with the filmstrip timeline.
- renderer.js → command palette: commands · Keyboard-driven actions and shortcuts are surfaced from the shell.
- renderer.js → context menu: menus · Context actions are attached to selected files and folders.
- renderer.js → settings UI: preferences · User configuration is edited in the renderer.
- renderer.js → database.js: reads cache · Renderer state is hydrated from local cached metadata.
- main.js → database.js: orchestrates · Main process coordinates persistence and app-level storage access.
- database.js → database worker: offloads · Database work is pushed into a background worker path.
- renderer.js → worker pool: dispatches · Heavy media tasks are sent to pooled workers.
- worker pool → thumbnail worker: runs · Thumbnail generation is one of the primary pooled jobs.
- worker pool → decode worker: runs · Image decoding feeds thumbnailing and metadata extraction.
- worker pool → hash worker: runs · Hashing supports duplicate detection and similarity queries.
- worker pool → clip inference: runs · ML-oriented preprocessing and inference are isolated in workers.
- renderer.js → plugin API: extends · Feature-specific behavior is added through a stable plugin boundary.
- plugin registry → plugin API: implements · Registry loads and wires plugins against the API contract.
- plugin registry → renderer.js: adds features · Plugins contribute file-type-specific inspection and cleanup behavior to the UI.
- main.js → native scanner: loads · Privileged runtime can access native acceleration for scanning/probing.
- renderer.js → webpxmux.wasm: uses codec · Media display and conversion paths can use the WASM module.
- main.js → release workflow: packages · Project distribution is built and published through release automation.
