# inkithai/online-learning-platform architecture

> Architecture diagram of the GitHub repository inkithai/online-learning-platform, 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/inkithai/online-learning-platform
- Repository: https://github.com/inkithai/online-learning-platform

## Overview

##### Main Components
- Frontend: Built in Angular using Angular Material. This layer is responsible for the user interface, including components such as login, dashboard, course management, and various dialogs (e.g., change-password, product confirmation). It resides under the “frontend/src/app” directory and includes dedicated modules and routing for different “features” (like home, dashboard, material-component, login, and signup).
- Backend: Developed with Node.js and Express.js. It handles server-side logic, authentication (with JWT tokens), API routing (with files in “backend/routes”) and services (business logic in “backend/services”). The backend also configures middleware for authentication and role checking.
- Database: MySQL-based system with the SQL schema file provided in the “database/academy_db.sql”. This layer is in charge of persisting course, user, and enrollment information.
- External Services & Middleware: Although not explicitly depicted as separate external services, the use of JWT tokens for authentication and the modular service files (like authentication.js and checkRole.js) implies a middleware architecture for request handling.

##### Relationships and Interactions
- Within the Backend, routes (such as bill.js, course.js, dashboard.js, user.js) map HTTP requests to service logic, ensuring that business rules (like authentication and role-based access) are enforced.
- The authentication mechanism using JWT tokens should be highlighted to show how secure communication is maintained between the client and server.

##### Architectural Patterns and Design Principles
- Modular Architecture: Both UI (Angular modules and separate material-component, dashboard, etc.) and backend layers are segmented for maintainability.
- MVC-like Pattern on the Backend: The routing files can be thought of as “controllers”, while service files encapsulate the “model” and business logic.
- Separation of Concerns: Clearly delineated sections (frontend, backend, and database) underline the layered architecture.
- UI Responsiveness: Use of Angular Material indicates a design focused on a responsive and dynamic user interface.
- Stateless Authentication: Emphasize the use of JWT tokens for secure, stateless user sessions.

##### Relevant Technologies
- Frontend: Angular, Angular Material.
- Backend: Node.js, Express.js.
- Database: MySQL.
- Additional Tools: npm for package management, and Sequelize (if using an ORM as indicated in the design decisions) even though it isn’t explicitly in the file tree.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Frontend Subgraph
    subgraph "Frontend"
        FE_UI["Angular Frontend"]:::frontend
        FE_Login["Login Component"]:::frontend
        FE_Dashboard["Dashboard Module"]:::frontend
        FE_Signup["Signup Module"]:::frontend
        FE_Material["Material Components"]:::frontend
    end

    %% Backend Subgraph
    subgraph "Backend"
        BE_Server["Server Initialization"]:::backend
        BE_API["API Routes"]:::backend
        BE_Middleware["Middleware Services"]:::backend
        BE_DBConn["Database Connection Module"]:::backend
    end

    %% Database Subgraph
    subgraph "Database"
        DB["MySQL Database"]:::database
    end

    %% Connections between layers
    FE_UI -->|"REST_API_calls"| BE_API
    BE_Server --> BE_API
    BE_API -->|"JWT_authentication"| BE_Middleware
    BE_Middleware -->|"Business_logic"| BE_DBConn
    BE_DBConn -->|"Data_queries"| DB

    %% Click Events for Frontend Components
    click FE_UI "https://github.com/inkithai/online-learning-platform/tree/main/frontend/src/app"
    click FE_Login "https://github.com/inkithai/online-learning-platform/blob/main/frontend/src/app/login/login.component.ts"
    click FE_Dashboard "https://github.com/inkithai/online-learning-platform/blob/main/frontend/src/app/dashboard/dashboard.module.ts"
    click FE_Signup "https://github.com/inkithai/online-learning-platform/blob/main/frontend/src/app/signup/signup.component.ts"
    click FE_Material "https://github.com/inkithai/online-learning-platform/tree/main/frontend/src/app/material-component/dialog"

    %% Click Events for Backend Components
    click BE_Server "https://github.com/inkithai/online-learning-platform/blob/main/backend/index.js"
    click BE_API "https://github.com/inkithai/online-learning-platform/tree/main/backend/routes"
    click BE_Middleware "https://github.com/inkithai/online-learning-platform/tree/main/backend/services"
    click BE_DBConn "https://github.com/inkithai/online-learning-platform/blob/main/backend/connection.js"

    %% Click Event for Database
    click DB "https://github.com/inkithai/online-learning-platform/blob/main/database/academy_db.sql"

    %% Styles
    classDef frontend fill:#AED6F1,stroke:#1F618D,stroke-width:2px;
    classDef backend fill:#A9DFBF,stroke:#196F3D,stroke-width:2px;
    classDef database fill:#F9E79F,stroke:#B7950B,stroke-width:2px;
```
