# mrvineet-raj/vibe architecture

> Architecture diagram of the GitHub repository mrvineet-raj/vibe, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-07-30). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/mrvineet-raj/vibe
- Repository: https://github.com/mrvineet-raj/vibe

## Overview

##### Project type and purpose
- This is a full-stack Next.js web application (v15.3.4) using shadcn UI components.
- It provides user authentication (sign-in/sign-up), project management, messaging, usage tracking, and billing/pricing pages.
- The stack includes: Next.js App Router (src/app), React UI (components & modules/ui), TRPC for type-safe RPC APIs, Inngest for background workflows, Prisma ORM with PostgreSQL, and pnpm monorepo tooling.

##### File structure
- Top-level “src/app” directory: defines all Next.js pages and API routes.
- src/app/api/trpc/[trpc]/route.ts → TRPC endpoint
- src/app/api/inngest/route.ts → Inngest webhook entry
- src/app/(home), /projects/[projectId], /sign-in, /sign-up, /pricing → UI routes
- “src/components” & “src/modules”: UI components, shared primitives, and feature-scoped UI under modules/home, modules/projects, modules/messages, modules/usage.
- “src/trpc”: client & server TRPC initialization and routers (_app.ts).
- “src/inngest”: client helper, functions, and utils for background jobs.
- “src/lib”: Prisma client (prisma.ts), usage tracking helpers, generic utils.
- “prisma/”: schema.prisma plus migration folders & SQL files.
- Config files: next.config.ts, tsconfig.json, eslint.config.mjs, postcss.config.mjs.

##### Extract additional insights from README
- Uses Dockerized PostgreSQL (`docker run … postgres`).
- Implies local/dev DB, Prisma migrations to evolve schema.

##### Main components
a. Frontend (Browser/Next.js App)
- Next.js App Router → React components in src/app pages
- UI library: shadcn/ui + custom components (components/, modules/*/ui/)
b. API Layer (Next.js Server Functions)
- TRPC API endpoint: app/api/trpc → invokes src/trpc/routers → server procedures
- Inngest webhook endpoint: app/api/inngest → triggers background workflows
c. Business Logic / Domain Services
- modules/projects/server/procedures.ts
- modules/messages/server/procedures.ts
- modules/usage/server/procedure.ts
- src/lib/usage.ts (analytics/tracking)
d. Data Layer
- Prisma client (src/lib/prisma.ts) → interfaces with PostgreSQL
- PostgreSQL database (containerized)
e. Background Processing
- Inngest functions (src/inngest/functions.ts) → scheduled or event-driven jobs
- Inngest client (src/inngest/client.ts)
f. External Services
- Dockerized PostgreSQL
- (Optional) any third-party auth provider or billing API if added

##### Relationships and data flow
- Browser → Next.js server (SSR/SSG & client-side rendering)
- Browser UI → TRPC client → /api/trpc → TRPC router → domain procedures → Prisma → PostgreSQL
- Browser UI triggers Inngest events via Inngest client → /api/inngest → Inngest runtime → Inngest functions → DB or email/external
- Prisma migrations evolve the database schema (prisma/migrations)
- Usage tracking: domain logic calls src/lib/usage.ts to log consumption

##### Architectural patterns & design principles
- Clear UI/Business/Data separation
- Type-safe end-to-end with TRPC + Prisma
- App Router & file-based routing in Next.js
- Feature folders under src/modules to isolate domains
- Background tasks decoupled via Inngest webhook pattern
- Monorepo package management with pnpm/workspace

##### Detailed component breakdown
- src/app (Pages & API routes)
- src/components & modules/*/ui (UI widgets)
- src/trpc (init, client, routers, server.tsx)
- src/inngest (client, functions)
- src/modules/*/server (procedures per domain)
- src/lib/prisma.ts & usage.ts
- prisma/schema.prisma & migration folder
- Dockerized PostgreSQL instance

## Diagram (Mermaid)

```mermaid
flowchart TD
  subgraph "Frontend (Browser)"
    direction TB
    NextApp["Next.js App Router\n(src/app)"]:::frontend
    Shadcn["shadcn/ui\n(src/components/ui)"]:::frontend
    SharedUI["Shared UI Components\n(src/components)"]:::frontend
    HomeUI["Home Feature UI\n(src/modules/home/ui/components)"]:::frontend
    ProjectsUI["Projects Feature UI\n(src/modules/projects/ui/components)"]:::frontend
    ProjectView["Project View\n(src/modules/projects/ui/views/project-view.tsx)"]:::frontend
    HomeLayout["Home Layout\n(layout.tsx)"]:::frontend
    HomePage["Home Page\n(page.tsx)"]:::frontend
    PricingPage["Pricing Page\n(pricing/page.tsx)"]:::frontend
    ProjectsPage["Projects Page\n([projectId]/page.tsx)"]:::frontend
    SignIn["Sign-In Page\n(sign-in/page.tsx)"]:::frontend
    SignUp["Sign-Up Page\n(sign-up/page.tsx)"]:::frontend
  end

  subgraph "API Layer (Next.js Server)"
    direction TB
    TRPC_Endpoint["TRPC Endpoint\n(route.ts)"]:::api
    Inngest_Endpoint["Inngest Webhook\n(route.ts)"]:::api
    TRPC_Init["TRPC Init & Routers\n(init.ts, client.tsx, _app.ts)"]:::api
  end

  subgraph "Business Logic"
    direction TB
    MsgProc["Messages Procedures\n(procedures.ts)"]:::service
    ProjProc["Projects Procedures\n(procedures.ts)"]:::service
    UsageProc["Usage Procedures\n(procedure.ts)"]:::service
    UsageLib["Usage Tracking\n(src/lib/usage.ts)"]:::service
  end

  subgraph "Data Layer"
    direction TB
    PrismaClient["Prisma Client\n(src/lib/prisma.ts)"]:::data
    DB["PostgreSQL\n(prisma/schema.prisma & migrations)"]:::database
  end

  subgraph "Background Processing"
    direction TB
    InngestClient["Inngest Client\n(client.ts)"]:::background
    InngestFuncs["Inngest Functions\n(functions.ts)"]:::background
  end

  %% Connections
  NextApp -->|uses| Shadcn
  NextApp -->|uses| SharedUI
  NextApp -->|uses| HomeUI
  NextApp -->|uses| ProjectsUI
  ProjectsUI --> ProjectView

  NextApp -->|HTTP/JSON via TRPC| TRPC_Endpoint
  NextApp -->|HTTP Webhook| Inngest_Endpoint

  TRPC_Endpoint --> TRPC_Init
  TRPC_Init --> MsgProc
  TRPC_Init --> ProjProc
  TRPC_Init --> UsageProc

  MsgProc -->|Prisma Client| PrismaClient
  ProjProc -->|Prisma Client| PrismaClient
  UsageProc -->|Prisma Client| PrismaClient
  UsageLib -->|logs to| PrismaClient

  PrismaClient -->|SQL Queries| DB

  Inngest_Endpoint -->|triggers| InngestFuncs
  InngestClient -->|calls Webhook| Inngest_Endpoint
  InngestFuncs -->|Prisma Client| PrismaClient
  InngestFuncs -->|external side-effects| DB

  %% Click Events
  click NextApp "https://github.com/mrvineet-raj/vibe/tree/main/src/app"
  click HomeLayout "https://github.com/mrvineet-raj/vibe/blob/main/src/app/(home)/layout.tsx"
  click HomePage "https://github.com/mrvineet-raj/vibe/blob/main/src/app/(home)/page.tsx"
  click PricingPage "https://github.com/mrvineet-raj/vibe/blob/main/src/app/(home)/pricing/page.tsx"
  click ProjectsPage "https://github.com/mrvineet-raj/vibe/blob/main/src/app/projects/[projectId]/page.tsx"
  click SignIn "https://github.com/mrvineet-raj/vibe/blob/main/src/app/sign-in/[[...sign-in]]/page.tsx"
  click SignUp "https://github.com/mrvineet-raj/vibe/blob/main/src/app/sign-up/[[...sign-up]]/page.tsx"
  click TRPC_Endpoint "https://github.com/mrvineet-raj/vibe/blob/main/src/app/api/trpc/[trpc]/route.ts"
  click TRPC_Init "https://github.com/mrvineet-raj/vibe/blob/main/src/trpc/init.ts"
  click TRPC_Init "https://github.com/mrvineet-raj/vibe/blob/main/src/trpc/client.tsx"
  click TRPC_Init "https://github.com/mrvineet-raj/vibe/blob/main/src/trpc/routers/_app.ts"
  click Inngest_Endpoint "https://github.com/mrvineet-raj/vibe/blob/main/src/app/api/inngest/route.ts"
  click InngestClient "https://github.com/mrvineet-raj/vibe/blob/main/src/inngest/client.ts"
  click InngestFuncs "https://github.com/mrvineet-raj/vibe/blob/main/src/inngest/functions.ts"
  click Shadcn "https://github.com/mrvineet-raj/vibe/tree/main/src/components/ui"
  click SharedUI "https://github.com/mrvineet-raj/vibe/tree/main/src/components"
  click HomeUI "https://github.com/mrvineet-raj/vibe/tree/main/src/modules/home/ui/components"
  click ProjectsUI "https://github.com/mrvineet-raj/vibe/tree/main/src/modules/projects/ui/components"
  click ProjectView "https://github.com/mrvineet-raj/vibe/blob/main/src/modules/projects/ui/views/project-view.tsx"
  click MsgProc "https://github.com/mrvineet-raj/vibe/blob/main/src/modules/messages/server/procedures.ts"
  click ProjProc "https://github.com/mrvineet-raj/vibe/blob/main/src/modules/projects/server/procedures.ts"
  click UsageProc "https://github.com/mrvineet-raj/vibe/blob/main/src/modules/usage/server/procedure.ts"
  click PrismaClient "https://github.com/mrvineet-raj/vibe/blob/main/src/lib/prisma.ts"
  click UsageLib "https://github.com/mrvineet-raj/vibe/blob/main/src/lib/usage.ts"
  click DB "https://github.com/mrvineet-raj/vibe/blob/main/prisma/schema.prisma"

  %% Styles
  classDef frontend fill:#D0E8FF,stroke:#0366d6,color:#0366d6
  classDef api fill:#DFFFD0,stroke:#228B22,color:#228B22
  classDef service fill:#FFF4D0,stroke:#FFA500,color:#FFA500
  classDef data fill:#F0F0F0,stroke:#A9A9A9,color:#333
  classDef database fill:#F0F0F0,stroke:#A9A9A9,color:#333
  classDef background fill:#FFEFD5,stroke:#FF8C00,color:#FF8C00
```
