# code100x/cms architecture

> Architecture diagram of the GitHub repository code100x/cms, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2024-12-28). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/code100x/cms
- Repository: https://github.com/code100x/cms

## Overview

##### Main Components

a) Frontend Layer:
- Next.js Application (React)
- Client-side Components (/src/components)
- Server Components (app directory structure)
- Authentication UI (/src/components/auth)
- Admin Dashboard (/src/app/admin)
- Video Player Components
- Search Interface

b) API Layer:
- Next.js API Routes (/src/app/api)
- Authentication Endpoints
- Course Management
- Video Management
- Discord Integration
- GitHub Integration
- Mobile API Endpoints

c) Database Layer:
- PostgreSQL Database (indicated by Prisma usage)
- Prisma ORM Layer
- Cache Layer (Redis and In-memory caching)

d) External Services:
- Discord Integration
- GitHub OAuth
- Video Storage/Streaming
- Google Analytics
- Notion Integration

**[Client Layer]**
- ↕
**[API/Server Layer]**
- ↕
**[Data Layer]**

##### Key Relationships to Highlight

a) Authentication Flow:
- NextAuth.js integration
- OAuth providers (GitHub, Discord)
- Session management

b) Content Delivery:
- Video streaming pipeline
- Course content delivery
- PDF handling
- Certificate generation

c) Data Flow:
- Prisma ORM interactions
- Caching mechanisms
- Search functionality

##### Infrastructure Elements

- Docker containers
- Development vs Production environments
- Database migrations
- Cache layers

##### Specific Implementation Details

- Video player implementation
- Certificate verification system
- Bookmark system
- Comment system
- Search functionality
- Calendar integration

##### Additional Notes

- Version control workflow
- CI/CD pipeline (.github/workflows)
- Security boundaries
- Public vs protected routes
- Error handling paths

This system design should emphasize the modern Next.js app router architecture while showing how it integrates with various services and handles different types of content (video, PDF, certificates) through a unified interface.

## Diagram (Mermaid)

```mermaid
graph TB
    subgraph Client
        FE[Frontend Application]
        COMP["Components"]
        ADMIN["Admin Dashboard"]:::admin
        VP["Video Player"]:::player
        SEARCH["Search Interface"]:::search
        AUTH_UI["Auth Components"]
        BOOK["Bookmark System"]:::bookmark
        COMM["Comment System"]:::comment
        ANAL["Analytics"]:::analytics
    end

    subgraph API
        API["API Layer"]
        AUTH["Authentication"]:::auth
        MOBILE["Mobile API"]:::mobile
        DISCORD["Discord Integration"]:::discord
        GITHUB["GitHub Integration"]:::github
        NOTION["Notion Integration"]:::notion
        COURSE["Course Management"]:::course
        CERT["Certificate System"]:::cert
        CAL["Calendar System"]:::calendar
    end

    subgraph Data
        DB[(PostgreSQL)]
        PRISMA["Prisma ORM"]:::prisma
        CACHE["Cache Layer"]:::cache
    end

    subgraph External
        GH_OAUTH["GitHub OAuth"]
        DISC_API["Discord API"]
        VIDEO_STORE["Video Storage"]
        GA["Google Analytics"]
        NOT_API["Notion API"]
    end

    %% Relationships
    FE --> COMP
    COMP --> VP
    COMP --> SEARCH
    COMP --> AUTH_UI
    COMP --> BOOK
    COMP --> COMM
    COMP --> ANAL

    API --> AUTH
    API --> MOBILE
    API --> DISCORD
    API --> GITHUB
    API --> NOTION
    API --> COURSE
    API --> CERT
    API --> CAL

    AUTH --> DB
    COURSE --> DB
    DB --> PRISMA
    API --> CACHE

    AUTH --> GH_OAUTH
    DISCORD --> DISC_API
    NOTION --> NOT_API
    ANAL --> GA

    %% Styles
    classDef frontend fill:#3498db
    classDef api fill:#2ecc71
    classDef database fill:#f1c40f
    classDef external fill:#9b59b6
    classDef auth fill:#e74c3c
    classDef cache fill:#95a5a6

    %% Click Events
    click COMP "https://github.com/code100x/cms/tree/main/src/components"
    click ADMIN "https://github.com/code100x/cms/tree/main/src/app/admin"
    click VP "https://github.com/code100x/cms/blob/main/src/components/VideoPlayer2.tsx"
    click SEARCH "https://github.com/code100x/cms/tree/main/src/components/search"
    click AUTH "https://github.com/code100x/cms/tree/main/src/app/api/auth"
    click MOBILE "https://github.com/code100x/cms/tree/main/src/app/api/mobile"
    click PRISMA "https://github.com/code100x/cms/tree/main/prisma"
    click CACHE "https://github.com/code100x/cms/tree/main/src/lib/cache"
    click DISCORD "https://github.com/code100x/cms/tree/main/src/app/api/discord"
    click GITHUB "https://github.com/code100x/cms/tree/main/src/app/api/github"
    click NOTION "https://github.com/code100x/cms/tree/main/src/app/api/notion"
    click ANAL "https://github.com/code100x/cms/tree/main/src/components/analytics"
    click COURSE "https://github.com/code100x/cms/tree/main/src/app/courses"
    click BOOK "https://github.com/code100x/cms/tree/main/src/components/bookmark"
    click COMM "https://github.com/code100x/cms/tree/main/src/components/comment"
    click CERT "https://github.com/code100x/cms/tree/main/src/app/certificate"
    click CAL "https://github.com/code100x/cms/tree/main/src/app/calendar"

    %% Legend
    subgraph Legend
        L1[Frontend]:::frontend
        L2[API]:::api
        L3[(Database)]:::database
        L4[External]:::external
        L5[Auth]:::auth
        L6[Cache]:::cache
    end
```
