# hetansh2220/crewd architecture

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

- Interactive diagram: https://gitdiagram.com/hetansh2220/crewd
- Repository: https://github.com/hetansh2220/crewd

## Overview

##### Project type and purpose
- This is a full-stack Next.js application (“Chat-App”) built with the new App Router.
- It provides user authentication (via Privy), group chat, tipping, media streaming, and image uploads.
- The code includes both UI components under `src/app` & `src/components` and server-side logic under `src/server` plus a relational database via Drizzle ORM.

##### File structure
- Top-level files: Next.js config (`next.config.ts`), linting, formatting, Drizzle config, package manifests.
- `src/app`: the React/Next.js entrypoints for routes: `/`, `/login`, `/dashboard`, `/group/[id]`, `/[username]`.
- `src/components`: reusable UI building blocks (LandingPage, Dashboard, Login, Settings, ui folder).
- `src/server`: server functions or API handlers for groups, reviews, streams, tips, transactions, users.
- `src/db` + `drizzle.config.ts`: database connection, schema definitions, ORM configuration.
- `src/lib` + `src/hooks`: utility modules for streaming, transfers, general helpers.
- `src/providers`: wrap app with theme, Privy (auth), Cloudinary (media) context providers.

##### README
- Confirms the Next.js framework, bootstrapped via `create-next-app`.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Frontend Layer
    subgraph "Frontend" 
        direction TB
        Browser["User Browser"]:::frontend

        subgraph "Next.js App Router" 
            direction TB
            Home["Home Page"]:::frontend
            LoginPage["Login Page"]:::frontend
            DashboardPage["Dashboard Page"]:::frontend
            GroupPage["Group Chat Page"]:::frontend
            ProfilePage["User Profile Page"]:::frontend
        end

        subgraph "UI Components" 
            direction TB
            DashboardComp["Dashboard Components"]:::frontend
            LandingComp["Landing Page Components"]:::frontend
            LoginComp["Login Components"]:::frontend
            SettingsComp["Settings Components"]:::frontend
            TipsComp["Tips Component"]:::frontend
            SharedUI["Shared UI Primitives"]:::frontend
        end

        subgraph "Context Providers" 
            direction TB
            PrivyProv["Privy Provider"]:::frontend
            CloudinaryProv["Cloudinary Provider"]:::frontend
            ThemeProv["Theme Provider"]:::frontend
        end

        subgraph "Hooks" 
            direction TB
            UseTransfer["use-transfer Hook"]:::frontend
        end
    end

    %% Backend Layer
    subgraph "Backend" 
        direction TB
        subgraph "API Layer (Next.js Server Functions)" 
            direction TB
            GroupAPI["Group API"]:::backend
            ReviewAPI["Review API"]:::backend
            StreamAPI["Streaming API"]:::backend
            TipsAPI["Tips API"]:::backend
            TransactionAPI["Transaction API"]:::backend
            UserAPI["User API"]:::backend
        end

        subgraph "ORM & Database" 
            direction TB
            DrizzleCfg["Drizzle Config"]:::backend
            DBIndex["DB Connection & Schema"]:::backend
            PostgreSQL["PostgreSQL Database"]:::db
        end

        subgraph "Server Utilities" 
            direction TB
            StreamUtil["Streaming Utilities"]:::backend
            Utils["General Utilities"]:::backend
        end
    end

    %% External Services
    PrivyService["Privy Auth Service"]:::external
    CloudinaryService["Cloudinary Media Service"]:::external
    StreamingService["Streaming Service"]:::external
    BlockchainNet["Blockchain/Wallet Network"]:::external

    %% Connections
    Browser -->|"navigates to"| Home
    Browser -->|navigates to| LoginPage
    Browser -->|navigates to| DashboardPage
    Browser -->|navigates to| GroupPage
    Browser -->|navigates to| ProfilePage

    Home -->|uses| LandingComp
    LoginPage -->|uses| LoginComp
    DashboardPage -->|uses| DashboardComp
    DashboardPage -->|uses| SettingsComp
    DashboardPage -->|uses| TipsComp
    ProfilePage -->|uses| SharedUI

    LoginPage -->|wraps with| PrivyProv
    Home -->|wraps with| ThemeProv
    Home -->|wraps with| CloudinaryProv

    DashboardPage -->|calls| UseTransfer
    DashboardPage -->|calls| StreamUtil

    Home -->|"API call"| UserAPI
    LoginPage -->|"API call"| UserAPI
    DashboardPage -->|"API call"| GroupAPI
    DashboardPage -->|"API call"| TipsAPI
    GroupPage -->|"API call"| StreamAPI
    ProfilePage -->|"API call"| UserAPI

    UserAPI -->|queries| DBIndex
    GroupAPI -->|queries| DBIndex
    ReviewAPI -->|queries| DBIndex
    TipsAPI -->|queries| DBIndex
    TransactionAPI -->|queries| DBIndex

    StreamAPI -->|uses| StreamUtil
    StreamUtil -->|connects to| StreamingService
    TipsAPI -->|processes| TransactionAPI
    TransactionAPI -->|sends to| BlockchainNet

    UserAPI -->|uploads/downloads| CloudinaryService
    TipsAPI -->|uploads/downloads| CloudinaryService

    %% ORM to Database
    DBIndex -->|manages| PostgreSQL
    DrizzleCfg -->|configures| DBIndex

    %% Frontend auth/media flows
    Browser -->|auth flow| PrivyService
    Browser -->|media flow| CloudinaryService

    %% Styles
    classDef frontend fill:#E3F2FD,stroke:#2196F3,color:#0D47A1
    classDef backend fill:#E8F5E9,stroke:#4CAF50,color:#1B5E20
    classDef external fill:#FFF3E0,stroke:#FF9800,color:#E65100
    classDef db fill:#ECEFF1,stroke:#607D8B,color:#37474F

    %% Click Events
    click Home "https://github.com/hetansh2220/crewd/blob/main/src/app/page.tsx"
    click LoginPage "https://github.com/hetansh2220/crewd/blob/main/src/app/login/page.tsx"
    click DashboardPage "https://github.com/hetansh2220/crewd/blob/main/src/app/dashboard/page.tsx"
    click GroupPage "https://github.com/hetansh2220/crewd/blob/main/src/app/group/[id]/page.tsx"
    click ProfilePage "https://github.com/hetansh2220/crewd/blob/main/src/app/[username]/page.tsx"
    click DashboardComp "https://github.com/hetansh2220/crewd/tree/main/src/components/Dashboard"
    click LandingComp "https://github.com/hetansh2220/crewd/tree/main/src/components/LandingPage"
    click LoginComp "https://github.com/hetansh2220/crewd/tree/main/src/components/Login"
    click SettingsComp "https://github.com/hetansh2220/crewd/tree/main/src/components/Settings"
    click TipsComp "https://github.com/hetansh2220/crewd/blob/main/src/components/send-tip.tsx"
    click SharedUI "https://github.com/hetansh2220/crewd/tree/main/src/components/ui"
    click PrivyProv "https://github.com/hetansh2220/crewd/blob/main/src/providers/privy-provider.tsx"
    click CloudinaryProv "https://github.com/hetansh2220/crewd/blob/main/src/providers/cloudinary-provider.ts"
    click ThemeProv "https://github.com/hetansh2220/crewd/blob/main/src/providers/theme-provider.tsx"
    click GroupAPI "https://github.com/hetansh2220/crewd/blob/main/src/server/group.ts"
    click ReviewAPI "https://github.com/hetansh2220/crewd/blob/main/src/server/review.ts"
    click StreamAPI "https://github.com/hetansh2220/crewd/blob/main/src/server/stream.ts"
    click TipsAPI "https://github.com/hetansh2220/crewd/blob/main/src/server/tips.ts"
    click TransactionAPI "https://github.com/hetansh2220/crewd/blob/main/src/server/transaction.ts"
    click UserAPI "https://github.com/hetansh2220/crewd/blob/main/src/server/user.ts"
    click DrizzleCfg "https://github.com/hetansh2220/crewd/blob/main/drizzle.config.ts"
    click DBIndex "https://github.com/hetansh2220/crewd/blob/main/src/db/index.ts"
    click PostgreSQL "https://github.com/hetansh2220/crewd/blob/main/src/db/schema.ts"
    click StreamUtil "https://github.com/hetansh2220/crewd/blob/main/src/lib/stream.ts"
    click UseTransfer "https://github.com/hetansh2220/crewd/blob/main/src/hooks/use-transfer.tsx"
    click Utils "https://github.com/hetansh2220/crewd/blob/main/src/lib/utils.ts"
    click Utils "https://github.com/hetansh2220/crewd/blob/main/src/lib/connection.ts"
```
