# meohoang3017/onlineclassroommanagement architecture

> Architecture diagram of the GitHub repository meohoang3017/onlineclassroommanagement, 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/meohoang3017/onlineclassroommanagement
- Repository: https://github.com/meohoang3017/onlineclassroommanagement

## Overview

##### Main Components
- Frontend: This folder includes all the client-side code built with React (as suggested by the presence of TypeScript, React components, hooks, and pages). It handles the user interface including pages for Authentication, Dashboard, Classroom management, Lesson management, and User management.
- Backend: This contains the server-side code based on Node.js and Express. The backend is structured in an MVC-like pattern with directories for controllers, routes, models, middlewares, and configuration. It supports APIs for authentication, classroom, lessons, file handling, approvals, and OTP operations.
- Database: Although no explicit database files are shown, the presence of backend/src/config/database.js and models implies that a database (likely MongoDB) is used.
- External Services: There are utility modules for handling Google Drive uploads (backend/src/utils/GoogleDrive.js), email notifications (Mailer), JWT handling, and file uploading.

##### Relationships/Interactions Between Components
- The Frontend communicates with the Backend via API endpoints. The API calls are abstracted through various API files under frontend/src/api which correspond to backend route modules.
- The Backend processes incoming requests through defined routes, passes them to appropriate controllers, and interacts with databases, middleware (like JWT and role checking), and external services.
- The Database stores and serves persistent data, as indicated by models like User, Lesson, Classroom, Approvement, etc.
- External utilities and services like Google Drive integration and mailing services are invoked within the backend flow to provide additional functionality.

##### Architectural Patterns and Design Principles
- MVC Pattern: The separation of concerns in the backend is clear with models (data structures), controllers (business logic), and routes (HTTP layer).
- Client-Server Architecture: The frontend is entirely separated from backend logic and communicates over RESTful APIs.
- Modularization: Both frontend and backend are divided into modules (e.g., different API modules and controllers) which makes the system extensible and maintainable.
- Use of Middleware: JWT and role-based middleware are used in the backend to secure endpoints.

##### Relevant Technologies/Frameworks
- Frontend: React with TypeScript, utilizing context providers for state management (e.g., AuthContext, NotyfContext), and routing via custom components (AppRoutes.tsx). Also using Vite for bundling.
- Backend: Node.js with Express, configured with various settings like CORs, passport for authentication, and socket connectivity. It involves utilities for hashing, JWT, mailing, and file uploads.
- Database: Likely MongoDB, as evident from model definitions (although the specific driver isn’t specified, the typical MERN stack would use MongoDB).
- External Integrations: Google Drive and mailing services.

##### Elements
- Use clear labels for each component (e.g., “Frontend: Login Page”, “Backend: AuthController”, “Database: MongoDB”).
- To denote middleware layers (e.g., JWT authentication) on the request path.

- For Frontend, subdivide into UI Components, API Services, and Contexts.
- For Backend, show the configuration layer, routing layer, controllers, models, middleware, and utilities as interconnected modules.

## Diagram (Mermaid)

```mermaid
flowchart TD
    subgraph "Frontend"
        FE_UI["UI Components (React)"]:::frontend
        FE_Pages["Pages (Auth, Classroom, Lesson, User)"]:::frontend
        FE_API["API Services"]:::frontend
        FE_Context["Context Providers"]:::frontend
        FE_Routing["Routing"]:::frontend
    end

    subgraph "Backend"
        BE_Config["Configuration"]:::backend
        BE_Routes["Routes"]:::backend
        BE_Controllers["Controllers"]:::backend
        BE_Models["Models"]:::backend
        BE_Middleware["Middleware"]:::backend
        BE_Utils["Utils/External Services"]:::backend
    end

    DB["(MongoDB Database)"]:::database

    %% Frontend connections
    FE_Context -->|"state_management"| FE_UI
    FE_Routing -->|"navigation"| FE_Pages
    FE_Pages -->|"API_calls"| FE_API

    %% Frontend to Backend API call
    FE_API -->|"REST_API"| BE_Routes

    %% Backend connections
    BE_Config -->|"configures"| BE_Routes
    BE_Routes -->|"routes_to"| BE_Controllers
    BE_Routes -->|"enforces"| BE_Middleware
    BE_Controllers -->|"data_ops"| BE_Models
    BE_Controllers -->|"external_calls"| BE_Utils
    BE_Controllers -->|"secured_by"| BE_Middleware
    BE_Models -->|"stores_data"| DB

    %% Click Events
    click FE_UI "https://github.com/meohoang3017/onlineclassroommanagement/tree/main/frontend/src/components"
    click FE_Pages "https://github.com/meohoang3017/onlineclassroommanagement/tree/main/frontend/src/pages"
    click FE_API "https://github.com/meohoang3017/onlineclassroommanagement/tree/main/frontend/src/api"
    click FE_Context "https://github.com/meohoang3017/onlineclassroommanagement/tree/main/frontend/src/contexts"
    click FE_Routing "https://github.com/meohoang3017/onlineclassroommanagement/blob/main/frontend/src/AppRoutes.tsx"
    click BE_Controllers "https://github.com/meohoang3017/onlineclassroommanagement/tree/main/backend/src/controllers"
    click BE_Routes "https://github.com/meohoang3017/onlineclassroommanagement/tree/main/backend/src/routes"
    click BE_Models "https://github.com/meohoang3017/onlineclassroommanagement/tree/main/backend/src/models"
    click BE_Config "https://github.com/meohoang3017/onlineclassroommanagement/tree/main/backend/src/config"
    click BE_Middleware "https://github.com/meohoang3017/onlineclassroommanagement/tree/main/backend/src/middlewares"
    click BE_Utils "https://github.com/meohoang3017/onlineclassroommanagement/tree/main/backend/src/utils"

    %% Styles
    classDef frontend fill:#cce5ff,stroke:#004085,stroke-width:2px;
    classDef backend fill:#d4edda,stroke:#155724,stroke-width:2px;
    classDef database fill:#fff3cd,stroke:#856404,stroke-width:2px;
```
