How xdadda/mini-photo-editor works
Project type and purpose
• From the file tree and README, this is a single-page, client-side, WebGL2-powered image editor (“mini-img-editor”).
• It uses Vite as the build tool, mini-js for UI utilities, and mini-gl for WebGL abstractions. The entire app lives in the browser—there is no backend service.
File structure
• Top-level:
• src/ → source code
• vite.config.js → build configuration
• src/ subdivided into:
• components/ → React-style, self-contained UI components (cropper, colorcurve, histogram, etc.)
• js/ → lower-level utilities (tools.js, zoom_pan.js)
• “_”-prefixed modules → core image-processing routines (filters, curves, composition, adjustments)
• main.js + app.js + CSS files → application entrypoints and global styling
Key insights from the README
• It’s deployed as a static site (Netlify link)
• Powered by two core libraries (mini-js, mini-gl) for UI and WebGL respectively
• In-browser photo editing via WebGL2
a. Main components to represent
• Browser UI Layer
– State & routing (mini-js)
• Image Processing Layer
– Core modules: _adjustments.js, _composition.js, _curves.js, _filters.js
– WebGL2 rendering context (mini-gl) + shaders
– LUT assets
– Web Worker (histogram_worker.js)
• Build & Deployment
– Vite bundler (vite.config.js) → produces index.html + bundled JS/CSS in public/
– Netlify (static hosting)
• External Libraries
– mini-js
– mini-gl
b. Relationships & interactions
1. User interacts with UI components → dispatches events to app.js
2. app.js coordinates data:
– Loads image into WebGL texture
– Routes parameter changes to core modules
3. Core modules feed into mini-gl context → shader execution → framebuffers → canvas
4. Histogram module offloaded to Web Worker → posts results back to UI
5. DownloadImage component reads final canvas output → triggers file save
6. Vite handles dev server and bundling; public/ assets injected at build time
c. Architectural patterns & principles
• Component-based UI
• Separation of concerns:
• Presentation (components + state)
• Business logic (JS tools + processing modules)
• Rendering (WebGL)
• Offload compute-heavy tasks (histogram) to Web Worker
• Static, client-only deployment
d. Key technologies/frameworks
• WebGL2 (via mini-gl)
• mini-js (lightweight UI state management)
• Vite (build tool)
• Web Worker API
• ES modules + modern CSS modules
Summary checklist
• [ ] UI layer with individual components
• [ ] Core image-processing modules
• [ ] WebGL2 context (mini-gl) and LUT assets
• [ ] Web Worker for histogram
• [ ] Build & Deployment (Vite + Netlify)
• [ ] External libraries (mini-js, mini-gl)