StylePrint is a prototype for extracting design facets from UI reference screenshots, mixing style choices across references, and generating React + Tailwind UI code.
The app is split into a Vite React frontend and a Fastify TypeScript backend.
- Production website: https://style-print.vercel.app/
- Local web app: http://localhost:5173
- Local API health check: http://localhost:4000/health
StylePrint helps turn visual UI references into reusable generation inputs:
- Upload UI reference screenshots.
- Extract design facets such as color, typography, layout, spacing, component style, and mood.
- Choose or recommend recipes that combine facets from multiple references.
- Evaluate intent coherence, conflicts, and possible repairs.
- Generate React + Tailwind UI code through v0.
- Build preview artifacts and compare generated output against the intended style.
apps/
web/ Vite + React + TypeScript frontend
api/ Fastify + TypeScript API server
packages/
shared/ shared frontend/backend TypeScript types
data/ local JSON storage
public/
uploads/ uploaded reference images
Branches follow this flow:
main -> dev -> feature/*
main: stable branch.dev: integration branch for active development.feature/*: feature or issue-specific work.
Recommended workflow:
- Create or identify the GitHub Issue for the task.
- Create a
feature/*branch fromdev. - Implement the feature.
- Run
npm run typecheck. - Run
npm run buildwhen the change affects broader frontend/backend behavior. - Open a PR from
feature/*todev. - Keep planning docs, weekly deliverables, and agent workflow notes in the GitHub Wiki.
Install dependencies and create a local environment file:
cd /Users/Owner/hcclab/style-print-jung
npm install
cp .env.local.example .env.localAdd real API keys to .env.local in the project root.
Start both the frontend and backend:
npm run devThen open the web app and check the API:
open http://localhost:5173
curl http://localhost:4000/healthYou can also run the API and web app in separate terminals:
npm run dev:apinpm run dev:webThe local environment file lives at:
/Users/Owner/hcclab/style-print-jung/.env.local
Create it from the example file if it does not exist:
cp .env.local.example .env.localExpected values:
OPENAI_API_KEY=sk-...
OPENAI_MODEL=gpt-4.1-mini
OPENAI_JUDGE_MODEL=gpt-4.1-mini
V0_API_KEY=...
V0_MODEL=v0-mini
API_PORT=4000
WEB_ORIGIN=http://localhost:5173
VITE_API_BASE_URL=OPENAI_API_KEY and V0_API_KEY are required. If either key is missing, or if an external API call fails, the relevant API request fails instead of falling back to mock data.
OPENAI_JUDGE_MODEL is optional. Use it to separate the coherence judge model from the main OPENAI_MODEL; if it is not set, the API uses OPENAI_MODEL.
WEB_ORIGIN accepts multiple frontend origins separated by commas. For example:
WEB_ORIGIN=https://style-print.vercel.app,https://style-print-git-dev.vercel.app- The web app uploads reference images as
multipart/form-data. - The API stores images in
public/uploadsand records file URL, MIME type, width, and height metadata indata/references.json. - The API extracts palette, semantic color roles, and contrast information with
sharpand rule-based color analysis. - The OpenAI Responses API analyzes typography, layout, spacing, component style, and mood keywords from the same reference.
- Recipe recommendation or manual recipe selection creates an
IntentSpec; selected facet provenance, source mood, and confidence are normalized intostyleContext. - The API runs rule-based coherence evaluation and can add an OpenAI judge evaluation in
off,shadow, orprimarymode. - The UI generation brief, screen plan, and variant count are saved in
IntentSpec.generationBriefand passed into the v0 prompt. - v0 generation runs as an async job.
/api/generate/v0returns a job ID, and the web app polls/api/generate/jobs/:jobIdfor generated code and preview URLs. - The API builds preview artifacts locally and stores a Playwright screenshot when available.
- OpenAI audit extracts facets from generated code and stores an intent comparison report with provenance badges.
| Endpoint | Method | Description |
|---|---|---|
/health |
GET |
Check API status. |
/uploads/:filename |
GET |
Serve uploaded images. |
/generated-previews/:previewId/:filename |
GET |
Serve generated preview artifact files. |
/api/references/upload |
GET |
List references. |
/api/references/upload |
POST |
Upload a multipart reference image. |
/api/references/upload?id=... |
DELETE |
Delete a reference. |
/api/facets/extract |
POST |
Extract facets from a reference. |
/api/intents/create |
POST |
Create an intent from a selected recipe. |
/api/recipes/recommend |
POST |
Recommend recipes from a facet pack. |
/api/intents/evaluate |
POST |
Evaluate intent coherence and conflicts, then save repair suggestions. judgeMode can be off, shadow, or primary. |
/api/intents/apply-repair |
POST |
Apply a repair suggestion. |
/api/coherence/feedback |
POST |
Save feedback for coherence judge results. |
/api/generate/v0 |
POST |
Create a v0 UI generation job. Only single mode is currently supported. |
/api/generate/jobs/:jobId |
GET |
Read generation job status and result. |
/api/preview/build |
POST |
Build preview artifacts from generated code. |
/api/audit/analyze |
POST |
Audit generated code. If generatedCodeId is provided, link the audit to that report. |
- Reference extraction uses rule-based color analysis and OpenAI LLM analysis for typography, layout, spacing, component style, and mood.
- LLM prompts receive palette and asset dimensions so they do not over-infer layout from non-UI assets.
- v0 prompts receive normalized facets, exact palette usage, source mood/confidence, user brief, screen plan, and variant count.
- v0 generation currently produces one default-export React component.
GenerationModestill includesstaged, but the server does not implement staged generation yet./api/generate/v0rejects staged requests with400.- Missing API keys or failed external API calls do not produce demo/mock results.
Run focused checks during development:
npm run typecheck
npm run test
npm run build
npm run regression:intents
npm run agreement:coherencenpm run build runs backend/frontend type checks and then builds the Vite app for production.
npm run regression:intents compares saved intent coherence reports for regressions.
npm run agreement:coherence outputs a Markdown report comparing rule evaluator results, OpenAI judge results, and human feedback expected scores.
Run the deployment smoke check with:
npm run smoke:deployTo smoke check specific deployed URLs, pass them as environment variables:
SMOKE_API_BASE_URL=https://style-print-jung-api.up.railway.app \
SMOKE_WEB_BASE_URL=https://style-print.vercel.app \
npm run smoke:deploy- OpenAI and v0 API calls require valid API keys.
- Staged generation is represented in shared types but is not implemented on the server.
- Storage is JSON-file based; multi-user or production deployments need a database and durable object storage such as SQLite/PostgreSQL plus S3/R2.
- Authentication and per-user data isolation are not implemented yet.