Skip to content

Web builder (Phase 3D)

Phase 3D extends apps/web (@truongdq01/web) — a Next.js app with a /builder route for iterating on production-quality ScreenSchema JSON before wiring a real AI API.

Terminal window
bun install
bun run build # build workspace packages first
bun run web:dev # http://localhost:3000/builder

From the app directory:

Terminal window
cd apps/web
bun run dev

Production build:

Terminal window
bun run web:build
# or: cd apps/web && bun run build

Routes:

RoutePurpose
/Minimal placeholder landing
/builderMain builder — templates, preview, schema/code panels
PanelPurpose
ChatTemplate chips (instant load) + mock AI prompts
PreviewDevice frame + WebPreviewHost (react-native-web, light theme)
Schema & CodeJSON editor, validation, TSX export, lazy-load plan
  • Light theme by default — preview ignores OS dark mode so inputs and surfaces match the phone canvas.
  • RNUI app background — WebPreviewHost sets color.bg.default on the preview canvas.
  • Polished device frame — lighter bezel, dynamic island, scrollable inner screen (~390×760px).
  • Template schemas — login, dashboard, settings, profile, and form fixtures use Card/Paper, hierarchy, and spacing.

Disclaimer shown in preview: Web preview approximates React Native rendering. Verify final UI in the iOS/Android example app.

Click a chip to load the schema immediately (no mock AI delay):

ChipSchema
LoginCard-wrapped sign-in form
DashboardGreeting, stats, chips, activity
SettingsProfile + preferences + sign out
Profile CardAvatar, stats, actions
Contact FormCard form with labeled inputs

No external AI API. Keyword routing when using the chat form:

Prompt keywordsSchema
login / sign-inLogin
settings / notificationsSettings
profile / avatarProfile card
dashboard / home / statsDashboard
form / submit / payment / checkoutContact form
(default)Dashboard
invalid / repairBroken schema for repair testing
  • Build a polished login screen using Card, Typography, Input, and Button.
  • Build a settings screen using profile card, preference rows, and switches.

repairSchema() replaces invalid schemas with the login template for repair-loop demos.

Good ScreenSchema screens for AI/mock generation:

  1. Screen root with padding + spacing — avoid empty flat lists.
  2. Card or Paper to group related content (forms, settings rows).
  3. Typography hierarchy — h3/h4 title + body2 subtitle before fields.
  4. webPreview-safe components only — see component schema.
  5. No inline style props — use component props and token-backed variants.

Fixtures live in .ai/examples/schemas/*.json and @truongdq01/component-schema examples.

template chip / prompt → MockAIProvider.generateSchema()
→ validateScreenSchema()
→ WebPreviewHost (colorScheme: light)
→ exportSchemaToTsx()

Repair loop: Repair schema (chat) or edit JSON → Validate → preview updates.

The builder configures Next.js webpack aliases:

  • react-native → react-native-web
  • Mocks for Reanimated, Gesture Handler, Worklets, FlashList, expo-blur, etc.
  • Slim RNUI component map (17 web-preview MVP components)
  • TextField web stub wrapping Input

Native-only components (Modal, BottomSheet, etc.) render fallback placeholders — they are not polyfilled in this phase.

  • Gesture-driven press feedback is mocked — buttons may not animate on web.
  • Reanimated-driven input focus rings are approximated.
  • Not a pixel-perfect substitute for iOS/Android — always verify in apps/example.
  • Generated TSX is not executed in the builder.
  • Mock AI only — no OpenAI/Anthropic/Gemini
  • Textarea JSON editor (no Monaco)
  • No auth, persistence, drag-and-drop, or props inspector

See .planning/phase-3d-preview-quality-followups.md — real AI provider, theme toggle in builder, Playwright E2E.