# suraj-9849/lms architecture

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

- Interactive diagram: https://gitdiagram.com/suraj-9849/lms
- Repository: https://github.com/suraj-9849/lms

## Overview

##### High-Level Architecture Components

a) Client Layer
- Next.js Frontend (Pages and Components)
- Authentication UI
- Course Management Interface
- Video Player Interface

b) Server Layer (API Routes)
- Authentication Services
- Course Management
- Payment Processing
- Video Management

c) Data Layer
- PostgreSQL Database (via Prisma ORM)
- AWS S3 (Video Storage)

d) External Services
- Stripe Payment Gateway
- AWS Services

##### Component Relationships

Frontend → API Layer:
- RESTful API routes (/api/*)
- Authentication flow
- Course management operations
- Payment processing flow

API Layer → Services:
- Database operations through Prisma
- File storage operations to AWS S3
- Payment processing through Stripe

##### Detailed Component Breakdown

Frontend Components:
- Dashboard Layout
- Course Management
- Video Player
- Authentication Forms
- User Profile

API Routes (Group by functionality):
- Auth Routes (/api/auth/*)
- Course Routes (/api/course/*)
- Payment Routes (/api/payment/*)
- Video Management Routes (/api/upload-video/*)

Database Layer:
- User Model
- Course Model
- Video Model
- Payment/Purchase Model

##### Key Flows to Highlight

a) Authentication Flow:
- Sign up/Login process
- JWT token handling
- Session management

b) Course Creation Flow:
- Course creation
- Video upload to S3
- Course publication

c) Purchase Flow:
- Course purchase
- Stripe integration
- Access management

##### Technical Details

Framework Specific:
- Next.js 13+ App Router
- API Routes structure
- Server Components vs Client Components

Security Layer:
- JWT Authentication
- Bcrypt password hashing
- Access control

Database Layer:
- Prisma Schema
- PostgreSQL tables
- Relationships between entities

## Diagram (Mermaid)

```mermaid
flowchart TB
    subgraph Client
        UI[User Interface]
        AuthUI[Authentication UI]:::authui
        CourseUI[Course Management Interface]:::courseui
        VideoUI[Video Player Interface]:::videoui
        ProfileUI[Profile Management]:::profileui
        DashLayout[Dashboard Layout]:::layout
    end

    subgraph API
        AuthAPI[Authentication Services]:::authapi
        CourseAPI[Course Management API]:::courseapi
        PaymentAPI[Payment Processing API]:::paymentapi
        VideoAPI[Video Management API]:::videoapi
        ProfileAPI[User Profile API]:::profileapi
    end

    subgraph Security
        JWT[JWT Authentication]
        ZodVal[Zod Validation]:::security
        Bcrypt[Password Hashing]:::security
        Middleware[Auth Middleware]:::security
    end

    subgraph "External Services"
        Stripe[Stripe Payment Gateway]
        S3[AWS S3 Storage]
    end

    subgraph "Data Layer"
        DB[(PostgreSQL Database)]:::database
        PrismaORM[Prisma ORM]:::database
    end

    UI --> AuthUI
    UI --> CourseUI
    UI --> VideoUI
    UI --> ProfileUI
    UI --> DashLayout

    AuthUI --> AuthAPI
    CourseUI --> CourseAPI
    VideoUI --> VideoAPI
    ProfileUI --> ProfileAPI

    AuthAPI --> JWT
    AuthAPI --> Bcrypt
    AuthAPI --> ZodVal
    AuthAPI --> Middleware

    CourseAPI --> PrismaORM
    VideoAPI --> S3
    PaymentAPI --> Stripe
    ProfileAPI --> PrismaORM

    PrismaORM --> DB

    %% Click Events
    click AuthUI "https://github.com/suraj-9849/lms/blob/main/src/app/login/page.tsx"
    click CourseUI "https://github.com/suraj-9849/lms/tree/main/src/app/dashboard/course"
    click VideoUI "https://github.com/suraj-9849/lms/blob/main/src/app/dashboard/course/[course_id]/video/[video_id]/page.tsx"
    click ProfileUI "https://github.com/suraj-9849/lms/blob/main/src/app/dashboard/profile/page.tsx"
    click DashLayout "https://github.com/suraj-9849/lms/blob/main/src/app/dashboard/layout.tsx"
    click AuthAPI "https://github.com/suraj-9849/lms/tree/main/src/app/api/auth"
    click CourseAPI "https://github.com/suraj-9849/lms/blob/main/src/app/api/courses/route.ts"
    click PaymentAPI "https://github.com/suraj-9849/lms/blob/main/src/app/api/create-checkout-session/route.ts"
    click VideoAPI "https://github.com/suraj-9849/lms/blob/main/src/app/api/upload-video/route.ts"
    click ProfileAPI "https://github.com/suraj-9849/lms/blob/main/src/app/api/user/profile/route.ts"
    click ZodVal "https://github.com/suraj-9849/lms/blob/main/src/utils/zod.ts"
    click Bcrypt "https://github.com/suraj-9849/lms/blob/main/src/utils/password.ts"
    click Middleware "https://github.com/suraj-9849/lms/blob/main/src/app/middleware.ts"
    click PrismaORM "https://github.com/suraj-9849/lms/blob/main/src/lib/prisma.ts"

    %% Styling
    classDef authui fill:#2196F3,color:white
    classDef courseui fill:#2196F3,color:white
    classDef videoui fill:#2196F3,color:white
    classDef profileui fill:#2196F3,color:white
    classDef layout fill:#2196F3,color:white
    classDef authapi fill:#4CAF50,color:white
    classDef courseapi fill:#4CAF50,color:white
    classDef paymentapi fill:#4CAF50,color:white
    classDef videoapi fill:#4CAF50,color:white
    classDef profileapi fill:#4CAF50,color:white
    classDef security fill:#FF5722,color:white
    classDef database fill:#9C27B0,color:white

    %% Legend
    subgraph Legend
        Frontend[Frontend Components]:::authui
        APIRoutes[API Routes]:::authapi
        SecurityComp[Security Components]:::security
        DataStore[Data Storage]:::database
    end
```
