Turn page ideas into safe, editable app canvases.
CanvasForge is an AI-assisted product design and code generation workspace for teams that need to turn rough page concepts into structured UI layouts, inspectable previews, and exportable Next.js code. It is designed for founders, product designers, and full-stack teams who want fast iteration without losing control over schema, safety, or code quality.
Founder Nina, 34 - Nina is a startup founder validating landing pages and product concepts quickly. She needs a way to turn rough ideas into something presentable, safe to demo, and easy to share with her engineer.
Product Designer Amir, 29 - Amir uses AI to explore multiple layout directions, but he needs deterministic structure and safe preview rendering. He wants quick text and color edits without waiting for full regeneration.
Full-Stack Engineer Priya, 41 - Priya receives AI-generated prototypes from non-technical teammates and needs them to be trustworthy, typed, and easy to integrate. She values strict schemas, predictable outputs, and code export that follows established patterns.
Nina has a new product idea and needs a polished landing page for a pitch meeting tomorrow. She writes a short prompt, connects her account, and within a minute sees a structured page preview instead of a blank editor.
She notices one section headline is too generic, so she changes the copy in the inspector and updates the hero color to match her brand. The canvas updates instantly inside a safe sandbox, and she can compare the result without risking the rest of the workspace.
When she is ready, she exports a clean Next.js project and sends it to her engineer. What used to take days of back-and-forth now becomes a fast, controlled workflow that helps the team validate ideas sooner and ship with less rework.
Team & resourcing - Small team - 2 full-stack engineers, 1 product designer, part-time PM, and shared DevOps support.
Paste this into Cursor, Bolt, Lovable, or v0 to start building.
Build a product called CanvasForge: an AI-assisted page layout workspace that generates strict typed UI from a prompt, previews it safely in a sandboxed iframe, lets users edit text and colors instantly, and exports a clean Next.js App Router codebase. Core requirements: Web app in Next.js 15 App Router, TypeScript strict, Tailwind CSS v4, shadcn/ui, Drizzle ORM, PostgreSQL. Python worker service in FastAPI with SSE streaming. Use Pydantic models for UIComponentNode and PageLayoutAST as the only allowed generation schema. Enforce generation budget with max model calls = 3 and max_output_tokens based on remaining user quota. Handle resource exhaustion and max token stop reasons deterministically without crashing. Preview must render only inside an iframe with sandbox allow-scripts and no allow-same-origin. All host-preview communication must use postMessage with Zod schema validation. Primary screens: Login and Antigravity account connect screen. Project dashboard with quota status. Project generation screen with live AST stream and sandbox preview. Inspector panel for editing copy and colors. Export screen to download a zip of Next.js files. Data model: users, projects, user_antigravity_accounts, token_consumption_audit. Build the app with a clean component structure, realistic empty states, loading states, validation errors, and audit logging. Include code for OAuth PKCE flow, SSE proxying, preview sandboxing, AST validation, and export packaging.
- Skema output agen **WAJIB DIKUNCI** menggunakan model Pydantic `PageLayoutAST` (Zero Hallucination). - Wajib menyematkan `BudgetConfig` Antigravity SDK: - `max_model_calls = 3` (Mencegah looping penalaran tanpa akhir). - `max_output_tokens` disesuaikan dengan jatah sisa token akun user. - Tangani `StopReason.RESOURCE_EXHAUSTED` dan `StopReason.MAX_OUTPUT_TOKENS_EXCEEDED` secara deterministik tanpa menyebabkan crash. ### D. Aturan Keamanan Live Preview - Canvas preview wajib dirender di dalam `<iframe>` dengan atribut isolasi: `sandbox="allow-scripts"`. - Dilarang menyertakan atribut `allow-same-origin` guna mencegah akses kode preview ke cookie atau local storage parent window. - Komunikasi antara Host UI dan Iframe hanya diizinkan melalui `window.postMessage` dengan validasi payload skema Zod. --- ## 4. RENCANA EKSEKUSI TAHAP DEMI TAHAP (STEP-BY-STEP) ### Tahap 1: Scaffolding Fondasi Monorepo & UI Baseline 1. Inisialisasi struktur monorepo (`apps/web` dan `apps/agent-worker`). 2. Konfigurasi Next.js 15 App Router, TypeScript Strict, Tailwind CSS v4. 3. Inisialisasi `shadcn/ui` dan unduh komponen dasar: `button`, `card`, `input`, `form`, `badge`, `progress`, `dialog`, `dropdown-menu`, `tabs`, `table`, `separator`. 4. Setup Drizzle ORM dan buat skema tabel: `users`, `projects`, `user_antigravity_accounts`, `token_consumption_audit`. 5. Implementasi utilitas kriptografi `AES-256-GCM` di `apps/web/src/lib/crypto/vault.ts`. ### Tahap 2: Autentikasi & Alur OAuth 2.0 PKCE Antigravity 1. Buat halaman `/login` dan form registrasi dengan shadcn/ui. 2. Implementasi rute OAuth `/api/v1/auth/antigravity/authorize` (Generate code_verifier, code_challenge, state). 3. Implementasi rute callback `/api/v1/auth/antigravity/callback` (Tukar code dengan token, enkripsi AES-256-GCM, simpan ke PostgreSQL). 4. Buat komponen UI `AntigravityConnectCard` untuk menampilkan identitas akun Antigravity yang tertaut dan sisa kuota. ### Tahap 3: Python Agent Worker & Pydantic AST Stream 1. Siapkan environment Python di `apps/agent-worker` dengan `google-antigravity`, `fastapi`, `uvicorn`, `pydantic`. 2. Definisikan model Pydantic `UIComponentNode` dan `PageLayoutAST`. 3. Buat endpoint FastAPI SSE `/agent/generate` yang menginisialisasi Antigravity Agent dengan delegasi user token dan `BudgetConfig`. 4. Buat proxy Route Handler di Next.js `/api/v1/projects/generate` untuk mengalirkan Server-Sent Events (SSE) dari worker ke browser klien. ### Tahap 4: Sandboxed Canvas & Visual Inspector 1. Buat komponen `SandboxedCanvas` menggunakan `<iframe>` aman. 2. Implementasi listener `postMessage` untuk menyuntikkan komponen React/Tailwind dari stream AST ke dalam iframe runtime. 3. Buat panel inspektor visual untuk memungkinkan edit teks dan warna secara instan tanpa regenerasi seluruh halaman. ### Tahap 5: Code Synthesis & Exporter 1. Buat use case untuk mengompilasi AST ke dalam berkas utuh Next.js App Router (`page.tsx`, `components/*`, `tailwind.config.ts`). 2. Buat endpoint ekspor yang mengompresi proyek menjadi file `.zip` siap pakai (*clean code, zero-lockin*). --- ## 5. INSTRUKSI MULAI BEKERJA Mulai pekerjaan sekarang dari **Tahap 1: Scaffolding Fondasi Monorepo & UI Baseline**. Laporkan setiap berkas yang dibuat dan lakukan verifikasi lokal (`npm run typecheck` atau linter) untuk menjamin kode bebas error.
Design by The Resonance | Powered by GPC – The AI Transformation Company