How viplavkhode/vibe works
1. Overall shape
- This is a Next.js 15 App Router application organized around two big concerns: the public marketing/auth experience and the authenticated “project builder” experience.
- The codebase is split into presentation routes in src/app, feature modules in src/modules, shared infrastructure in src/lib, src/trpc, and src/inngest, plus Prisma schema/migrations and sandbox templates.
2. User-facing route surface
- src/app/(home) contains the landing page, pricing page, and Clerk sign-in/sign-up flows.
- src/app/projects/[projectId] is the authenticated project workspace, which is where users inspect a generated project, send messages/prompts, and view preview/code-related UI.
- src/app/error.tsx and src/app/layout.tsx provide the global shell/error handling for the app.
3. Feature-module boundaries
- src/modules/home owns the home-page UI pieces such as the navbar, project form, and project list.
- src/modules/projects owns the project workspace UI: header, message composer, message list/cards, loading states, usage display, and project view switching.
- src/modules/messages and src/modules/usage hold server-side procedures for those domains, keeping business logic out of route components.
4. Client/server API layer
- The app uses tRPC for type-safe server communication.
- src/app/api/trpc/[trpc]/route.ts exposes the tRPC HTTP endpoint, while src/trpc/* contains the client, server initialization, query client, and router composition.
- Domain procedures live in src/modules/*/server/procedures.ts, then get composed into the root router in src/trpc/routers/_app.ts.
5. Persistence layer
- Prisma is the main persistence boundary: prisma/schema.prisma and the migrations define the data model.
- The presence of migrations for projects, user_id, and usage indicates at least three core stored entities/concerns: project records, user ownership, and consumption tracking.
- src/lib/db.ts is the shared DB access point, and src/lib/usage.ts likely encapsulates metering/credit logic used by usage-related procedures.
6. Authentication and request gating
- Clerk is the auth provider, reflected in the sign-in/sign-up routes and the environment variables documented in the README.
- src/middleware.ts is the main request gate for authenticated sections and route protection, so auth decisions likely happen before the project workspace or API layer is reached.
- src/components/user-controls.tsx suggests the authenticated header/account controls live in the shared UI shell.
7. Background orchestration
- The repo has a dedicated Inngest integration under src/inngest, with client.ts, functions.ts, and util.ts, plus an API handler at src/app/api/inngest/route.ts.
- This is the async execution boundary for prompt processing, generation, validation, or other long-running tasks described in the README.
- .inngest/main.db suggests local Inngest state is used in development.
8. Generated-app runtime / sandbox boundary
- sandbox-templates/nextjs contains a Dockerfile, E2B config, and compile script for running generated apps in isolated sandboxes.
- This is a distinct runtime from the main Next.js app: the builder generates code here, but execution/preview happens in sandboxed environments rather than inside the host app process.
- That boundary is important for the architecture diagram because preview execution is intentionally isolated from the product UI/API.
9. Project workspace UI flow
- The project detail page likely composes the message stream, project header, preview/code views, and usage widgets from src/modules/projects/ui.
- Components like file-explorer, tree-view, and code-view support the “inspect generated code” experience described in the README.
- project-views.tsx and fragment-web.tsx suggest the workspace can switch between preview and code/navigation-oriented views.
10. Shared UI and design system
- The repo uses a large shared component set in src/components/ui, which is consistent with a Shadcn/Radix-based design system.
- This shared layer feeds both marketing pages and the project workspace, so the diagram should treat it as a cross-cutting presentation library rather than a separate business subsystem.
11. Operational concerns
- src/modules/usage and src/lib/usage.ts show metering/credits are first-class product logic, not just analytics.
- The README’s billing mention plus the usage schema migration imply the system must enforce or display quota/credit state during generation workflows.
12. End-to-end data flow
- A user enters the app through the home/auth routes, authenticates with Clerk, and creates or opens a project.
- The project workspace sends typed actions through tRPC into server procedures, which read/write Prisma records and may enqueue Inngest jobs for long-running generation.
- Inngest-driven work produces code/artifacts and triggers sandbox validation/preview setup, while the UI reads back project state, messages, and usage to render the live builder experience.
Main entry points: _app.ts tRPC core · page.tsx Project workspace · project-header.tsx Project UI · functions.ts Inngest jobs
Components 22
App routes
Next.js App Router surface for marketing, auth, and the authenticated workspace.
- App shell · Global app layout and error handling.
src/app/layout.tsx - Error page · Global route error boundary.
src/app/error.tsx - Landing · Public home page and entry experience.
src/app/(home)/page.tsx - Pricing · Public pricing page.
src/app/(home)/pricing/page.tsx - Auth pages · Sign-in and sign-up flows.
src/app/(home)/sign-in/[[...sign-in]]/page.tsx - Project workspace · Authenticated project detail and builder surface.
src/app/projects/[projectId]/page.tsx
Feature modules
Domain-specific UI and server procedures.
- Home module · Home-page composition and project entry UI.
src/modules/home/ui/components/navbar.tsx - Project UI · Workspace header, messaging, loading, usage, and view switching.
src/modules/projects/ui/components/project-header.tsx - Projects API · Server procedures for project operations.
src/modules/projects/server/procedures.ts - Messages API · Server procedures for messaging and prompt flow.
src/modules/messages/server/procedures.ts - Usage API · Server procedures for metering and quota state.
src/modules/usage/server/procedures.ts
Infrastructure
Shared persistence, API, auth gating, and background execution.
- tRPC route · HTTP entrypoint for typed client-server calls.
src/app/api/trpc/[trpc]/route.ts - tRPC core · Client, server init, query client, and router wiring.
src/trpc/routers/_app.ts - Auth gate · Request gating and route protection.
src/middleware.ts - Database · Shared Prisma access and persisted application state.
src/lib/db.ts - Usage logic · Shared quota and credit helpers.
src/lib/usage.ts - Inngest API · HTTP handler for background job events.
src/app/api/inngest/route.ts - Inngest jobs · Async orchestration for generation and long-running work.
src/inngest/functions.ts
Shared UI
Reusable presentation components and hooks.
- UI kit · Reusable shared components across routes and features.
src/components/ui/button.tsx - Code browser · File explorer, tree view, and code display for generated projects.
src/components/code-view/index.tsx - User controls · Authenticated header/account controls.
src/components/user-controls.tsx
Sandbox runtime
Isolated generated-app execution and build environment.
- Sandbox template · Next.js sandbox build and compile environment for generated apps.
sandbox-templates/nextjs/e2b.toml
Connections 24
- App shell → Landing: wraps · Provides the global shell for public pages.
- App shell → Project workspace: wraps · Provides the global shell for the authenticated workspace.
- App shell → Error page: handles · Displays route-level failures.
- Landing → Home module: uses · Composes landing-page sections and entry forms.
- Pricing → UI kit: uses · Renders marketing UI from the shared component kit.
- Auth pages → UI kit: uses · Builds Clerk auth screens with shared UI primitives.
- Project workspace → Project UI: composes · Assembles the workspace from feature UI pieces.
- Project workspace → Code browser: uses · Surfaces generated files and code views.
- Project workspace → User controls: uses · Shows authenticated account actions in the shell.
- Project UI → Messages API: calls · Loads and mutates message state through typed procedures.
- Project UI → Projects API: calls · Reads project state and workspace metadata.
- Project UI → Usage API: calls · Displays usage and quota state.
- Projects API → tRPC core: registered in · Composed into the root application router.
- Messages API → tRPC core: registered in · Composed into the root application router.
- Usage API → tRPC core: registered in · Composed into the root application router.
- tRPC core → tRPC route: served by · Exposed over the HTTP API.
- tRPC core → Database: reads/writes · Uses Prisma-backed persistence.
- tRPC core → Usage logic: uses · Applies shared metering logic.
- Auth gate → Project workspace: protects · Gates authenticated workspace routes.
- Auth gate → tRPC route: protects · Constrains access to typed API calls.
- Inngest API → Inngest jobs: dispatches · Hands off incoming events to background jobs.
- tRPC core → Inngest jobs: enqueues · Triggers long-running generation and validation work.
- Inngest jobs → Sandbox template: uses · Builds and runs generated apps in isolated sandboxes.
- Inngest jobs → Database: updates · Persists generation results and workflow state.