An open-source clone of Vercel's v0 experience: describe what you want to build, and an AI coding agent generates a working Next.js fragment in a disposable sandbox. Each iteration is saved as a message with an attached code fragment and a live preview.
- Chat-to-build: Send prompts to generate UI or features; results are saved as messages and fragments.
- Live preview: Each fragment runs in an isolated E2B sandbox with a public URL.
- Code view: Inspect generated files via an in-app file explorer.
- Projects: Group your conversations and fragments per project.
- Auth and usage limits: Clerk auth with free/pro usage tiers and rate limiting.
- Background jobs: Inngest powers the agent orchestration and sandbox operations.
- Framework: Next.js 15 (App Router, React 19)
- UI: Shadcn UI (Radix Primitives, Tailwind CSS 4)
- Auth & Billing: Clerk
- Database: Prisma + PostgreSQL
- API: tRPC (server adapters + TanStack Query 5 on client)
- Agents/Jobs: Inngest +
@inngest/agent-kit - Sandboxing: E2B
src/app— routes and API handlersapi/trpc/[trpc]/route.ts— tRPC fetch adapterapi/inngest/route.ts— Inngest function server
src/modules— feature modulesprojects— server procedures and UI for project view, messages, preview/code tabshome— landing page, project creation
src/inngest— agent network and functionsfunctions.ts— maincode/generatefunction: spins up sandbox, runs agent network, stores resultsagents.ts,tools.ts,network.ts,prompt.ts— agent definition, tools (terminal, read/write files), router, prompts
src/lib/prisma.ts— Prisma clientprisma/schema.prisma— models:Project,Message,Fragment,Usagesrc/trpc— router, context, server/client wiringsrc/env— validated env vars for server and client using@t3-oss/env-nextjs
Data flow for a generation:
- User submits a prompt in a project →
messages.createmutation saves user message and triggers Inngest eventcode/generate. - Inngest function creates an E2B sandbox, hydrates agent memory with last messages, runs the agent network.
- Resulting files are written to the sandbox; a live URL is derived and saved with a fragment.
- A new assistant message is stored with
type=RESULTand linkedFragmentcontainingfilesandsandboxUrl. - UI polls messages; latest assistant fragment becomes the active preview and code.
Shadcn components are colocated under src/components/ui/* and used throughout the app (e.g., buttons, tabs, dropdowns, resizable panels). Follow the component APIs as implemented in this repo. Tailwind CSS 4 powers styling; no extra CSS files are required beyond the provided theme and utilities.
Server (src/env/server.ts):
DATABASE_URL— PostgreSQL connection URLNODE_ENV—development|test|productionOPENAI_API_KEY— LLM key used by@inngest/agent-kitE2B_API_KEY— E2B sandbox API keyCLERK_SECRET_KEY— Clerk server key
Client (src/env/client.ts):
NEXT_PUBLIC_APP_URLNEXT_PUBLIC_CLERK_PUBLISHABLE_KEYNEXT_PUBLIC_CLERK_SIGN_IN_URLNEXT_PUBLIC_CLERK_SIGN_IN_FALLBACK_REDIRECT_URLNEXT_PUBLIC_CLERK_SIGN_UP_URLNEXT_PUBLIC_CLERK_SIGN_UP_FALLBACK_REDIRECT_URL
Create a .env and .env.local with these values before running locally.
Prisma models live in prisma/schema.prisma. Run migrations and generate the client:
npm install
npx prisma migrate deploy
npx prisma generate- Set environment variables (see above).
- Install deps:
npm install. - Generate Prisma client:
npm run postinstall(runs automatically) ornpx prisma generate. - Start dev server:
npm run dev. - Sign in with Clerk and create a project on
/. - Send a message; an Inngest job will generate a fragment and attach a live sandbox preview.
- Deploy on your platform of choice (e.g., Vercel). Ensure runtime env vars are set.
- Provision a managed Postgres database and set
DATABASE_URL. - Set Clerk keys and domain.
- Ensure Inngest and E2B keys are configured in the environment.
dev— Next.js dev with Turbopackbuild— Next.js buildstart— Next.js startpostinstall—prisma generate
- Middleware protects non-public routes via Clerk; API routes are public but server procedures enforce auth.
- Usage limits are tracked in
Usageviarate-limiter-flexible; free vs pro quotas enforced insrc/lib/usage.ts.
src/
app/
components/
e2b/
env/
inngest/
lib/
modules/
trpc/
prisma/
