# kkk1998sss/webinar architecture

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

- Interactive diagram: https://gitdiagram.com/kkk1998sss/webinar
- Repository: https://github.com/kkk1998sss/webinar

## Overview

##### Main Components
a. Client-side (Browser)
- User UI (public website, webinar flows, ebook/video library)
- Admin UI (CRUD interfaces for users, ebooks, videos, webinars)
b. Next.js Server Layer
- App Router pages & server actions (`src/app/…`)
- API Routes (serverless functions under `src/app/api/…`)
c. Data Layer
- Prisma ORM (`prisma/schema.prisma`)
- Underlying relational database (e.g., PostgreSQL)
d. Authentication & Authorization
- NextAuth (`src/app/api/auth/[...nextauth]`)
- Role checks in middleware (`src/middleware.ts`)
e. External Services
- Stripe (checkout sessions, webhooks)
- Razorpay (payments, webhooks)
- Twilio (OTP, SMS)
- Email/SMS providers (for reset-password, verify-otp)
f. Infrastructure & CI/CD
- Vercel (hosting, serverless functions)
- GitHub Actions (lint, tests, i18n workflows)

##### Relationships & Data Flows
- Browser → Next.js Frontend via HTTPS (React pages + client components)
- Frontend → Server Actions & API Routes (form submissions, data fetching)
- API Routes → Prisma → Database (CRUD operations)
- API Routes → External Services (Stripe/Razorpay checkout, Twilio OTP)
- External Services → API Webhooks → Next.js API Routes → Prisma/Notifications
- NextAuth connects browser and API for session management, calling OAuth providers

##### Architectural Patterns
- Next.js App Router (colocates page, layout, and route handlers)
- “Server Actions” (`src/actions/…`) for mutations without explicit API routes
- Serverless functions (each API directory maps to a separate lambda)
- Prisma migrations for evolving database schema
- Role-based access: public vs. authenticated vs. admin areas

##### Additional Details
- Where middleware (`middleware.ts`) enforces auth on routes
- Prisma migrations path and schema file to indicate database versioning
- An inset showing i18n flow (messages under `src/messages`, `src/lib/i18n`) if needed
- Optionally, add a separate “Testing” section: Jest & Playwright calling API and page routes

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Browser Layer
    subgraph "Browser"
        direction TB
        UserUI["User UI (Public Website & Webinar Flows)"]:::ui
        AdminUI["Admin UI (CRUD Interfaces)"]:::ui
    end

    %% Next.js Server Layer
    subgraph "Next.js Server Layer"
        direction TB
        subgraph "App Router Pages"
            direction TB
            RootLayout["Root Layout"]:::ui
            RootPage["Root Page"]:::ui
            ErrorPage["Error Page"]:::ui
            NotFound["Not Found Page"]:::ui
            AdminLayout["Admin Layout"]:::ui
        end
        ServerActions["Server Actions"]:::serverless
        APIRoutes["API Routes"]:::serverless
    end

    %% Auth Layer
    subgraph "Authentication & Authorization"
        direction TB
        NextAuthAPI["NextAuth API"]:::serverless
        Middleware["Middleware (Role Checks)"]:::serverless
    end

    %% Data Layer
    subgraph "Data Layer"
        direction TB
        Prisma["Prisma ORM"]:::db
        Migrations["Migrations"]:::db
        Database["Relational Database"]:::db
    end

    %% External Services
    subgraph "External Services"
        direction TB
        StripeCheckout["Stripe Checkout Session API"]:::ext
        StripeWebhook["Stripe Webhook Handler"]:::ext
        StripeLib["Stripe Client Library"]:::ext

        RazorpayPayments["Razorpay Payments API"]:::ext
        RazorpayVerify["Razorpay Verification API"]:::ext
        RazorpayWebhook["Razorpay Webhook Handler"]:::ext
        RazorpayLib["Razorpay Client Library"]:::ext

        TwilioSend["Send OTP API"]:::ext
        TwilioVerify["Verify OTP API"]:::ext
        TwilioLib["Twilio Client Library"]:::ext

        ResetPassword["Reset Password API"]:::ext
        VerificationAPI["Verification API"]:::ext
    end

    %% Dashboard & Upload
    Dashboard["Dashboard Endpoints"]:::serverless
    FileUpload["File Upload API"]:::serverless
    UploadLib["Upload Library"]:::ext

    %% CI/CD
    subgraph "Infrastructure & CI/CD"
        direction TB
        GitHubActions["GitHub Actions Workflows"]:::infra
        Vercel["Vercel Deployment"]:::infra
    end

    %% Connections
    UserUI -->|"HTTPS"| RootLayout
    AdminUI -->|"HTTPS"| AdminLayout

    RootLayout -->|renders| RootPage
    RootPage -->|error| ErrorPage
    RootPage -->|not found| NotFound

    RootPage -->|calls| ServerActions
    RootPage -->|fetches| APIRoutes

    ServerActions -->|CRUD| Prisma
    APIRoutes -->|CRUD| Prisma

    Prisma -->|migrations| Migrations
    Prisma -->|queries| Database

    APIRoutes -->|auth| NextAuthAPI
    APIRoutes -->|auth check| Middleware

    APIRoutes -->|calls| StripeCheckout
    APIRoutes -->|calls| RazorpayPayments
    APIRoutes -->|calls| TwilioSend
    APIRoutes -->|calls| ResetPassword

    StripeCheckout -->|webhook| StripeWebhook
    RazorpayPayments -->|verify| RazorpayVerify
    RazorpayPayments -->|webhook| RazorpayWebhook
    TwilioSend -->|verify| TwilioVerify

    StripeWebhook -->|updates| APIRoutes
    RazorpayWebhook -->|updates| APIRoutes
    TwilioVerify -->|updates| APIRoutes
    VerificationAPI -->|verification| APIRoutes

    Dashboard -->|data| Prisma
    FileUpload -->|stores| UploadLib

    GitHubActions -->|deploy| Vercel
    Vercel -->|hosts| APIRoutes
    Vercel -->|hosts| RootLayout

    %% Click Events
    click UserUI "https://github.com/kkk1998sss/webinar/tree/main/src/app/users"
    click AdminUI "https://github.com/kkk1998sss/webinar/tree/main/src/app/admin"
    click RootLayout "https://github.com/kkk1998sss/webinar/blob/main/src/app/layout.tsx"
    click RootPage "https://github.com/kkk1998sss/webinar/blob/main/src/app/page.tsx"
    click ErrorPage "https://github.com/kkk1998sss/webinar/blob/main/src/app/error/page.tsx"
    click NotFound "https://github.com/kkk1998sss/webinar/blob/main/src/app/not-found.tsx"
    click AdminLayout "https://github.com/kkk1998sss/webinar/blob/main/src/app/admin/layout.tsx"
    click ServerActions "https://github.com/kkk1998sss/webinar/tree/main/src/actions"
    click APIRoutes "https://github.com/kkk1998sss/webinar/tree/main/src/app/api"
    click Prisma "https://github.com/kkk1998sss/webinar/blob/main/prisma/schema.prisma"
    click Migrations "https://github.com/kkk1998sss/webinar/tree/main/prisma/migrations"
    click NextAuthAPI "https://github.com/kkk1998sss/webinar/blob/main/src/app/api/auth/[...nextauth]/route.ts"
    click Middleware "https://github.com/kkk1998sss/webinar/blob/main/src/middleware.ts"
    click StripeCheckout "https://github.com/kkk1998sss/webinar/blob/main/src/app/api/stripe/checkout-session/route.ts"
    click StripeWebhook "https://github.com/kkk1998sss/webinar/blob/main/src/app/api/stripe/webhook/route.ts"
    click StripeLib "https://github.com/kkk1998sss/webinar/blob/main/src/lib/stripe.ts"
    click RazorpayPayments "https://github.com/kkk1998sss/webinar/blob/main/src/app/api/razorpay/payments/route.ts"
    click RazorpayVerify "https://github.com/kkk1998sss/webinar/blob/main/src/app/api/razorpay/payments/verify/route.ts"
    click RazorpayWebhook "https://github.com/kkk1998sss/webinar/blob/main/src/app/api/razorpay/webhooks/razorpay/route.ts"
    click RazorpayLib "https://github.com/kkk1998sss/webinar/blob/main/src/lib/razorpay.ts"
    click TwilioSend "https://github.com/kkk1998sss/webinar/blob/main/src/app/api/send-otp/route.ts"
    click TwilioVerify "https://github.com/kkk1998sss/webinar/blob/main/src/app/api/verify-otp/route.ts"
    click TwilioLib "https://github.com/kkk1998sss/webinar/blob/main/src/lib/twilio.ts"
    click ResetPassword "https://github.com/kkk1998sss/webinar/blob/main/src/app/api/auth/reset-password/route.ts"
    click VerificationAPI "https://github.com/kkk1998sss/webinar/blob/main/src/app/api/verify/route.ts"
    click Dashboard "https://github.com/kkk1998sss/webinar/tree/main/src/app/api/dashboard"
    click FileUpload "https://github.com/kkk1998sss/webinar/blob/main/src/app/api/upload/route.ts"
    click UploadLib "https://github.com/kkk1998sss/webinar/blob/main/src/lib/upload.ts"
    click GitHubActions "https://github.com/kkk1998sss/webinar/tree/main/.github/workflows"
    click Vercel "https://github.com/kkk1998sss/webinar/blob/main/vercel.json"

    %% Styles
    classDef ui fill:#cce5ff,stroke:#339,stroke-width:1px
    classDef serverless fill:#d4edda,stroke:#282,stroke-width:1px
    classDef db fill:#ffe5cc,stroke:#a52,stroke-width:1px
    classDef ext fill:#e2e3e5,stroke:#666,stroke-width:1px
    classDef infra fill:#f0e0ff,stroke:#a0f,stroke-width:1px
```
