# rhithesh/chaos_crowd architecture

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

- Interactive diagram: https://gitdiagram.com/rhithesh/chaos_crowd
- Repository: https://github.com/rhithesh/chaos_crowd

## Overview

##### Project type and purpose
- ChaosCrowd is a full-stack web application built on Next.js (using the App Router) that enables peer-to-peer fundraising via donation “blinks” on the Solana blockchain. The README calls out Solana blinks, NextAuth for authentication, Prisma with PostgreSQL, and Bun as the runtime.

##### File structure
- Top-level “app” directory: Next.js server-and-client routes and pages (app/api, app/page.tsx, layout.tsx, etc.).
- “components”: React UI components organized by feature (Auth, Discover, Dashboard, global, ui).
- “provider”: Custom React context providers (SessionProvider, AppWalletProvider, theme).
- “lib” and “hooks”: Business logic utilities (auth and fetchers) and custom hooks.
- “prisma”: Database schema and migrations (PostgreSQL via Prisma).
- Config files: next.config.mjs, tsconfig.json, tailwind.config.ts, postcss.config.mjs.
- State management: zustand folder.

##### README for additional insights
- It confirms the stack: Bun, Next.js, Docker-hosted Postgres, Prisma, NextAuth (OAuth via Google), Solana wallet integration.

## Diagram (Mermaid)

```mermaid
graph TD
    %% Frontend / Client
    subgraph "Browser / Client"
        direction TB
        subgraph "Pages & Routing" 
            direction TB
            Layout["app/layout.tsx"]:::frontend
            HomePage["app/page.tsx"]:::frontend
            LoginPage["app/auth/login/page.tsx"]:::frontend
            DashboardPage["app/dashboard/page.tsx"]:::frontend
            DiscoverPage["app/discover/page.tsx"]:::frontend
        end
        subgraph "UI Components"
            direction TB
            GlobalUI["components/global/*"]:::frontend
            CoreUI["components/ui/*"]:::frontend
            DiscoverUI["components/Discover/*"]:::frontend
            DashboardUI["components/dashboard/Form.tsx"]:::frontend
            AuthUI["components/Auth/signin.tsx"]:::frontend
        end
        subgraph "Providers & State"
            direction TB
            SessionProv["provider/SessionProvider.tsx"]:::frontend
            WalletProv["provider/AppWalletProvider.tsx"]:::frontend
            ZustandStore["zustand/index.ts"]:::frontend
        end
        subgraph "Hooks & Utils"
            direction TB
            ToastHook["hooks/use-toast.ts"]:::frontend
            AuthHelper["lib/auth.ts"]:::frontend
            FetchUser["lib/fetchUser.ts"]:::frontend
            Utils["lib/utils.ts"]:::frontend
        end
    end

    %% Next.js Server
    subgraph "Next.js Server (SSR + API)" 
        direction TB
        subgraph "Server-side Rendering"
            direction TB
            SSRLayouts["app/layout.tsx"]:::backend
            SSRPages["app/page.tsx"]:::backend
        end
        subgraph "API Routes"
            direction TB
            AuthAPI["app/api/auth/[...nextauth]/route.ts"]:::backend
            DonateAPI["app/api/actions/donate/route.ts"]:::backend
            BlinksAPI["app/api/blinks/route.ts"]:::backend
        end
        NextAuthService["NextAuth (Session Store)"]:::backend
        PrismaClient["lib/prismaDb.ts"]:::backend
        ConfigFiles["next.config.mjs\ntsconfig.json\npostcss.config.mjs\ntailwind.config.ts"]:::backend
    end

    %% Database and External Services
    Google["Google OAuth"]:::external
    Postgres[(PostgreSQL)]:::database
    Solana["Solana RPC Nodes"]:::external

    %% Client to Server
    Layout -->|renders via HTTPS| SSRLayouts
    HomePage --> SSRPages
    LoginPage --> SSRPages
    DashboardPage --> SSRPages
    DiscoverPage --> SSRPages

    %% Client API calls
    GlobalUI -->|UI Actions| AuthAPI
    DashboardUI -->|donate| DonateAPI
    DiscoverUI -->|CRUD blinks| BlinksAPI
    AuthUI -->|sign in| AuthAPI

    %% Providers & State
    SessionProv --> AuthAPI
    WalletProv --> DonateAPI
    ZustandStore --> SSRPages

    %% Server internals
    AuthAPI -->|uses| NextAuthService
    NextAuthService -->|stores session| Postgres
    DonateAPI -->|validates session| NextAuthService
    DonateAPI -->|requests tx| Solana
    BlinksAPI -->|CRUD| PrismaClient
    PrismaClient --> Postgres

    %% External flows
    AuthAPI -->|OAuth| Google
    DonateAPI -->|RPC| Solana

    %% Click Events
    click Layout "https://github.com/rhithesh/chaos_crowd/blob/main/app/layout.tsx"
    click HomePage "https://github.com/rhithesh/chaos_crowd/blob/main/app/page.tsx"
    click LoginPage "https://github.com/rhithesh/chaos_crowd/blob/main/app/auth/login/page.tsx"
    click DashboardPage "https://github.com/rhithesh/chaos_crowd/blob/main/app/dashboard/page.tsx"
    click DiscoverPage "https://github.com/rhithesh/chaos_crowd/blob/main/app/discover/page.tsx"
    click AuthAPI "https://github.com/rhithesh/chaos_crowd/blob/main/app/api/auth/[...nextauth]/route.ts"
    click DonateAPI "https://github.com/rhithesh/chaos_crowd/blob/main/app/api/actions/donate/route.ts"
    click BlinksAPI "https://github.com/rhithesh/chaos_crowd/blob/main/app/api/blinks/route.ts"
    click GlobalUI "https://github.com/rhithesh/chaos_crowd/tree/main/components/global/*"
    click CoreUI "https://github.com/rhithesh/chaos_crowd/tree/main/components/ui/*"
    click DiscoverUI "https://github.com/rhithesh/chaos_crowd/tree/main/components/Discover/*"
    click DashboardUI "https://github.com/rhithesh/chaos_crowd/blob/main/components/dashboard/Form.tsx"
    click AuthUI "https://github.com/rhithesh/chaos_crowd/blob/main/components/Auth/signin.tsx"
    click SessionProv "https://github.com/rhithesh/chaos_crowd/blob/main/provider/SessionProvider.tsx"
    click WalletProv "https://github.com/rhithesh/chaos_crowd/blob/main/provider/AppWalletProvider.tsx"
    click ZustandStore "https://github.com/rhithesh/chaos_crowd/blob/main/zustand/index.ts"
    click ToastHook "https://github.com/rhithesh/chaos_crowd/blob/main/hooks/use-toast.ts"
    click AuthHelper "https://github.com/rhithesh/chaos_crowd/blob/main/lib/auth.ts"
    click FetchUser "https://github.com/rhithesh/chaos_crowd/blob/main/lib/fetchUser.ts"
    click Utils "https://github.com/rhithesh/chaos_crowd/blob/main/lib/utils.ts"
    click PrismaClient "https://github.com/rhithesh/chaos_crowd/blob/main/lib/prismaDb.ts"

    %% Styles
    classDef frontend fill:#D0E8FF,stroke:#4287f5,color:#000
    classDef backend fill:#D5F5D0,stroke:#28a745,color:#000
    classDef external fill:#FFE5B4,stroke:#ff8c00,color:#000
    classDef database fill:#F0D9FF,stroke:#9b59b6,color:#000
```
