How tirthbhatt1208/vibestudio works
1. Repo shape
- This is a full-stack Next.js App Router application, mostly JavaScript/JSX with some generated TypeScript typings under generated/prisma.
- The app is organized around a project workspace for prompt-driven UI generation, plus auth, billing/usage, and background processing.
2. Primary runtime boundary
- There are three main execution zones:
- Client UI in src/app and src/components
- Server-side feature actions in src/modules/*/actions
- Background jobs in src/inngest/*, exposed through src/app/api/inngest/route.js
- That separation is the core architectural boundary: user interactions happen in the browser, state-changing work runs on the server, and long-running generation work is offloaded.
3. Route structure
- Public routes live under src/app/(root) for the landing page, pricing, sign-in, and sign-up.
- The main app experience is under src/app/projects/[projectId], which is the project detail/workspace screen.
- src/app/layout.js and src/app/globals.css provide the app shell and global styling.
4. Feature-oriented modules
- Business logic is split by domain in src/modules:
- auth for authentication-related actions
- home for the landing/dashboard experience
- projects for project workspace behavior
- messages for prompt/message threading
- usage for quota and billing/consumption tracking
- Each module has its own actions, and many also have components and hooks, which keeps UI and domain logic co-located.
5. Project workspace UI
- The project page is composed from focused UI pieces in src/modules/projects/components, including:
- message composer and message cards
- file explorer / tree view
- code viewer with syntax styling
- project header and overall project view container
- preview-related fragments
- This strongly suggests the main workspace is a split-view editor/review surface: prompt/messages on one side, generated code/files/preview on the other.
6. Data flow for generation
- The README describes a prompt-to-code pipeline, and the tree supports that with src/prompt.js, message utilities, and the job system.
- The likely flow is: user submits a prompt in the project UI → a server action persists/validates it → an Inngest event is emitted → background functions generate or update code → results are stored and surfaced back in the project workspace.
7. Background job subsystem
- src/inngest/client.js, functions.js, and utils.js define the async job layer.
- src/app/api/inngest/route.js is the webhook/handler boundary that lets Inngest invoke the app.
- This subsystem exists to keep generation and sandbox execution out of the request/response path, so the UI can stay responsive while work completes asynchronously.
8. Persistence layer
- Prisma is the database boundary: prisma/schema.prisma, migration files, prisma.config.ts, and the generated client under generated/prisma.
- The schema includes User, Project, Message, Fragment, and Usage, which maps to the app’s core concepts:
- identity and ownership
- project grouping
- chat/prompt history
- generated code fragments
- metering/quotas
- src/lib/db.js is the shared database access point.
9. Sandbox execution boundary
- sandbox-templates/next-js is a separate execution environment template for running generated code in isolation.
- The presence of e2b.Dockerfile, e2b.toml, and compile_page.sh shows the generated UI is meant to be built/run inside a controlled sandbox, not on the main app server.
- This is a major architectural boundary: the app produces code, but execution happens in an external isolated runtime.
10. Auth, billing, and usage control
- The repo has dedicated sign-in/sign-up routes and a src/proxy.js, indicating route protection at the edge or middleware layer.
- src/modules/usage and src/lib/usage.js suggest generation limits and billing/entitlement checks are enforced server-side before expensive work starts.
- src/components/user-control.jsx likely anchors the authenticated account menu/session controls in the UI.
11. Shared client infrastructure
- src/components/query-provider.jsx and src/components/theme-provider.jsx provide app-wide client context for server-state caching and theming.
- src/hooks contains reusable client behavior such as mobile detection, scrolling, and theme state.
- src/lib/utils.js and src/lib/message-role.js hold cross-cutting helpers used across modules.
12. UI system
- src/components/ui/* is a large shadcn/ui-style component library used to assemble the interface.
- This means most screens are built from composable primitives rather than custom one-off widgets, which keeps the design system consistent across home, auth, and workspace views.
13. What to diagram
- The most important diagram boundaries are:
- browser UI vs server actions
- server app vs Inngest jobs
- app vs PostgreSQL via Prisma
- app vs isolated sandbox runtime
- auth/usage gating around generation entry points
- The central object in the architecture is the project, with messages/prompts and generated fragments flowing through it.
Main entry points: db.js DB access · layout.js App layout · index.js Message actions · components Workspace UI
Components 22
App Shell
Next.js routes, layout, and API entrypoints.
- App layout · Global app wrapper and shell styles.
src/app/layout.js - Global styles · Application-wide styling entrypoint.
src/app/globals.css - Public pages · Landing, pricing, sign-in, and sign-up screens.
src/app/(root) - Project workspace · Main project detail workspace for prompt-driven generation.
src/app/projects/[projectId]/page.jsx - Inngest handler · Webhook boundary for background job execution.
src/app/api/inngest/route.js
Feature Modules
Domain-specific server actions and UI pieces.
- Auth module · Authentication-related actions and flows.
src/modules/auth/actions/index.js - Home screens · Landing/dashboard UI such as navbar, project list, and project form.
src/modules/home/components - Project actions · Server-side project workspace mutations and coordination.
src/modules/projects/actions/index.js - Message actions · Prompt and thread persistence plus message-related workflows.
src/modules/messages/actions/index.js - Usage actions · Quota, billing, and entitlement checks.
src/modules/usage/actions/index.js - Workspace UI · Project header, messages, file tree, code view, and preview fragments.
src/modules/projects/components - Message hook · Client-side message state helpers for the workspace.
src/modules/messages/hooks/message.js - Prompt config · Prompt definitions and generation instructions.
src/prompt.js
Async Jobs
Inngest background processing for generation work.
- Job engine · Inngest client, utilities, and function definitions.
src/inngest/functions.js
Data Layer
Prisma schema, generated client, and shared DB access.
- DB access · Shared database access point.
src/lib/db.js - Prisma schema · Core entities for users, projects, messages, fragments, and usage.
prisma/schema.prisma - Generated client · Generated Prisma client and model typings.
generated/prisma
External Runtime
Isolated sandbox used to build and run generated apps.
- Sandbox template · Next.js template used for executing generated code in isolation.
sandbox-templates/next-js
Shared UI
Cross-cutting client providers, hooks, and reusable UI primitives.
- Query provider · App-wide server-state caching context.
src/components/query-provider.jsx - Theme provider · App-wide theme state and switching context.
src/components/theme-provider.jsx - UI kit · Reusable shadcn-style primitives used across the app.
src/components/ui - Usage guard · Shared usage and entitlement logic used before expensive generation work.
src/lib/usage.js
Connections 25
- App layout → Public pages: wraps · Provides the shell for public pages.
- App layout → Project workspace: wraps · Provides the shell for the project workspace.
- App layout → Query provider: hosts · Mounts shared client state providers.
- App layout → Theme provider: hosts · Mounts shared theme state.
- App layout → Global styles: loads · Applies global styles across the app.
- Public pages → Auth module: signs in · Public auth screens trigger authentication actions.
- Public pages → Home screens: renders · Landing and dashboard-facing UI is assembled here.
- Project workspace → Workspace UI: composes · The project page is built from workspace components.
- Project workspace → Project actions: mutates · Workspace interactions call server actions.
- Workspace UI → Message actions: sends prompts · Composer and message thread interactions persist through message actions.
- Workspace UI → Message hook: uses · Client-side message state is coordinated with hook logic.
- Project actions → DB access: reads/writes · Project mutations persist through the database layer.
- Message actions → DB access: reads/writes · Messages and fragments are stored via Prisma.
- Usage actions → Usage guard: checks · Server actions enforce quota and entitlement rules.
- Usage actions → DB access: records · Usage is tracked in persistence.
- Message actions → Usage actions: gates · Prompt work is constrained by usage rules.
- Message actions → Prompt config: uses · Prompting behavior is defined in shared prompt config.
- Message actions → Job engine: emits · Prompt submissions enqueue background generation work.
- Inngest handler → Job engine: invokes · External job callbacks are handled by the job engine.
- Job engine → Sandbox template: runs in · Generated app work executes in the isolated sandbox.
- Job engine → DB access: updates · Background jobs persist results and state.
- DB access → Prisma schema: backed by · Schema defines the persistent entities.
- DB access → Generated client: typed by · Shared DB access uses generated Prisma types.
- Workspace UI → UI kit: builds from · Workspace screens are composed from reusable primitives.
- Home screens → UI kit: builds from · Home and auth-facing surfaces use the shared component kit.