# tusharthakur04/luma architecture

> Architecture diagram of the GitHub repository tusharthakur04/luma, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-02-04). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/tusharthakur04/luma
- Repository: https://github.com/tusharthakur04/luma

## Overview

##### 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.

## Diagram (Mermaid)

```mermaid
flowchart TB
    subgraph "Frontend Layer"
        Browser["Browser"]:::frontend
        SSR["Next.js SSR/SSG\n(app/page.tsx, app/layout.tsx, app/projects/[projectId]/page.tsx)"]:::frontend
        UI["UI Components\n(components/ui)"]:::frontend
        HOViews["Hooks & Views\n(hooks/use-mobile.ts, views/project_view.tsx, views/signedInHomePage.tsx)"]:::frontend
    end

    subgraph "API Layer"
        NextAPI["Next.js Route Handlers\n(app/api/hello/route.ts, app/api/inngest/route.ts, app/api/trpc/[trpc]/route.ts)"]:::api
        tRPCServer["tRPC Server\n(trpc/server.tsx, trpc/routers/_app.ts)"]:::api
        tRPCClient["tRPC Client\n(trpc/client.tsx, trpc/query-client.ts, trpc/init.ts)"]:::api
        ExpressRoutes["Express-style Routes\n(routes/projectRoute.ts, routes/messageRoute.ts, proxy.ts)"]:::api
    end

    subgraph "Data Layer"
        PrismaClient["Prisma Client\n(lib/prisma.ts)"]:::db
        Postgres["PostgreSQL\n(prisma/schema.prisma, prisma/migrations/)"]:::db
    end

    subgraph "Worker Layer"
        InngestClient["Inngest Client\n(inngest/client.ts)"]:::worker
        InngestFunctions["Inngest Functions\n(inngest/functions.ts)"]:::worker
        InngestWorker["Inngest Worker"]:::worker
    end

    Utils["Utilities\n(lib/utils.ts, utils/prompts.ts)"]:::util
    External["External Systems\n(email/SMS, 3rd party)"]:::external

    Browser -->|"GET pages"| SSR
    SSR -->|"renders pages"| Browser
    Browser -->|"tRPC RPC"| tRPCClient
    Browser -->|"Fetch REST"| NextAPI

    tRPCClient -->|"RPC HTTP"| tRPCServer
    NextAPI -->|"HTTP REST"| PrismaClient
    tRPCServer -->|"RPC→ORM"| PrismaClient
    NextAPI -->|"Enqueue job"| InngestClient

    InngestClient -->|"Define job"| InngestFunctions
    InngestWorker -->|"Invoke functions"| InngestFunctions
    InngestFunctions -->|"ORM access"| PrismaClient
    InngestWorker -->|"Uses ORM"| PrismaClient
    PrismaClient -->|"SQL queries"| Postgres
    InngestWorker -->|"External calls"| External

    classDef frontend fill:#AEDFF7,stroke:#333,stroke-width:1px
    classDef api fill:#C6F7DD,stroke:#333,stroke-width:1px
    classDef db fill:#FFD8B8,stroke:#333,stroke-width:1px
    classDef worker fill:#E0C4FE,stroke:#333,stroke-width:1px
    classDef util fill:#ECECEC,stroke:#333,stroke-width:1px
    classDef external fill:#F0F0F0,stroke:#333,stroke-width:1px

    click SSR "https://github.com/tusharthakur04/luma/blob/main/app/layout.tsx"
    click SSR "https://github.com/tusharthakur04/luma/blob/main/app/page.tsx"
    click SSR "https://github.com/tusharthakur04/luma/blob/main/app/projects/[projectId]/page.tsx"
    click UI "https://github.com/tusharthakur04/luma/tree/main/components/ui"
    click NextAPI "https://github.com/tusharthakur04/luma/blob/main/app/api/hello/route.ts"
    click NextAPI "https://github.com/tusharthakur04/luma/blob/main/app/api/inngest/route.ts"
    click NextAPI "https://github.com/tusharthakur04/luma/blob/main/app/api/trpc/[trpc]/route.ts"
    click tRPCServer "https://github.com/tusharthakur04/luma/blob/main/trpc/server.tsx"
    click tRPCServer "https://github.com/tusharthakur04/luma/blob/main/trpc/routers/_app.ts"
    click tRPCClient "https://github.com/tusharthakur04/luma/blob/main/trpc/client.tsx"
    click tRPCClient "https://github.com/tusharthakur04/luma/blob/main/trpc/query-client.ts"
    click tRPCClient "https://github.com/tusharthakur04/luma/blob/main/trpc/init.ts"
    click ExpressRoutes "https://github.com/tusharthakur04/luma/blob/main/routes/projectRoute.ts"
    click ExpressRoutes "https://github.com/tusharthakur04/luma/blob/main/routes/messageRoute.ts"
    click ExpressRoutes "https://github.com/tusharthakur04/luma/blob/main/proxy.ts"
    click PrismaClient "https://github.com/tusharthakur04/luma/blob/main/lib/prisma.ts"
    click Postgres "https://github.com/tusharthakur04/luma/blob/main/prisma/schema.prisma"
    click Postgres "https://github.com/tusharthakur04/luma/tree/main/prisma/migrations/"
    click InngestFunctions "https://github.com/tusharthakur04/luma/blob/main/inngest/functions.ts"
    click InngestClient "https://github.com/tusharthakur04/luma/blob/main/inngest/client.ts"
    click Utils "https://github.com/tusharthakur04/luma/blob/main/lib/utils.ts"
    click Utils "https://github.com/tusharthakur04/luma/blob/main/utils/prompts.ts"
    click HOViews "https://github.com/tusharthakur04/luma/blob/main/hooks/use-mobile.ts"
    click HOViews "https://github.com/tusharthakur04/luma/blob/main/views/project_view.tsx"
    click HOViews "https://github.com/tusharthakur04/luma/blob/main/views/signedInHomePage.tsx"
```
