How raptorvampire/pollinations-image-lab works
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: generator.js Generation workflow · app.js Application bootstrap · api.js Pollinations API client · settings.js Generation settings
Components 13
Browser client
Static native-ES-module application.
- Application shell · Defines controls, preview, and user panels.
index.html - Presentation styles
css/style.css - Application bootstrap · Wires events, initializes state, and composes modules.
js/app.js - Generated image · Displayed and downloaded entirely in the browser.
Feature modules
- UI rendering · Renders inputs, preview, download, loading, and errors.
js/modules/ui.js - Generation workflow · Coordinates request construction, result display, and history insertion.
js/modules/generator.js - Pollinations API client · Discovers models and requests generated images.
js/modules/api.js - Generation settings · Stores preferences, parameters, and optional API key.
js/modules/settings.js - Prompt history · Stores prior prompts for recall.
js/modules/history.js - Defaults and API constants
js/modules/config.js - Shared utilities
js/modules/utils.js
External and browser services
- Browser storage · Persists settings and prompt history locally.
- Pollinations AI · Provides models and generated image responses.
Connections 19
- 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