# 302ai/302_ecom_image_generator architecture

> Architecture diagram of the GitHub repository 302ai/302_ecom_image_generator, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-10-01). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/302ai/302_ecom_image_generator
- Repository: https://github.com/302ai/302_ecom_image_generator

## Overview

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: [`src/components/ImageUpscaler.tsx`](https://github.com/302ai/302_ecom_image_generator/blob/main/src/components/ImageUpscaler.tsx) (Image workspace), [`src/components/Landing.tsx`](https://github.com/302ai/302_ecom_image_generator/blob/main/src/components/Landing.tsx) (Input form), [`src/libs/api.ts`](https://github.com/302ai/302_ecom_image_generator/blob/main/src/libs/api.ts) (API services), [`src/app/(land)/page.tsx`](https://github.com/302ai/302_ecom_image_generator/blob/main/src/app/(land)/page.tsx) (App page)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_experience["User experience"]
  node_page["App page<br/>[page.tsx]"]
  node_landing["Input form<br/>[Landing.tsx]"]
  node_examples["Example picker<br/>[Example.tsx]"]
  node_history["History drawer<br/>[HistoryDrawer.tsx]"]
end

subgraph group_creation["Creation workflow"]
  node_workspace["Image workspace<br/>[ImageUpscaler.tsx]"]
  node_editor["Image editor<br/>[ImageEditor.tsx]"]
  node_compare["Image compare<br/>[ImageCompare.tsx]"]
  node_prompt["Prompt settings<br/>[PromptModal.tsx]"]
  node_ratio["Aspect controls<br/>[RatioBox.tsx]"]
  node_scene["Scene controls<br/>[SceneBar.tsx]"]
  node_actions["Action controls<br/>[ActionBar.tsx]"]
  node_progress["Progress display<br/>[ProgressBar.tsx]"]
  node_video["Video player<br/>[VideoPlayer.tsx]"]
end

subgraph group_runtime["Generation runtime"]
  node_handlers["Generation handlers<br/>[query.ts]"]
  node_api["API services<br/>[api.ts]"]
  node_provider{{"302.AI services"}}
  node_image["Image utilities<br/>[Image.ts]"]
end

subgraph group_support["State and localization"]
  node_storage[("Browser storage<br/>[Storage.ts]")]
  node_locales["Translations"]
  node_system["System utilities<br/>[System.ts]"]
end

node_user(("Creator"))

node_user -->|"provides inputs"| node_landing
node_landing -->|"sets selected file"| node_page
node_page -->|"renders for file"| node_workspace
node_page -->|"renders without file"| node_landing
node_landing -->|"renders examples"| node_examples
node_landing -->|"opens history"| node_history
node_workspace -->|"receives generation callbacks"| node_handlers
node_workspace -->|"loads editor"| node_editor
node_workspace -->|"uses comparison view"| node_compare
node_workspace -->|"renders prompt settings"| node_prompt
node_workspace -->|"renders ratio controls"| node_ratio
node_workspace -->|"renders scene controls"| node_scene
node_workspace -->|"renders action controls"| node_actions
node_workspace -->|"renders progress"| node_progress
node_workspace -->|"renders video player"| node_video
node_handlers -->|"uploads and describes images"| node_api
node_handlers -->|"submits and polls tasks"| node_provider
node_api -->|"sends API requests"| node_provider
node_handlers -->|"reads and converts images"| node_image
node_workspace -->|"reads and updates tasks"| node_api
node_history -->|"loads and clears history"| node_api
node_history -->|"downloads results"| node_system
node_api -->|"persists browser data"| node_storage
node_system -->|"converts images"| node_image
node_page -->|"uses interface text"| node_locales
node_landing -->|"uses interface text"| node_locales

click node_page "https://github.com/302ai/302_ecom_image_generator/blob/main/src/app/(land)/page.tsx"
click node_landing "https://github.com/302ai/302_ecom_image_generator/blob/main/src/components/Landing.tsx"
click node_examples "https://github.com/302ai/302_ecom_image_generator/blob/main/src/components/Example.tsx"
click node_history "https://github.com/302ai/302_ecom_image_generator/blob/main/src/components/HistoryDrawer.tsx"
click node_workspace "https://github.com/302ai/302_ecom_image_generator/blob/main/src/components/ImageUpscaler.tsx"
click node_editor "https://github.com/302ai/302_ecom_image_generator/blob/main/src/components/ImageEditor.tsx"
click node_compare "https://github.com/302ai/302_ecom_image_generator/blob/main/src/components/ImageCompare.tsx"
click node_prompt "https://github.com/302ai/302_ecom_image_generator/blob/main/src/components/PromptModal.tsx"
click node_ratio "https://github.com/302ai/302_ecom_image_generator/blob/main/src/components/RatioBox.tsx"
click node_scene "https://github.com/302ai/302_ecom_image_generator/blob/main/src/components/SceneBar.tsx"
click node_actions "https://github.com/302ai/302_ecom_image_generator/blob/main/src/components/ActionBar.tsx"
click node_progress "https://github.com/302ai/302_ecom_image_generator/blob/main/src/components/ProgressBar.tsx"
click node_video "https://github.com/302ai/302_ecom_image_generator/blob/main/src/components/VideoPlayer.tsx"
click node_handlers "https://github.com/302ai/302_ecom_image_generator/blob/main/src/app/(land)/query.ts"
click node_api "https://github.com/302ai/302_ecom_image_generator/blob/main/src/libs/api.ts"
click node_image "https://github.com/302ai/302_ecom_image_generator/blob/main/src/utils/Image.ts"
click node_storage "https://github.com/302ai/302_ecom_image_generator/blob/main/src/utils/Storage.ts"
click node_locales "https://github.com/302ai/302_ecom_image_generator/tree/main/src/locales"
click node_system "https://github.com/302ai/302_ecom_image_generator/blob/main/src/utils/System.ts"

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_page,node_landing,node_examples,node_history toneBlue
class node_workspace,node_editor,node_compare,node_prompt,node_ratio,node_scene,node_actions,node_progress,node_video toneAmber
class node_handlers,node_api,node_provider,node_image toneMint
class node_storage,node_locales,node_system toneRose
class node_user toneIndigo
```

## Components

### User experience

- [App page](https://github.com/302ai/302_ecom_image_generator/blob/main/src/app/(land)/page.tsx): `src/app/(land)/page.tsx`
- [Input form](https://github.com/302ai/302_ecom_image_generator/blob/main/src/components/Landing.tsx): `src/components/Landing.tsx`
- [Example picker](https://github.com/302ai/302_ecom_image_generator/blob/main/src/components/Example.tsx): `src/components/Example.tsx`
- [History drawer](https://github.com/302ai/302_ecom_image_generator/blob/main/src/components/HistoryDrawer.tsx): `src/components/HistoryDrawer.tsx`

### Creation workflow

- [Image workspace](https://github.com/302ai/302_ecom_image_generator/blob/main/src/components/ImageUpscaler.tsx): `src/components/ImageUpscaler.tsx`
- [Image editor](https://github.com/302ai/302_ecom_image_generator/blob/main/src/components/ImageEditor.tsx): `src/components/ImageEditor.tsx`
- [Image compare](https://github.com/302ai/302_ecom_image_generator/blob/main/src/components/ImageCompare.tsx): `src/components/ImageCompare.tsx`
- [Prompt settings](https://github.com/302ai/302_ecom_image_generator/blob/main/src/components/PromptModal.tsx): `src/components/PromptModal.tsx`
- [Aspect controls](https://github.com/302ai/302_ecom_image_generator/blob/main/src/components/RatioBox.tsx): `src/components/RatioBox.tsx`
- [Scene controls](https://github.com/302ai/302_ecom_image_generator/blob/main/src/components/SceneBar.tsx): `src/components/SceneBar.tsx`
- [Action controls](https://github.com/302ai/302_ecom_image_generator/blob/main/src/components/ActionBar.tsx): `src/components/ActionBar.tsx`
- [Progress display](https://github.com/302ai/302_ecom_image_generator/blob/main/src/components/ProgressBar.tsx): `src/components/ProgressBar.tsx`
- [Video player](https://github.com/302ai/302_ecom_image_generator/blob/main/src/components/VideoPlayer.tsx): `src/components/VideoPlayer.tsx`

### Generation runtime

- [Generation handlers](https://github.com/302ai/302_ecom_image_generator/blob/main/src/app/(land)/query.ts): `src/app/(land)/query.ts`
- [API services](https://github.com/302ai/302_ecom_image_generator/blob/main/src/libs/api.ts): `src/libs/api.ts`
- **302.AI services**
- [Image utilities](https://github.com/302ai/302_ecom_image_generator/blob/main/src/utils/Image.ts): `src/utils/Image.ts`

### State and localization

- [Browser storage](https://github.com/302ai/302_ecom_image_generator/blob/main/src/utils/Storage.ts): `src/utils/Storage.ts`
- [Translations](https://github.com/302ai/302_ecom_image_generator/tree/main/src/locales): `src/locales`
- [System utilities](https://github.com/302ai/302_ecom_image_generator/blob/main/src/utils/System.ts): `src/utils/System.ts`

### Other components

- **Creator**

## Connections

- Creator → Input form: provides inputs (evidence: `src/components/Landing.tsx`)
- Input form → App page: sets selected file (evidence: `src/app/(land)/page.tsx`)
- App page → Image workspace: renders for file (evidence: `src/app/(land)/page.tsx`)
- App page → Input form: renders without file (evidence: `src/app/(land)/page.tsx`)
- Input form → Example picker: renders examples (evidence: `src/components/Landing.tsx`)
- Input form → History drawer: opens history (evidence: `src/components/Landing.tsx`)
- Image workspace → Generation handlers: receives generation callbacks (evidence: `src/app/(land)/page.tsx`)
- Image workspace → Image editor: loads editor (evidence: `src/components/ImageUpscaler.tsx`)
- Image workspace → Image compare: uses comparison view (evidence: `src/components/ImageUpscaler.tsx`)
- Image workspace → Prompt settings: renders prompt settings (evidence: `src/components/ImageUpscaler.tsx`)
- Image workspace → Aspect controls: renders ratio controls (evidence: `src/components/ImageUpscaler.tsx`)
- Image workspace → Scene controls: renders scene controls (evidence: `src/components/ImageUpscaler.tsx`)
- Image workspace → Action controls: renders action controls (evidence: `src/components/ImageUpscaler.tsx`)
- Image workspace → Progress display: renders progress (evidence: `src/components/ImageUpscaler.tsx`)
- Image workspace → Video player: renders video player (evidence: `src/components/ImageUpscaler.tsx`)
- Generation handlers → API services: uploads and describes images (evidence: `src/app/(land)/query.ts`)
- Generation handlers → 302.AI services: submits and polls tasks (evidence: `src/app/(land)/query.ts`)
- API services → 302.AI services: sends API requests (evidence: `src/libs/api.ts`)
- Generation handlers → Image utilities: reads and converts images (evidence: `src/app/(land)/query.ts`)
- Image workspace → API services: reads and updates tasks (evidence: `src/components/ImageUpscaler.tsx`)
- History drawer → API services: loads and clears history (evidence: `src/components/HistoryDrawer.tsx`)
- History drawer → System utilities: downloads results (evidence: `src/components/HistoryDrawer.tsx`)
- API services → Browser storage: persists browser data (evidence: `src/libs/api.ts`)
- System utilities → Image utilities: converts images (evidence: `src/utils/System.ts`)
- App page → Translations: uses interface text (evidence: `src/app/(land)/page.tsx`)
- Input form → Translations: uses interface text (evidence: `src/components/Landing.tsx`)
