How 302ai/302_ecom_image_generator works
This is a browser-based AI e-commerce scene-image generator. Users provide a product or model image plus scene text or an image, choose generation settings, then review, edit, and download generated images or videos. The main flow runs from the landing form through the image workspace and generation handlers to 302.AI services. Local browser storage supports task state and creation history; the README also documents lighting modes, model selection, regeneration, and Chinese, English, and Japanese interfaces. Some generation handlers and workspace logic were only partially excerpted, so uncertain internal call details are omitted.
Main entry points: ImageUpscaler.tsx Image workspace · Landing.tsx Input form · api.ts API services · page.tsx App page
Components 21
User experience
- App page
src/app/(land)/page.tsx - Input form
src/components/Landing.tsx - Example picker
src/components/Example.tsx - History drawer
src/components/HistoryDrawer.tsx
Creation workflow
- Image workspace
src/components/ImageUpscaler.tsx - Image editor
src/components/ImageEditor.tsx - Image compare
src/components/ImageCompare.tsx - Prompt settings
src/components/PromptModal.tsx - Aspect controls
src/components/RatioBox.tsx - Scene controls
src/components/SceneBar.tsx - Action controls
src/components/ActionBar.tsx - Progress display
src/components/ProgressBar.tsx - Video player
src/components/VideoPlayer.tsx
Generation runtime
- Generation handlers
src/app/(land)/query.ts - API services
src/libs/api.ts - 302.AI services
- Image utilities
src/utils/Image.ts
State and localization
- Browser storage
src/utils/Storage.ts - Translations
src/locales - System utilities
src/utils/System.ts
Other components
- Creator
Connections 26
- Creator → Input form: provides inputs
src/components/Landing.tsx - Input form → App page: sets selected file
src/app/(land)/page.tsx - App page → Image workspace: renders for file
src/app/(land)/page.tsx - App page → Input form: renders without file
src/app/(land)/page.tsx - Input form → Example picker: renders examples
src/components/Landing.tsx - Input form → History drawer: opens history
src/components/Landing.tsx - Image workspace → Generation handlers: receives generation callbacks
src/app/(land)/page.tsx - Image workspace → Image editor: loads editor
src/components/ImageUpscaler.tsx - Image workspace → Image compare: uses comparison view
src/components/ImageUpscaler.tsx - Image workspace → Prompt settings: renders prompt settings
src/components/ImageUpscaler.tsx - Image workspace → Aspect controls: renders ratio controls
src/components/ImageUpscaler.tsx - Image workspace → Scene controls: renders scene controls
src/components/ImageUpscaler.tsx - Image workspace → Action controls: renders action controls
src/components/ImageUpscaler.tsx - Image workspace → Progress display: renders progress
src/components/ImageUpscaler.tsx - Image workspace → Video player: renders video player
src/components/ImageUpscaler.tsx - Generation handlers → API services: uploads and describes images
src/app/(land)/query.ts - Generation handlers → 302.AI services: submits and polls tasks
src/app/(land)/query.ts - API services → 302.AI services: sends API requests
src/libs/api.ts - Generation handlers → Image utilities: reads and converts images
src/app/(land)/query.ts - Image workspace → API services: reads and updates tasks
src/components/ImageUpscaler.tsx - History drawer → API services: loads and clears history
src/components/HistoryDrawer.tsx - History drawer → System utilities: downloads results
src/components/HistoryDrawer.tsx - API services → Browser storage: persists browser data
src/libs/api.ts - System utilities → Image utilities: converts images
src/utils/System.ts - App page → Translations: uses interface text
src/app/(land)/page.tsx - Input form → Translations: uses interface text
src/components/Landing.tsx