# datakult0r/meta-stack architecture

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

- Interactive diagram: https://gitdiagram.com/datakult0r/meta-stack
- Repository: https://github.com/datakult0r/meta-stack

## Overview

##### Main System Components

a) Frontend Layer:
- Sub-components:
- Pages/Routes (from src/app)
- UI Components (from src/components)
- Client-side Hooks (from src/hooks)
- Theme System

b) API Layer:
- tRPC Routes
- NextAuth Authentication
- API Routes (transcribe, upload)
- Inngest Event Handler

c) Backend Services:
- Supabase Database (via Prisma ORM)
- AI Services Integration
- AWS S3 Storage
- Resend Email Service
- Background Jobs (Inngest)

##### Connection Flows

- Client → API Layer (tRPC calls)
- API Layer → Database (Prisma queries)
- API Layer → External Services
- Authentication flow with NextAuth
- Background job workflows with Inngest

##### Specific Implementation Details

**Frontend:**
- Next.js 14 App Router
- TailwindCSS
- React Components
- TypeScript

**API Layer:**
- tRPC Endpoints
- NextAuth Integration
- REST API Routes

**Backend Services:**
- Prisma ORM
- Multiple AI Providers
- Email Service
- File Storage

##### Key Architectural Patterns to Highlight

- Type-safe API calls with tRPC
- Server-side rendering with Next.js
- Authentication flow with NextAuth
- Background job processing
- Email templating system
- Theme system implementation

##### Additional Elements

Supporting elements:
- Environment configuration
- Build/Deploy pipeline
- Development tools (Storybook)
- Type system flow

##### Important Notes

- Type-safety aspect between frontend and backend
- Distinction between server and client components
- How the authentication flow integrates with the rest of the system
- How background jobs are processed through Inngest
- Email template system architecture
- How the theme system is implemented

Remember to maintain a balance between detail and clarity, focusing on the architectural decisions that make this template unique, such as the AI integration options and the type-safe API layer with tRPC.

## Diagram (Mermaid)

```mermaid
graph TB
    subgraph Frontend
        NextApp["Next.js Frontend (App Router)"]
        Routes["Pages/Routes"]:::frontend
        UIComp["UI Components"]:::frontend
        Hooks["Client-side Hooks"]:::frontend
        Theme["Theme System"]:::frontend
        
        NextApp --> Routes
        NextApp --> UIComp
        NextApp --> Hooks
        NextApp --> Theme
    end

    subgraph APILayer
        TRPC["tRPC Routes"]:::api
        Auth["NextAuth Authentication"]:::api
        TransAPI["Transcribe API"]:::api
        UploadAPI["Upload API"]:::api
        InngestHandler["Inngest Event Handler"]:::api
    end

    subgraph BackendServices
        DB[(Supabase Database)]:::database
        AI["AI Services"]:::service
        Storage["AWS S3"]:::service
        Email["Resend Email"]:::service
        BGJobs["Background Jobs (Inngest)"]:::service
    end

    subgraph CoreLibraries
        Types["Type Definitions"]:::lib
        AuthLib["Authentication Logic"]:::lib
        TRPCClient["tRPC Client"]:::lib
        TRPCServer["tRPC Server"]:::lib
        EmailTemplates["Email Templates"]:::lib
        SchemaVal["Schema Validation"]:::lib
    end

    NextApp --> APILayer
    TRPC --> DB
    Auth --> DB
    TransAPI --> AI
    UploadAPI --> Storage
    InngestHandler --> BGJobs
    BGJobs --> Email
    Email --> EmailTemplates
    TRPC --> TRPCServer
    TRPCClient --> TRPC

    click Routes "https://github.com/Datakult0r/Meta-stack/tree/main/src/app"
    click UIComp "https://github.com/Datakult0r/Meta-stack/tree/main/src/components"
    click Theme "https://github.com/Datakult0r/Meta-stack/tree/main/src/components/theme"
    click Hooks "https://github.com/Datakult0r/Meta-stack/tree/main/src/hooks"
    click TRPC "https://github.com/Datakult0r/Meta-stack/tree/main/src/app/api/trpc/[trpc]"
    click Auth "https://github.com/Datakult0r/Meta-stack/blob/main/src/app/api/auth/[...nextauth]"
    click TransAPI "https://github.com/Datakult0r/Meta-stack/tree/main/src/app/api/transcribe"
    click UploadAPI "https://github.com/Datakult0r/Meta-stack/tree/main/src/app/api/upload"
    click InngestHandler "https://github.com/Datakult0r/Meta-stack/blob/main/src/app/api/inngest/handler.ts"
    click DB "https://github.com/Datakult0r/Meta-stack/blob/main/prisma/schema.prisma"
    click AI "https://github.com/Datakult0r/Meta-stack/blob/main/src/lib/aiClient.ts"
    click Storage "https://github.com/Datakult0r/Meta-stack/blob/main/src/lib/storage.ts"
    click Email "https://github.com/Datakult0r/Meta-stack/tree/main/src/lib/email"
    click BGJobs "https://github.com/Datakult0r/Meta-stack/blob/main/src/lib/inngest.ts"
    click Types "https://github.com/Datakult0r/Meta-stack/blob/main/src/lib/types.ts"
    click AuthLib "https://github.com/Datakult0r/Meta-stack/tree/main/src/lib/auth"
    click TRPCClient "https://github.com/Datakult0r/Meta-stack/blob/main/src/lib/trpc/client.ts"
    click TRPCServer "https://github.com/Datakult0r/Meta-stack/blob/main/src/lib/trpc/server.ts"
    click EmailTemplates "https://github.com/Datakult0r/Meta-stack/tree/main/src/lib/email/templates"
    click SchemaVal "https://github.com/Datakult0r/Meta-stack/blob/main/src/lib/zod/userSchemas.ts"

    classDef frontend fill:#2563eb,color:white
    classDef api fill:#22c55e,color:white
    classDef service fill:#f97316,color:white
    classDef database fill:#9333ea,color:white
    classDef lib fill:#64748b,color:white

    subgraph Legend
        Frontend_["Frontend"]:::frontend
        API_["API Layer"]:::api
        Service_["Services"]:::service
        Database_["Database"]:::database
        Library_["Libraries"]:::lib
    end
```
