# the-lord-buddha-club/lord_buddha_club architecture

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

- Interactive diagram: https://gitdiagram.com/the-lord-buddha-club/lord_buddha_club
- Repository: https://github.com/the-lord-buddha-club/lord_buddha_club

## Overview

##### Project Type & Purpose
- This is a full-stack, monolithic Next.js application using the App Router.
- Purpose: a community platform for blog/event management, role-based dashboards, and user profiles.

##### File Structure & Tech Stack
- Frontend:
- `app/` directory contains React Server Components (pages, layouts, API routes).
- `components/` holds reusable UI pieces (shadcn/ui & custom).
- Backend/API:
- Next.js API Routes under `app/api/*` implement REST endpoints (auth, posts, events, roles, users).
- `lib/` contains business logic: `lib/auth` (NextAuth config), `lib/db` (Drizzle ORM schema & DB utilities), `lib/github`, `lib/utils`.
- Data Store:
- PostgreSQL (Neon) accessed via Drizzle ORM.
- External Services:
- NextAuth.js OAuth with GitHub
- Resend (email)
- Docker Compose orchestration
- DevOps / Config:
- `docker-compose.yml`, `.env.example`, `next.config.js`, `drizzle.config.ts`

##### Main Components & Their Roles
A. Client / UI Layer
- Browser ↔︎ Next.js pages (`app/*/page.tsx`) & React components (`components/*`).
- Theme & layout via `components/theme-provider.tsx`, `app/layout.tsx`.
B. API / Server Layer (Next.js Serverless Functions)
- Authentication: `app/api/auth/[...nextauth]/route.ts` backed by NextAuth.
- Content Management:
- Posts: `app/api/posts/*/route.ts`
- Events: `app/api/events/*/route.ts`
- Users & Roles: `app/api/users/*`, `app/api/roles/transfer/*`
C. Business Logic & Utilities
- `lib/auth/*`: session, roles, config
- `lib/db/*`: Drizzle schema, connectors
- `lib/github.ts`: GitHub-related utilities
- `lib/utils.ts`: shared helpers
D. Database
- PostgreSQL instance (Neon)
- Drizzle ORM for query building & migrations
E. External Services
- GitHub OAuth Provider (NextAuth)
- Resend Email Service
F. DevOps & Infrastructure
- Docker Compose: database container, app container
- Environment variables for secrets & URLs

##### Relationships & Data Flows
- User (Browser) → HTTP(S) requests → Next.js Frontend pages/components
- Pages invoke client-side data fetch or form submissions → Next.js API Routes
- API Routes → Drizzle ORM → PostgreSQL
- NextAuth callbacks → GitHub OAuth endpoints → NextAuth session store → user cookies
- Email triggers (e.g., verification) → Resend API
- Static assets served from `public/`

##### Architectural Patterns & Design Principles
- Monorepo / Monolithic Full-Stack: Single Next.js project containing both UI and API.
- MVC-like separation: pages (views), API routes (controllers), Drizzle + schema (model).
- Serverless micro-endpoints: each API folder under `app/api` is isolated.
- Reusable UI libs: `shadcn/ui` + custom components.
- Environment-driven config for secrets & URLs.

##### Essential Details to Capture
- Separation of concerns: UI vs API vs Data.
- Role-based dashboards: note Admin/Owner/Member flows under the Dashboard UI component.
- Authentication flow: user ↔ NextAuth ↔ GitHub ↔ Session store.
- Email sending path via Resend.
- Database migrations & ORM connections.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Client Layer
    subgraph "Client / Browser" 
        Browser["Browser"]:::ui
    end

    %% Next.js Monolith
    subgraph "Next.js Monolith"
        %% UI Layer
        subgraph "UI Layer"
            Layout["app/layout.tsx"]:::ui
            Home["app/page.tsx"]:::ui
            About["app/about/page.tsx"]:::ui
            Blog["app/blog/page.tsx"]:::ui
            Contact["app/contact/page.tsx"]:::ui
            DashboardPage["app/dashboard/page.tsx"]:::ui
            EventsPage["app/events/page.tsx"]:::ui
            Join["app/join/page.tsx"]:::ui
            Login["app/login/page.tsx"]:::ui
            ProfilePage["app/profile/page.tsx"]:::ui
            Projects["app/projects/page.tsx"]:::ui
            Verify["app/verify/page.tsx"]:::ui
            ThemeProv["components/theme-provider.tsx"]:::ui
            AuthProv["components/auth-provider.tsx"]:::ui
            Navbar["components/navbar.tsx"]:::ui
            Footer["components/footer.tsx"]:::ui
            Hero["components/hero-section.tsx"]:::ui
            LatestBlogs["components/latest-blogs.tsx"]:::ui
            FeaturedProj["components/featured-projects.tsx"]:::ui
            UIShadcn["components/ui/*"]:::ui
            DashboardComp["components/dashboard/*"]:::ui
            ProfileComp["components/profile/*"]:::ui
        end

        %% API Layer
        subgraph "API Layer"
            AuthAPI["app/api/auth/[...nextauth]/route.ts"]:::ui
            PostsAPI["app/api/posts/route.ts"]:::ui
            PostDetail["app/api/posts/[id]/route.ts"]:::ui
            EventsAPI["app/api/events/route.ts"]:::ui
            EventDetail["app/api/events/[id]/route.ts"]:::ui
            UserProfileAPI["app/api/users/profile/route.ts"]:::ui
            UserRoleAPI["app/api/users/[id]/role/route.ts"]:::ui
            UserStatsAPI["app/api/users/[id]/stats/route.ts"]:::ui
            RoleTransAPI["app/api/roles/transfer/route.ts"]:::ui
            RoleTransDetail["app/api/roles/transfer/[id]/route.ts"]:::ui
        end

        %% Business Logic & Utilities
        subgraph "Business Logic & Utilities"
            AuthConfig["lib/auth/config.ts"]:::ui
            AuthRoles["lib/auth/roles.ts"]:::ui
            AuthUtils["lib/auth/utils.ts"]:::ui
            DBSchema["lib/db/schema.ts"]:::data
            DBIndex["lib/db/index.ts"]:::data
            GitHubLib["lib/github.ts"]:::ext
            Utils["lib/utils.ts"]:::ui
        end
    end

    %% Database
    Database["PostgreSQL (Neon)"]:::data

    %% External Services
    GitHubOAuth["GitHub OAuth"]:::ext
    Resend["Resend Email Service"]:::ext

    %% Infrastructure
    subgraph "DevOps & Infrastructure"
        Docker["docker-compose.yml"]:::infra
        Env[".env.example"]:::infra
        NextConfig["next.config.js"]:::infra
        PostCSS["postcss.config.js"]:::infra
        Tailwind["tailwind.config.ts"]:::infra
        TSConfig["tsconfig.json"]:::infra
        Middleware["middleware.ts"]:::infra
    end

    %% Data Flows and Relationships
    Browser -->|"renders UI"| Layout
    Browser -->|"renders UI"| Home
    Home --> Hero
    Home --> LatestBlogs
    Home --> FeaturedProj

    Layout --> Navbar
    Layout --> Footer

    Home --> PostsAPI
    Blog --> PostsAPI
    PostDetail --> PostsAPI

    EventsPage --> EventsAPI
    EventDetail --> EventsAPI

    DashboardPage --> UserProfileAPI
    DashboardPage --> UserRoleAPI
    DashboardPage --> UserStatsAPI
    DashboardPage --> RoleTransAPI
    RoleTransDetail --> RoleTransAPI

    Login --> AuthAPI
    AuthAPI --> AuthConfig
    AuthAPI --> AuthUtils
    AuthAPI --> GitHubOAuth
    AuthOAuthCallback["Auth Callback"]:::ext
    GitHubOAuth --> AuthAPI

    AuthUtils --> Resend

    PostsAPI --> DBSchema
    PostDetail --> DBSchema
    EventsAPI --> DBSchema
    EventDetail --> DBSchema
    UserProfileAPI --> DBSchema
    UserRoleAPI --> DBSchema
    UserStatsAPI --> DBSchema
    RoleTransAPI --> DBSchema
    RoleTransDetail --> DBSchema

    DBSchema --> Database
    DBIndex --> Database

    Docker --- Browser
    Docker --- Database

    %% Click Events for Component Mapping
    click Layout "https://github.com/the-lord-buddha-club/lord_buddha_club/blob/main/app/layout.tsx"
    click Home "https://github.com/the-lord-buddha-club/lord_buddha_club/blob/main/app/page.tsx"
    click About "https://github.com/the-lord-buddha-club/lord_buddha_club/blob/main/app/about/page.tsx"
    click Blog "https://github.com/the-lord-buddha-club/lord_buddha_club/blob/main/app/blog/page.tsx"
    click Contact "https://github.com/the-lord-buddha-club/lord_buddha_club/blob/main/app/contact/page.tsx"
    click DashboardPage "https://github.com/the-lord-buddha-club/lord_buddha_club/blob/main/app/dashboard/page.tsx"
    click EventsPage "https://github.com/the-lord-buddha-club/lord_buddha_club/blob/main/app/events/page.tsx"
    click Join "https://github.com/the-lord-buddha-club/lord_buddha_club/blob/main/app/join/page.tsx"
    click Login "https://github.com/the-lord-buddha-club/lord_buddha_club/blob/main/app/login/page.tsx"
    click ProfilePage "https://github.com/the-lord-buddha-club/lord_buddha_club/blob/main/app/profile/page.tsx"
    click Projects "https://github.com/the-lord-buddha-club/lord_buddha_club/blob/main/app/projects/page.tsx"
    click Verify "https://github.com/the-lord-buddha-club/lord_buddha_club/blob/main/app/verify/page.tsx"
    click ThemeProv "https://github.com/the-lord-buddha-club/lord_buddha_club/blob/main/components/theme-provider.tsx"
    click AuthProv "https://github.com/the-lord-buddha-club/lord_buddha_club/blob/main/components/auth-provider.tsx"
    click Navbar "https://github.com/the-lord-buddha-club/lord_buddha_club/blob/main/components/navbar.tsx"
    click Footer "https://github.com/the-lord-buddha-club/lord_buddha_club/blob/main/components/footer.tsx"
    click Hero "https://github.com/the-lord-buddha-club/lord_buddha_club/blob/main/components/hero-section.tsx"
    click LatestBlogs "https://github.com/the-lord-buddha-club/lord_buddha_club/blob/main/components/latest-blogs.tsx"
    click FeaturedProj "https://github.com/the-lord-buddha-club/lord_buddha_club/blob/main/components/featured-projects.tsx"
    click UIShadcn "https://github.com/the-lord-buddha-club/lord_buddha_club/tree/main/components/ui/*"
    click DashboardComp "https://github.com/the-lord-buddha-club/lord_buddha_club/tree/main/components/dashboard/*"
    click ProfileComp "https://github.com/the-lord-buddha-club/lord_buddha_club/tree/main/components/profile/*"
    click AuthAPI "https://github.com/the-lord-buddha-club/lord_buddha_club/blob/main/app/api/auth/[...nextauth]/route.ts"
    click PostsAPI "https://github.com/the-lord-buddha-club/lord_buddha_club/blob/main/app/api/posts/route.ts"
    click PostDetail "https://github.com/the-lord-buddha-club/lord_buddha_club/blob/main/app/api/posts/[id]/route.ts"
    click EventsAPI "https://github.com/the-lord-buddha-club/lord_buddha_club/blob/main/app/api/events/route.ts"
    click EventDetail "https://github.com/the-lord-buddha-club/lord_buddha_club/blob/main/app/api/events/[id]/route.ts"
    click UserProfileAPI "https://github.com/the-lord-buddha-club/lord_buddha_club/blob/main/app/api/users/profile/route.ts"
    click UserRoleAPI "https://github.com/the-lord-buddha-club/lord_buddha_club/blob/main/app/api/users/[id]/role/route.ts"
    click UserStatsAPI "https://github.com/the-lord-buddha-club/lord_buddha_club/blob/main/app/api/users/[id]/stats/route.ts"
    click RoleTransAPI "https://github.com/the-lord-buddha-club/lord_buddha_club/blob/main/app/api/roles/transfer/route.ts"
    click RoleTransDetail "https://github.com/the-lord-buddha-club/lord_buddha_club/blob/main/app/api/roles/transfer/[id]/route.ts"
    click AuthConfig "https://github.com/the-lord-buddha-club/lord_buddha_club/blob/main/lib/auth/config.ts"
    click AuthRoles "https://github.com/the-lord-buddha-club/lord_buddha_club/blob/main/lib/auth/roles.ts"
    click AuthUtils "https://github.com/the-lord-buddha-club/lord_buddha_club/blob/main/lib/auth/utils.ts"
    click DBSchema "https://github.com/the-lord-buddha-club/lord_buddha_club/blob/main/lib/db/schema.ts"
    click DBIndex "https://github.com/the-lord-buddha-club/lord_buddha_club/blob/main/lib/db/index.ts"
    click GitHubLib "https://github.com/the-lord-buddha-club/lord_buddha_club/blob/main/lib/github.ts"
    click Utils "https://github.com/the-lord-buddha-club/lord_buddha_club/blob/main/lib/utils.ts"
    click Docker "https://github.com/the-lord-buddha-club/lord_buddha_club/blob/main/docker-compose.yml"
    click Env "https://github.com/the-lord-buddha-club/lord_buddha_club/blob/main/.env.example"
    click NextConfig "https://github.com/the-lord-buddha-club/lord_buddha_club/blob/main/next.config.js"
    click PostCSS "https://github.com/the-lord-buddha-club/lord_buddha_club/blob/main/postcss.config.js"
    click Tailwind "https://github.com/the-lord-buddha-club/lord_buddha_club/blob/main/tailwind.config.ts"
    click TSConfig "https://github.com/the-lord-buddha-club/lord_buddha_club/blob/main/tsconfig.json"
    click Middleware "https://github.com/the-lord-buddha-club/lord_buddha_club/blob/main/middleware.ts"

    %% Styles
    classDef ui fill:#D0E8FF,stroke:#0366D6,color:#0366D6;
    classDef data fill:#DFFFE0,stroke:#228B22,color:#228B22;
    classDef ext fill:#FFF4D9,stroke:#FF8C00,color:#FF8C00;
    classDef infra fill:#F2F2F2,stroke:#666666,color:#333333;
```
