# duckhang1412002/coursecraft-colony-65 architecture

> Architecture diagram of the GitHub repository duckhang1412002/coursecraft-colony-65, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-04-03). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/duckhang1412002/coursecraft-colony-65
- Repository: https://github.com/duckhang1412002/coursecraft-colony-65

## Overview

##### Main Components
- Frontend UI Layer: Highlight the role of the React components. This includes the overall layout (Navbar, Footer in src/components/layout) and various domain-specific components (animation, auth, language, learning, teacher, and common components).
- Pages and Routing: Represent the various pages (e.g., AdminDashboard, CourseDetails, CourseLearn, CoursesList, NotFound, SignIn, and SignUp in src/pages) that form the navigation of the application.
- State Management & Business Logic: Include the context providers (AuthContext, CartContext, LanguageContext) and custom hooks (useAuth, useCart, useCourses, etc.) that manage and provide state across components.
- Utility & Helper Layer: Represent shared logic from src/lib/utils and any helper functions used within the app.

##### Relationships and Interactions
- How the user interacts with the Frontend UI, which is rendered by a combination of pages and components.
- A connection from the application’s data layer (custom hooks or context) to the Supabase integration, representing backend communication.
- You might also want to mention how the configuration (via Vite, ESLint, PostCSS, etc.) supports the development and build processes.

##### Architectural Patterns and Design Principles
- Component-Based Architecture: Emphasize that the front end is built using a modular, component-driven approach where individual components (e.g., CourseCard, Quiz, QuizEditor) encapsulate specific UI or functionality.
- Separation of Concerns: Note the clear separation between layout components, domain/task-specific components (learning, teacher, auth), and UI primitives (all located in the subdirectory src/components/ui).
- Integration Abstraction: The supabase folder abstracts the backend connectivity, highlighting a clean separation between frontend rendering and backend services.

##### Specific Elements
- Clear labels for each main component:
- “UI Layer” (listing components, pages, and sub-components like layout, auth, learning, etc.)
- “State Management” (showing AuthContext, CartContext, LanguageContext, and related hooks)
- “External Services” (Supabase integration)
- “Utilities & Helpers” (src/lib, custom hooks)
- “Tooling & Build” (Vite, configuration files)
- Annotations or notes:
- Call-outs for technologies (React, TypeScript, Vite, shadcn-ui, Tailwind CSS) where they are most relevant.
- Optionally, annotate the “Build & Config” section to communicate the development pipeline.

##### Final Assembly
- At the bottom, indicate the external integrations and annotate with the relevant configuration and build tools.

## Diagram (Mermaid)

```mermaid
graph TD
    Client["User/Client"]:::user
    PRES["Presentation Layer"]:::ui

    Client -->|"interacts"| PRES
    PRES -->|"updates_state"| SM1

    subgraph "Presentation Layer Details"
        subgraph "UI Components"
            UI1["Navbar (Layout)"]:::ui
            UI2["Footer (Layout)"]:::ui
            UI3["FadeIn (Animation)"]:::ui
            UI4["ProtectedRoute (Auth)"]:::ui
            UI5["CourseCard (Common_UI)"]:::ui
            UI6["LanguageSelector (Language)"]:::ui
            UI7["Quiz (Learning)"]:::ui
            UI8["QuizEditor (Teacher)"]:::ui
            UI9["UI Primitives"]:::ui
        end
        subgraph "Pages & Routing"
            P["Pages Collection"]:::ui
        end
    end

    subgraph "State Management"
        SM1["AuthContext"]:::state
        SM2["CartContext"]:::state
        SM3["LanguageContext"]:::state
        SM4["use-mobile"]:::state
        SM5["use-toast"]:::state
        SM6["useAuth"]:::state
        SM7["useCart"]:::state
        SM8["useCourses"]:::state
        SM9["useLessons"]:::state
    end

    subgraph "External Services"
        ES["Supabase Integration"]:::external
    end

    subgraph "Utilities & Helpers"
        Util["Utils"]:::util
    end

    subgraph "Build & Config"
        BC1["vite.config.ts"]:::build
        BC2["tsconfig.app.json"]:::build
        BC3["tsconfig.json"]:::build
        BC4["tsconfig.node.json"]:::build
        BC5["tailwind.config.ts"]:::build
        BC6["postcss.config.js"]:::build
        BC7["eslint.config.js"]:::build
    end

    PRES -->|"calls_utilities"| Util
    SM1 -->|"fetches_data"| ES

    %% Click Events for Frontend UI Layer
    click UI1 "https://github.com/duckhang1412002/coursecraft-colony-65/blob/main/src/components/layout/Navbar.tsx"
    click UI2 "https://github.com/duckhang1412002/coursecraft-colony-65/blob/main/src/components/layout/Footer.tsx"
    click UI3 "https://github.com/duckhang1412002/coursecraft-colony-65/blob/main/src/components/animation/FadeIn.tsx"
    click UI4 "https://github.com/duckhang1412002/coursecraft-colony-65/blob/main/src/components/auth/ProtectedRoute.tsx"
    click UI5 "https://github.com/duckhang1412002/coursecraft-colony-65/blob/main/src/components/common/CourseCard.tsx"
    click UI6 "https://github.com/duckhang1412002/coursecraft-colony-65/blob/main/src/components/language/LanguageSelector.tsx"
    click UI7 "https://github.com/duckhang1412002/coursecraft-colony-65/blob/main/src/components/learning/Quiz.tsx"
    click UI8 "https://github.com/duckhang1412002/coursecraft-colony-65/blob/main/src/components/teacher/QuizEditor.tsx"
    click UI9 "https://github.com/duckhang1412002/coursecraft-colony-65/tree/main/src/components/ui"

    %% Click Event for Pages and Routing
    click P "https://github.com/duckhang1412002/coursecraft-colony-65/tree/main/src/pages"

    %% Click Events for State Management & Business Logic
    click SM1 "https://github.com/duckhang1412002/coursecraft-colony-65/blob/main/src/context/AuthContext.tsx"
    click SM2 "https://github.com/duckhang1412002/coursecraft-colony-65/blob/main/src/context/CartContext.tsx"
    click SM3 "https://github.com/duckhang1412002/coursecraft-colony-65/blob/main/src/context/LanguageContext.tsx"
    click SM4 "https://github.com/duckhang1412002/coursecraft-colony-65/blob/main/src/hooks/use-mobile.tsx"
    click SM5 "https://github.com/duckhang1412002/coursecraft-colony-65/blob/main/src/hooks/use-toast.ts"
    click SM6 "https://github.com/duckhang1412002/coursecraft-colony-65/blob/main/src/hooks/useAuth.tsx"
    click SM7 "https://github.com/duckhang1412002/coursecraft-colony-65/blob/main/src/hooks/useCart.tsx"
    click SM8 "https://github.com/duckhang1412002/coursecraft-colony-65/blob/main/src/hooks/useCourses.tsx"
    click SM9 "https://github.com/duckhang1412002/coursecraft-colony-65/blob/main/src/hooks/useLessons.tsx"

    %% Click Event for Utility & Helper Layer
    click Util "https://github.com/duckhang1412002/coursecraft-colony-65/blob/main/src/lib/utils.ts"

    %% Click Event for External Integrations
    click ES "https://github.com/duckhang1412002/coursecraft-colony-65/tree/main/src/integrations/supabase"

    %% Click Events for Build & Configurations
    click BC1 "https://github.com/duckhang1412002/coursecraft-colony-65/blob/main/vite.config.ts"
    click BC2 "https://github.com/duckhang1412002/coursecraft-colony-65/blob/main/tsconfig.app.json"
    click BC3 "https://github.com/duckhang1412002/coursecraft-colony-65/blob/main/tsconfig.json"
    click BC4 "https://github.com/duckhang1412002/coursecraft-colony-65/blob/main/tsconfig.node.json"
    click BC5 "https://github.com/duckhang1412002/coursecraft-colony-65/blob/main/tailwind.config.ts"
    click BC6 "https://github.com/duckhang1412002/coursecraft-colony-65/blob/main/postcss.config.js"
    click BC7 "https://github.com/duckhang1412002/coursecraft-colony-65/blob/main/eslint.config.js"

    %% Style Definitions
    classDef user fill:#ffccbc,stroke:#d84315,color:#000;
    classDef ui fill:#bbdefb,stroke:#0d47a1,color:#000;
    classDef state fill:#c8e6c9,stroke:#2e7d32,color:#000;
    classDef external fill:#ffe0b2,stroke:#fb8c00,color:#000;
    classDef util fill:#f8bbd0,stroke:#ad1457,color:#000;
    classDef build fill:#d1c4e9,stroke:#673ab7,color:#000;
```
