How tusharthakur04/luma works
Project Type and Purpose
• This is a full-stack, monolithic Next.js (App Router) web application.
• It provides project-based messaging functionality (“projects,” “messages,” “fragments”).
• It uses tRPC for type-safe RPC endpoints, Inngest for background jobs, and Prisma as the ORM.
File Structure Analysis
• app/
• app/page.tsx, app/layout.tsx, app/globals.css: main layout, styling, and home page.
• app/api/…: Next.js serverless Route Handlers for HTTP endpoints (hello, inngest, trpc).
• app/projects/[projectId]/page.tsx: dynamic route for project-specific UI.
• components/ui/
• Reusable React UI primitives (buttons, tables, dialogs, etc.).
• trpc/
• trpc/server.tsx, trpc/routers/_app.ts, client setup, and query client.
• routes/
• Express-style custom endpoints (messageRoute.ts, projectRoute.ts) probably proxied from proxy.ts.
• inngest/
• client.ts, functions.ts: background job definitions and invocation code.
• lib/ and utils/
• prisma.ts: Prisma client instantiation.
• utils.ts, prompts.ts: shared utility functions.
• prisma/
• Schema, migrations, DB definitions (projects, messages, fragments).
• hooks/ and views/
• Client hooks (use-mobile.ts) and higher-order view components (project_view, signedInHomePage).
Relationships and Data Flows
• Browser → Next.js SSR/SSG: HTTP GET for pages (React components render).
• Browser → tRPC HTTP endpoint: JSON‐RPC over HTTP for data fetching/mutations.
• Browser → app/api Route Handlers: fetch or Axios to REST endpoints (hello, inngest).
• Next.js API / tRPC → Prisma → PostgreSQL: reads/writes project, message, fragment models.
• Next.js API → Inngest Client: enqueues background jobs (e.g., send notification, fragment analysis).
• Inngest Worker → Prisma → PostgreSQL: performs async work, updates database, emits events.
• Inngest Worker → External Systems (optional): email/SMS, third-party integrations.
Architectural Patterns and Principles
• Separation of Concerns:
• UI layer (React + components/ui)
• API layer (Next.js Route Handlers + tRPC)
• Data layer (Prisma + PostgreSQL)
• Background processing (Inngest)
• Type Safety End-to-End via tRPC and TypeScript.
• Serverless Functions under Next.js App Router architecture.
• Modularity: isolated routers in trpc/routers, and standalone Inngest functions.