# raptorvampire/pollinations-image-lab architecture

> Architecture diagram of the GitHub repository raptorvampire/pollinations-image-lab, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-07-18). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/raptorvampire/pollinations-image-lab
- Repository: https://github.com/raptorvampire/pollinations-image-lab

## Overview

#### Purpose and Runtime
Pollinations Image Lab is a static, browser-only client for generating images through Pollinations AI. It has no backend, package dependencies, or build step; modern browsers execute native ES modules. It can be hosted as static files, including GitHub Pages.

#### Entry and Composition
`index.html` defines the application shell, generation controls, preview area, and user-facing panels. `js/app.js` is the client bootstrap and orchestration entry point: it wires DOM events and composes feature modules. Presentation is supplied by `css/style.css`.

Paths: `index.html`, `js/app.js`, `css/style.css`.

#### UI and Interaction Boundary
The UI layer owns DOM rendering and user feedback: prompt entry, control values, generated-image preview, download affordance, loading/error states, and responsive interaction behavior. Application logic should remain separate from direct DOM manipulation by routing visual updates through this layer.

Path: `js/modules/ui.js`.

#### Generation Pipeline
Generation begins with user input and configured parameters, then constructs a Pollinations-compatible image request and updates UI state while the result loads. The generator component is the central workflow boundary between form/state inputs and a generated image URL or response; it likely coordinates request construction, result display, and history insertion.

Paths: `js/modules/generator.js`, `js/app.js`, `js/modules/utils.js`.

#### Pollinations API Integration
External communication is isolated in the API module. This boundary handles Pollinations AI access, including automatic discovery of available image models and image-generation requests. The browser communicates directly with Pollinations endpoints; API keys, when used, are supplied from client-side settings rather than a server-side secret store.

Paths: `js/modules/api.js`, `js/modules/config.js`.

#### Persistent User State
Settings persist generation preferences such as model, dimensions, seed, API key, and generation parameters across sessions using browser-native storage. Prompt history is a distinct persisted domain for recalling prior prompts, supporting productivity without requiring accounts or remote storage.

Paths: `js/modules/settings.js`, `js/modules/history.js`, `js/modules/config.js`.

#### Shared Configuration and Utilities
Configuration centralizes defaults and API-related constants used across modules. Utilities provide common transformations or browser helpers used by the generation, UI, and persistence flows, keeping feature modules narrowly scoped.

Paths: `js/modules/config.js`, `js/modules/utils.js`.

#### Primary Control Flow
On load, `js/app.js` initializes settings and history, requests or populates available models, and renders the initial interface. A generation action collects UI values, applies settings/defaults, calls the API/generator path, displays the resulting image, and records the prompt. Download operates entirely in the browser against the displayed generated image.

Paths: `js/app.js`, `js/modules/generator.js`, `js/modules/api.js`, `js/modules/history.js`.

Main entry points: [`js/modules/generator.js`](https://github.com/raptorvampire/pollinations-image-lab/blob/main/js/modules/generator.js) (Generation workflow), [`js/app.js`](https://github.com/raptorvampire/pollinations-image-lab/blob/main/js/app.js) (Application bootstrap), [`js/modules/api.js`](https://github.com/raptorvampire/pollinations-image-lab/blob/main/js/modules/api.js) (Pollinations API client), [`js/modules/settings.js`](https://github.com/raptorvampire/pollinations-image-lab/blob/main/js/modules/settings.js) (Generation settings)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_client["Browser client"]
  node_shell["Application shell<br/>HTML<br/>[index.html]"]
  node_styles["Presentation styles<br/>CSS<br/>[style.css]"]
  node_app["Application bootstrap<br/>orchestrator<br/>[app.js]"]
  node_image_result["Generated image<br/>browser image result"]
end

subgraph group_features["Feature modules"]
  node_ui["UI rendering<br/>DOM boundary<br/>[ui.js]"]
  node_generator["Generation workflow<br/>pipeline<br/>[generator.js]"]
  node_api["Pollinations API client<br/>API integration<br/>[api.js]"]
  node_settings["Generation settings<br/>persistent state<br/>[settings.js]"]
  node_history["Prompt history<br/>persistent state<br/>[history.js]"]
  node_config["Defaults and API constants<br/>configuration<br/>[config.js]"]
  node_utils["Shared utilities<br/>shared helpers<br/>[utils.js]"]
end

subgraph group_external["External and browser services"]
  node_browser_storage[("Browser storage<br/>local persistence")]
  node_pollinations{{"Pollinations AI<br/>external image API"}}
end

node_shell -->|"loads module"| node_app
node_shell -->|"applies"| node_styles
node_app -->|"initializes and routes updates"| node_ui
node_app -->|"loads preferences"| node_settings
node_app -->|"loads history"| node_history
node_app -->|"loads available models"| node_api
node_ui -->|"generation action and values"| node_generator
node_generator -->|"applies preferences"| node_settings
node_generator -->|"requests image"| node_api
node_generator -->|"updates loading and result state"| node_ui
node_generator -->|"records prompt"| node_history
node_generator -->|"uses transformations"| node_utils
node_api -->|"uses endpoint constants"| node_config
node_api -->|"browser request"| node_pollinations
node_settings -->|"uses defaults"| node_config
node_settings -->|"persists"| node_browser_storage
node_history -->|"persists"| node_browser_storage
node_api -->|"returns image URL or response"| node_image_result
node_image_result -->|"preview and download"| node_ui

click node_shell "https://github.com/raptorvampire/pollinations-image-lab/blob/main/index.html"
click node_styles "https://github.com/raptorvampire/pollinations-image-lab/blob/main/css/style.css"
click node_app "https://github.com/raptorvampire/pollinations-image-lab/blob/main/js/app.js"
click node_ui "https://github.com/raptorvampire/pollinations-image-lab/blob/main/js/modules/ui.js"
click node_generator "https://github.com/raptorvampire/pollinations-image-lab/blob/main/js/modules/generator.js"
click node_api "https://github.com/raptorvampire/pollinations-image-lab/blob/main/js/modules/api.js"
click node_settings "https://github.com/raptorvampire/pollinations-image-lab/blob/main/js/modules/settings.js"
click node_history "https://github.com/raptorvampire/pollinations-image-lab/blob/main/js/modules/history.js"
click node_config "https://github.com/raptorvampire/pollinations-image-lab/blob/main/js/modules/config.js"
click node_utils "https://github.com/raptorvampire/pollinations-image-lab/blob/main/js/modules/utils.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_shell,node_styles,node_app,node_image_result toneBlue
class node_ui,node_generator,node_api,node_settings,node_history,node_config,node_utils toneAmber
class node_browser_storage,node_pollinations toneMint
```

## Components

### Browser client

Static native-ES-module application.

- [Application shell](https://github.com/raptorvampire/pollinations-image-lab/blob/main/index.html): HTML · Defines controls, preview, and user panels. · `index.html`
- [Presentation styles](https://github.com/raptorvampire/pollinations-image-lab/blob/main/css/style.css): CSS · `css/style.css`
- [Application bootstrap](https://github.com/raptorvampire/pollinations-image-lab/blob/main/js/app.js): orchestrator · Wires events, initializes state, and composes modules. · `js/app.js`
- **Generated image**: browser image result · Displayed and downloaded entirely in the browser.

### Feature modules

- [UI rendering](https://github.com/raptorvampire/pollinations-image-lab/blob/main/js/modules/ui.js): DOM boundary · Renders inputs, preview, download, loading, and errors. · `js/modules/ui.js`
- [Generation workflow](https://github.com/raptorvampire/pollinations-image-lab/blob/main/js/modules/generator.js): pipeline · Coordinates request construction, result display, and history insertion. · `js/modules/generator.js`
- [Pollinations API client](https://github.com/raptorvampire/pollinations-image-lab/blob/main/js/modules/api.js): API integration · Discovers models and requests generated images. · `js/modules/api.js`
- [Generation settings](https://github.com/raptorvampire/pollinations-image-lab/blob/main/js/modules/settings.js): persistent state · Stores preferences, parameters, and optional API key. · `js/modules/settings.js`
- [Prompt history](https://github.com/raptorvampire/pollinations-image-lab/blob/main/js/modules/history.js): persistent state · Stores prior prompts for recall. · `js/modules/history.js`
- [Defaults and API constants](https://github.com/raptorvampire/pollinations-image-lab/blob/main/js/modules/config.js): configuration · `js/modules/config.js`
- [Shared utilities](https://github.com/raptorvampire/pollinations-image-lab/blob/main/js/modules/utils.js): shared helpers · `js/modules/utils.js`

### External and browser services

- **Browser storage**: local persistence · Persists settings and prompt history locally.
- **Pollinations AI**: external image API · Provides models and generated image responses.

## Connections

- Application shell → Application bootstrap: loads module
- Application shell → Presentation styles: applies
- Application bootstrap → UI rendering: initializes and routes updates
- Application bootstrap → Generation settings: loads preferences
- Application bootstrap → Prompt history: loads history
- Application bootstrap → Pollinations API client: loads available models
- UI rendering → Generation workflow: generation action and values
- Generation workflow → Generation settings: applies preferences
- Generation workflow → Pollinations API client: requests image
- Generation workflow → UI rendering: updates loading and result state
- Generation workflow → Prompt history: records prompt
- Generation workflow → Shared utilities: uses transformations
- Pollinations API client → Defaults and API constants: uses endpoint constants
- Pollinations API client → Pollinations AI: browser request
- Generation settings → Defaults and API constants: uses defaults
- Generation settings → Browser storage: persists
- Prompt history → Browser storage: persists
- Pollinations API client → Generated image: returns image URL or response
- Generated image → UI rendering: preview and download
