# kl3init/course-hub-frontend architecture

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

- Interactive diagram: https://gitdiagram.com/kl3init/course-hub-frontend
- Repository: https://github.com/kl3init/course-hub-frontend

## Overview

##### Project type and purpose
- This is a full-stack, client-centric “Comprehensive Learning Platform” built with Next.js (App Router), React, TypeScript, and Tailwind CSS.
- The README describes an educational portal with course catalog, learning modules, admin/manager dashboards, payments, analytics, and user/auth management.
- It’s deployed to Vercel and synchronized via v0.dev; the front end consumes REST/WS microservices (“services/*.ts”) for all business domains (courses, payments, users, reports, etc.).

##### File structure
- Top-level config & environment: .env.*, next.config.mjs, postcss.config.mjs, tailwind.config.ts, package.json, tsconfig.json.
- “app/” contains Next.js page routes (App Router) for public (courses, login, register), learner (“learn/…”), admin (“app/admin/…”), manager (“app/manager/…”), payment flows, profile, etc.
- “components/” is organized by feature domain (auth, admin, manager, learning, payment, profile, UI primitives).
- “services/” holds typed HTTP client wrappers for each backend API domain plus a WebSocket service.
- “context/” & “hooks/” provide global state, auth guard, custom React hooks (debounce, video player, course data, toast, mobile).
- “styles/” & “public/assets” for static styling and assets.
- Utilities (“lib/”, “utils/”) and domain types (“types/”) for shared functions and TypeScript models.

##### README for additional insights
- No explicit backend code lives here; the front end relies on external v0.dev–deployed APIs.
- Deployment is on Vercel; continuous sync with v0.dev chat-based builder.

##### Capturing essential architectural elements
- Cover all major domains: auth, course management, learning, payments, admin analytics, reporting.
- How dynamic routing in /app triggers code splitting and SSR/SSG.
- Don’t omit the WebSocket channel for real-time notifications/analytics.

## Diagram (Mermaid)

```mermaid
flowchart TD
    Browser["Browser / User Agent"]:::external

    subgraph "Presentation Layer"
        NextJS["Next.js App Router & Pages"]:::ui
        Components["React Components"]:::ui
    end

    subgraph "State & Logic Layer"
        ContextHooks["Context & Hooks"]:::state
    end

    subgraph "Integration Layer"
        ServiceLayer["Service Layer\n(HTTP & WS Clients)"]:::integration
    end

    subgraph "External Systems"
        ExternalAPIs["External Backend APIs"]:::external
        GoogleOAuth["Google OAuth"]:::external
        PaymentGateway["Payment Gateway"]:::external
        AnalyticsService["Analytics Backend"]:::external
        Vercel["Vercel Hosting & v0.dev Sync"]:::external
    end

    Browser --> NextJS
    NextJS --> Components
    Components --> ContextHooks
    ContextHooks --> ServiceLayer
    ServiceLayer --> ExternalAPIs
    ServiceLayer --> GoogleOAuth
    ServiceLayer --> PaymentGateway
    ServiceLayer --> AnalyticsService
    NextJS --> GoogleOAuth

    click NextJS "https://github.com/kl3init/course-hub-frontend/tree/main/app/"
    click NextJS "https://github.com/kl3init/course-hub-frontend/blob/main/app/layout.tsx"
    click NextJS "https://github.com/kl3init/course-hub-frontend/blob/main/app/page.tsx"
    click NextJS "https://github.com/kl3init/course-hub-frontend/blob/main/app/admin/page.tsx"
    click NextJS "https://github.com/kl3init/course-hub-frontend/blob/main/app/learn/[courseId]/[lessonId]/page.tsx"
    click NextJS "https://github.com/kl3init/course-hub-frontend/blob/main/app/manager/analytics/page.tsx"
    click NextJS "https://github.com/kl3init/course-hub-frontend/blob/main/app/payment/qr/page.tsx"
    click NextJS "https://github.com/kl3init/course-hub-frontend/blob/main/app/auth/google/callback/page.tsx"
    click Components "https://github.com/kl3init/course-hub-frontend/tree/main/components/"
    click Components "https://github.com/kl3init/course-hub-frontend/blob/main/components/auth/login-form.tsx"
    click Components "https://github.com/kl3init/course-hub-frontend/blob/main/components/auth/permission-guard.tsx"
    click Components "https://github.com/kl3init/course-hub-frontend/blob/main/components/admin/admin-dashboard.tsx"
    click Components "https://github.com/kl3init/course-hub-frontend/blob/main/components/admin/report-management.tsx"
    click Components "https://github.com/kl3init/course-hub-frontend/blob/main/components/learning/VideoPlayer.tsx"
    click Components "https://github.com/kl3init/course-hub-frontend/blob/main/components/learning/lesson-viewer.tsx"
    click Components "https://github.com/kl3init/course-hub-frontend/blob/main/components/manager/course-editor.tsx"
    click Components "https://github.com/kl3init/course-hub-frontend/blob/main/components/manager/student-management.tsx"
    click Components "https://github.com/kl3init/course-hub-frontend/blob/main/components/payment/payment-modal.tsx"
    click Components "https://github.com/kl3init/course-hub-frontend/blob/main/components/payment/qr-payment.tsx"
    click Components "https://github.com/kl3init/course-hub-frontend/blob/main/components/ui/button.tsx"
    click Components "https://github.com/kl3init/course-hub-frontend/blob/main/components/ui/dialog.tsx"
    click Components "https://github.com/kl3init/course-hub-frontend/blob/main/components/ui/date-range-picker.tsx"
    click Components "https://github.com/kl3init/course-hub-frontend/blob/main/components/ui/toast.tsx"
    click ContextHooks "https://github.com/kl3init/course-hub-frontend/blob/main/context/auth-context.tsx"
    click ContextHooks "https://github.com/kl3init/course-hub-frontend/tree/main/hooks/"
    click ContextHooks "https://github.com/kl3init/course-hub-frontend/blob/main/hooks/useCourseData.ts"
    click ContextHooks "https://github.com/kl3init/course-hub-frontend/blob/main/hooks/useLessonProgress.ts"
    click ContextHooks "https://github.com/kl3init/course-hub-frontend/blob/main/hooks/useVideoPlayer.ts"
    click ContextHooks "https://github.com/kl3init/course-hub-frontend/blob/main/hooks/use-debounce.ts"
    click ContextHooks "https://github.com/kl3init/course-hub-frontend/blob/main/hooks/use-toast.ts"
    click ServiceLayer "https://github.com/kl3init/course-hub-frontend/tree/main/services/"
    click ServiceLayer "https://github.com/kl3init/course-hub-frontend/blob/main/services/http-client.ts"
    click ServiceLayer "https://github.com/kl3init/course-hub-frontend/blob/main/services/course-api.ts"
    click ServiceLayer "https://github.com/kl3init/course-hub-frontend/blob/main/services/user-api.ts"
    click ServiceLayer "https://github.com/kl3init/course-hub-frontend/blob/main/services/payment-api.ts"
    click ServiceLayer "https://github.com/kl3init/course-hub-frontend/blob/main/services/report-api.ts"
    click ServiceLayer "https://github.com/kl3init/course-hub-frontend/blob/main/services/websocket-service.ts"
    click Vercel "https://github.com/kl3init/course-hub-frontend/blob/main/next.config.mjs"

    classDef ui fill:#dafbe1,stroke:#2e8b57,color:#000
    classDef state fill:#cce5ff,stroke:#003f87,color:#000
    classDef integration fill:#ffe5b4,stroke:#cd8200,color:#000
    classDef external fill:#f0f0f0,stroke:#888,color:#000
```
