# dibya-22/get-me-a-chai architecture

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

- Interactive diagram: https://gitdiagram.com/dibya-22/get-me-a-chai
- Repository: https://github.com/dibya-22/get-me-a-chai

## Overview

##### Project type and purpose
- This is a full-stack web application built with Next.js (app directory), TailwindCSS, NextAuth (auth), MongoDB/Mongoose (data), and Razorpay (payment).
- Purpose: let fans (“users”) sign in via GitHub, browse creator pages, and send small “chai-sized” payments. Creators get a dashboard to view supporters and earnings.

##### File structure
- Top-level directories:
- app/ – Next.js 13+ “app router” pages and API routes
- components/ – React UI components shared across pages
- actions/ – client/server actions for data fetching/mutation
- db/ – database connection helper (connectDB.js)
- models/ – Mongoose schemas (User.js, Payment.js)
- Key API routes:
- app/api/auth/[...nextauth]/route.js – authentication via GitHub
- app/api/razorpay/route.js – server API to create/verify payments
- Configs: next.config.mjs, tailwind.config.mjs, eslint.config.mjs, jsconfig.json.

##### Examining the README
- Confirms tech stack and flow: OAuth with GitHub, Razorpay integration, MongoDB for persistence.
- High-level workflow: sign in → view creator page → process payment → dashboard updates.

##### Detail
- MongoDB collections (users, payments)

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Frontend
    subgraph "Browser/Client" 
        direction TB
        Browser["Browser/Client"]:::frontend
    end

    subgraph "Next.js App" 
        direction TB
        subgraph "UI Layer" 
            direction TB
            HomePage["Home Page\n(app/page.js)"]:::frontend
            LoginPage["Login Page\n(app/login/page.js)"]:::frontend
            AboutPage["About Page\n(app/about/page.js)"]:::frontend
            CreatorPage["Creator Page\n(app/[username]/page.js)"]:::frontend
            DashboardPage["Dashboard Page\n(app/dashboard/page.js)"]:::frontend
            Navbar["Navbar\n(components/Navbar.js)"]:::frontend
            Footer["Footer\n(components/Footer.js)"]:::frontend
            SessionWrapper["SessionWrapper\n(components/SessionWrapper.js)"]:::frontend
            DashboardComp["Dashboard Component\n(components/Dashboard.js)"]:::frontend
            PaymentComp["Payment Page Component\n(components/PaymentPage.js)"]:::frontend
        end
        subgraph "API Layer" 
            direction TB
            AuthAPI["/api/auth\n(app/api/auth/[...nextauth]/route.js)"]:::backend
            PaymentAPI["/api/razorpay\n(app/api/razorpay/route.js)"]:::backend
            UserActions["User Actions\n(actions/useractions.js)"]:::backend
        end
        DBHelper["DB Connector\n(db/connectDB.js)"]:::backend
        UserModel["User Model\n(models/User.js)"]:::backend
        PaymentModel["Payment Model\n(models/Payment.js)"]:::backend
    end

    %% External Services
    NextAuthService["GitHub OAuth\n(NextAuth)"]:::external
    RazorpayService["Razorpay Gateway"]:::external

    %% Database
    MongoDB[(MongoDB
    Users, Payments)]:::database

    %% Connections
    Browser -->|renders| HomePage
    Browser -->|navigates| LoginPage
    Browser -->|navigates| AboutPage
    Browser -->|visits| CreatorPage
    Browser -->|visits| DashboardPage

    HomePage -->|uses| Navbar
    LoginPage -->|uses| SessionWrapper
    CreatorPage -->|uses| PaymentComp
    DashboardPage -->|uses| DashboardComp

    Browser -->|calls login| AuthAPI
    AuthAPI -->|redirects| NextAuthService
    NextAuthService -->|callback| AuthAPI
    AuthAPI -->|reads/writes| MongoDB

    Browser -->|calls pay| PaymentAPI
    PaymentAPI -->|requests| RazorpayService
    RazorpayService -->|callback| PaymentAPI
    PaymentAPI -->|writes| MongoDB

    DashboardPage -->|fetches data| UserActions
    UserActions -->|reads| MongoDB

    AuthAPI -->|connects via| DBHelper
    PaymentAPI -->|connects via| DBHelper
    UserActions -->|connects via| DBHelper

    DBHelper -->|init| MongoDB
    MongoDB -->|stores| UserModel
    MongoDB -->|stores| PaymentModel

    %% Click Events
    click HomePage "https://github.com/dibya-22/get-me-a-chai/blob/main/app/page.js"
    click LoginPage "https://github.com/dibya-22/get-me-a-chai/blob/main/app/login/page.js"
    click AboutPage "https://github.com/dibya-22/get-me-a-chai/blob/main/app/about/page.js"
    click CreatorPage "https://github.com/dibya-22/get-me-a-chai/blob/main/app/[username]/page.js"
    click DashboardPage "https://github.com/dibya-22/get-me-a-chai/blob/main/app/dashboard/page.js"
    click Navbar "https://github.com/dibya-22/get-me-a-chai/blob/main/components/Navbar.js"
    click Footer "https://github.com/dibya-22/get-me-a-chai/blob/main/components/Footer.js"
    click SessionWrapper "https://github.com/dibya-22/get-me-a-chai/blob/main/components/SessionWrapper.js"
    click DashboardComp "https://github.com/dibya-22/get-me-a-chai/blob/main/components/Dashboard.js"
    click PaymentComp "https://github.com/dibya-22/get-me-a-chai/blob/main/components/PaymentPage.js"
    click AuthAPI "https://github.com/dibya-22/get-me-a-chai/blob/main/app/api/auth/[...nextauth]/route.js"
    click PaymentAPI "https://github.com/dibya-22/get-me-a-chai/blob/main/app/api/razorpay/route.js"
    click DBHelper "https://github.com/dibya-22/get-me-a-chai/blob/main/db/connectDB.js"
    click UserModel "https://github.com/dibya-22/get-me-a-chai/blob/main/models/User.js"
    click PaymentModel "https://github.com/dibya-22/get-me-a-chai/blob/main/models/Payment.js"
    click UserActions "https://github.com/dibya-22/get-me-a-chai/blob/main/actions/useractions.js"

    %% Styles
    classDef frontend fill:#ADD8E6,stroke:#333,stroke-width:1px
    classDef backend fill:#90EE90,stroke:#333,stroke-width:1px
    classDef external fill:#FFA500,stroke:#333,stroke-width:1px
    classDef database fill:#FFFF99,stroke:#333,stroke-width:1px,stroke-dasharray: 5 5
```
