Clone UI components from reference screenshots using a DesignCoder-inspired 3-phase hierarchy-aware pipeline. Generates plain CSS (no Tailwind).
Clone a reference UI screenshot into an HTML component using a hierarchy-aware 3-phase pipeline.
The This project uses a DesignCoder-inspired 3-phase pipeline that extracts hierarchy information before generating code — unlike single-pass screenshot-to-code tools, it it3-phase approach produces structurally correct HTML, not "flat div soup."
ui-loop-test/
├── main.py # CLI entry point
├── loop.py # Pipeline orchestration
├── config.py # Provider & pipeline settings
├── llm_client.py # OpenAI-compatible HTTP client
├── phases/
│ ├── phase1_grouping/
│ │ ├── division.py # 1.1 UI Division
│ │ ├── semantic.py # 1.2 Semantic Extraction
│ │ └── grouping.py # 1.3 Component Grouping
│ ├── phase2_codegen/
│ │ ├── html_gen.py # 2.1 HTML Generation
│ │ └── style_gen.py # 2.2 Style Generation (plain CSS)
│ └── phase3_refinement/
│ ├── matcher.py # 3.2 Component Matching
│ ├── comparator.py # 3.3 Visual Comparison (per-component SSIM)
│ └── repair.py # 3.4 Targeted Repair (BeautifulSoup)
├── utils/
│ ├── image.py # SSIM, color extraction, diff overlay
│ ├── dom.py # Playwright DOM extraction
│ └── metrics.py # TreeBLEU, ContainerMatch, TreeEditDist
├── storage/
│ └── component.py # Component state persistence (JSON)
├── src/ # SvelteKit viewer app
│ ├── routes/
│ │ ├── +page.svelte # Component list
│ │ ├── component/[id]/ # Component detail + preview
│ │ └── api/components/ # REST API for component data
│ └── lib/
├── output/ # Generated component files
└── ui-inspo/ # Reference images to clone
# Install dependencies
pip install -r requirements.txt
# Set API keys
export OPENROUTER_API_KEY=your_key
export FIREWORKS_API_KEY=your_key
# Run the full 3-phase pipeline
python main.py ui-inspo/sample.png --name my-component
# Run specific phases
python main.py ui-inspo/sample.png --phase 1 # Just analyze structure
python main.py ui-inspo/sample.png --phase 2 # Just generate code
python main.py ui-inspo/sample.png --phase 3 # Just refine
# Use different providers
python main.py ui-inspo/sample.png --provider fireworks
python main.py ui-inspo/sample.png --provider openrouter --vision-provider fireworks
extract_colors for the palette.The SvelteKit viewer shows live progress:
/ — List all components with status/component/[id] — Preview, iterations, diffs, activity feed/test — Phase 1 segmentation testingStart the dev server:
npm run dev
Create a .env file:
OPENROUTER_API_KEY=sk-or-v1-...
FIREWORKS_API_KEY=fw-...
DEFAULT_PROVIDER=openrouter