# ad1tya-a1/getchai-donation- architecture

> Architecture diagram of the GitHub repository ad1tya-a1/getchai-donation-, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-09-03). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/ad1tya-a1/getchai-donation-
- Repository: https://github.com/ad1tya-a1/getchai-donation-

## Overview

##### Project type and purpose
- This is a full-stack, React-based Next.js application with serverless API routes.
- Primary features: user authentication (NextAuth), payment processing (Razorpay), a user dashboard, and MongoDB persistence via Mongoose models.

##### File structure
- Top-level “app” folder holds all the UI routes and React components, following Next.js App Router conventions.
- app/page.js: public landing page
- app/logIn/page.js: login UI
- app/dashboard/page.js: protected dashboard UI
- app/[username]/page.js: dynamic user profiles
- app/components: reusable UI pieces (Navbar, Footer, SessionWrapper, PaymentPage, Dashboard)
- API layer under app/api:
- auth endpoints under app/api/auth/[...nextauth]/route.js (NextAuth handlers)
- razorpay endpoint under app/api/razorpay/route.js
- “actions” folder: client-side or server-side logic for calling APIs (useractions.js)
- Database connection file in db/connectDb.js
- Mongoose models in models/Payment.js and models/User.js
- Configuration files: next.config.mjs, postcss.config.mjs, eslint.config.mjs, jsconfig.json

##### README
- Confirms Next.js App Router setup (`create-next-app`)

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Frontend Layer
    subgraph "Frontend (Browser & UI)" 
        direction TB
        Browser["User Browser"]:::external
        subgraph "Next.js App Router" 
            direction TB
            Layout["layout.js"]:::router
            Globals["globals.css"]:::router
        end
        subgraph "Pages (app/*.js)" 
            direction TB
            Landing["app/page.js"]:::page
            LoginPage["app/logIn/page.js"]:::page
            DashboardPage["app/dashboard/page.js"]:::page
            ProfilePage["app/[username]/page.js"]:::page
        end
        subgraph "UI Components (app/components)" 
            direction TB
            Navbar["Navbar.js"]:::component
            Footer["Footer.js"]:::component
            SessionWrapper["SessionWrapper.js"]:::component
            PaymentPageComp["PaymentPage.js"]:::component
            DashboardComp["Dashboard.js"]:::component
            LoaderCSS["loader.css"]:::component
        end
        subgraph "Client Actions" 
            direction TB
            UserActions["actions/useractions.js"]:::action
        end
    end

    %% Backend Layer
    subgraph "Backend (Serverless API)" 
        direction TB
        subgraph "API Routes (app/api)" 
            direction TB
            AuthAPI["[...]nextauth]/route.js"]:::api
            RazorpayAPI["razorpay/route.js"]:::api
        end
        AuthService["NextAuth Service"]:::service
    end

    %% Data & External
    subgraph "Data & External Services"
        direction TB
        MongoDB["MongoDB"]:::database
        DBConnect["db/connectDb.js"]:::database
        subgraph "Mongoose Models" 
            direction TB
            UserModel["models/User.js"]:::model
            PaymentModel["models/Payment.js"]:::model
        end
        RazorpayExt["Razorpay"]:::external
    end

    %% Connections
    Browser -->|"SSR/CSR"| Landing
    Browser -->|"SSR/CSR"| LoginPage
    Browser -->|"SSR/CSR"| DashboardPage
    Browser -->|"SSR/CSR"| ProfilePage

    Landing --> Navbar
    LoginPage --> SessionWrapper
    DashboardPage --> SessionWrapper
    DashboardPage --> DashboardComp
    ProfilePage --> Navbar
    ProfilePage --> Footer

    SessionWrapper --> UserActions
    DashboardComp --> UserActions
    PaymentPageComp --> UserActions

    UserActions -->|"POST /api/auth"| AuthAPI
    UserActions -->|"POST /api/razorpay"| RazorpayAPI

    AuthAPI --> AuthService
    AuthService --> UserModel
    RazorpayAPI --> RazorpayExt
    RazorpayAPI --> PaymentModel

    UserModel --> DBConnect
    PaymentModel --> DBConnect
    DBConnect --> MongoDB

    %% Click Events
    click Landing "https://github.com/ad1tya-a1/getchai-donation-/blob/main/app/page.js"
    click LoginPage "https://github.com/ad1tya-a1/getchai-donation-/blob/main/app/logIn/page.js"
    click DashboardPage "https://github.com/ad1tya-a1/getchai-donation-/blob/main/app/dashboard/page.js"
    click ProfilePage "https://github.com/ad1tya-a1/getchai-donation-/blob/main/app/[username]/page.js"
    click Layout "https://github.com/ad1tya-a1/getchai-donation-/blob/main/app/layout.js"
    click Globals "https://github.com/ad1tya-a1/getchai-donation-/blob/main/app/globals.css"
    click Navbar "https://github.com/ad1tya-a1/getchai-donation-/blob/main/app/components/Navbar.js"
    click Footer "https://github.com/ad1tya-a1/getchai-donation-/blob/main/app/components/Footer.js"
    click SessionWrapper "https://github.com/ad1tya-a1/getchai-donation-/blob/main/app/components/SessionWrapper.js"
    click PaymentPageComp "https://github.com/ad1tya-a1/getchai-donation-/blob/main/app/components/PaymentPage.js"
    click DashboardComp "https://github.com/ad1tya-a1/getchai-donation-/blob/main/app/components/Dashboard.js"
    click LoaderCSS "https://github.com/ad1tya-a1/getchai-donation-/blob/main/app/components/loader.css"
    click UserActions "https://github.com/ad1tya-a1/getchai-donation-/blob/main/actions/useractions.js"
    click AuthAPI "https://github.com/ad1tya-a1/getchai-donation-/blob/main/app/api/auth/[...nextauth]/route.js"
    click RazorpayAPI "https://github.com/ad1tya-a1/getchai-donation-/blob/main/app/api/razorpay/route.js"
    click DBConnect "https://github.com/ad1tya-a1/getchai-donation-/blob/main/db/connectDb.js"
    click UserModel "https://github.com/ad1tya-a1/getchai-donation-/blob/main/models/User.js"
    click PaymentModel "https://github.com/ad1tya-a1/getchai-donation-/blob/main/models/Payment.js"
    click MongoDB "https://github.com/ad1tya-a1/getchai-donation-/tree/main/public/"

    %% Styles
    classDef external fill:#f9f,stroke:#333,stroke-width:1px
    classDef router fill:#bbf,stroke:#333,stroke-width:1px
    classDef page fill:#ade,stroke:#333,stroke-width:1px
    classDef component fill:#def,stroke:#333,stroke-width:1px
    classDef action fill:#ffd,stroke:#333,stroke-width:1px
    classDef api fill:#fdb,stroke:#333,stroke-width:1px
    classDef service fill:#fdc,stroke:#333,stroke-width:1px
    classDef database fill:#bfb,stroke:#333,stroke-width:1px
    classDef model fill:#dfd,stroke:#333,stroke-width:1px
```
