# abdessattar23/youdemy architecture

> Architecture diagram of the GitHub repository abdessattar23/youdemy, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-02-21). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/abdessattar23/youdemy
- Repository: https://github.com/abdessattar23/youdemy

## Overview

##### Project Type and Purpose
- This is a web-based online course platform (Youdemy) designed with a clear MVC architecture in PHP.
- The platform enables different user roles (visitor, student, teacher, administrator) to interact with courses, manage profiles, and perform administrative actions.
- It handles both front-office functions (course catalog, account creation, and role-specific dashboards) and back-office functions (user and content management, validations, and statistics).

##### Analyzing the File Structure – Identifying Main Components
a. Presentation Layer (Frontend):
- Located within the "public" directory (includes assets: CSS, JavaScript, fonts, images) and entry point "public/index.php".
- The "app/views" directory contains subdirectories for various user roles (admin, auth, home, student, teacher, visitor). These are the templates used to generate HTML pages.
b. Application Layer (Backend Business Logic):
- "app/controllers" contains controllers like AdminController, AuthController, CourseController, and others to handle requests and route them to the proper business logic.
- "app/models" includes data models (Admin, Course, Student, Teacher, etc.) which encapsulate database interactions and business rules.
- "app/helpers" includes utility classes such as ErrorHandler and Utils to support common operations.
- "app/config" holds configuration files (e.g., db.php) for database settings.
c. Core/System Foundation:
- The "core" directory houses the BaseController, Route, and Router classes. These likely implement routing logic and a basic controller structure that underpins the MVC framework.
d. Database:
- Scheme files (scheme.sql and scheme2.sql) indicate the relational database structure, including tables for courses, users, many-to-many relationships (for tags), and other information.
e. Autoload and Bootstrap:
- "autoload.php" sets up the app’s required classes, providing support for the automatic inclusion of required classes.

##### Final Advice
- Maintain clarity by grouping related components together (e.g., cluster all “app/views” by user roles and present the MVC layers distinctly).
- Notes for any non-obvious interactions (such as how helpers are invoked by controllers or how user sessions are managed).

## Diagram (Mermaid)

```mermaid
flowchart TD
    Browser["Browser"]:::client

    subgraph "Public Layer"
        PublicIndex["index.php Entry Point"]:::public
        PublicAssets["Assets (CSS,JS,Images)"]:::public
    end

    subgraph "Core/System Foundation"
        BaseController["BaseController"]:::core
        Route["Route"]:::core
        Router["Router"]:::core
        BaseController --> Route
        Route --> Router
    end

    subgraph "Controllers"
        AdminCtrl["AdminController"]:::controllers
        AuthCtrl["AuthController"]:::controllers
        CourseCtrl["CourseController"]:::controllers
        StudentCtrl["StudentController"]:::controllers
        TeacherCtrl["TeacherController"]:::controllers
        StatCtrl["StatisticsController"]:::controllers
    end

    subgraph "Models"
        ModelAdmin["Admin"]:::models
        ModelCourse["Course"]:::models
        ModelStudent["Student"]:::models
        ModelTeacher["Teacher"]:::models
        ModelUser["User"]:::models
        ModelDocument["DocumentCourse"]:::models
        ModelVideo["VideoCourse"]:::models
    end

    subgraph "Views"
        Views["Views: admin,auth,home,student,teacher,visitor"]:::views
    end

    subgraph "Helpers & Utilities"
        ErrorHandler["ErrorHandler"]:::helpers
        Utils["Utils"]:::helpers
    end

    subgraph "Database"
        DBConfig["DB Config"]:::database
        Scheme["scheme.sql"]:::database
        Scheme2["scheme2.sql"]:::database
    end

    Autoload["Autoload"]:::autoload

    Browser --> PublicIndex
    PublicIndex --> Router
    Autoload --> BaseController
    Router --> AuthCtrl
    AdminCtrl --> ModelAdmin
    AuthCtrl --> ModelUser
    CourseCtrl --> ModelCourse
    StudentCtrl --> ModelStudent
    TeacherCtrl --> ModelTeacher
    StatCtrl --> ModelUser
    AuthCtrl --> Views
    TeacherCtrl --> Views
    CourseCtrl --> ErrorHandler
    ModelUser --> DBConfig
    ModelCourse --> DBConfig

    click PublicIndex "https://github.com/abdessattar23/youdemy/blob/main/public/index.php"
    click PublicAssets "https://github.com/abdessattar23/youdemy/tree/main/public/assets"
    click Views "https://github.com/abdessattar23/youdemy/tree/main/app/views"
    click AdminCtrl "https://github.com/abdessattar23/youdemy/blob/main/app/controllers/AdminController.php"
    click AuthCtrl "https://github.com/abdessattar23/youdemy/blob/main/app/controllers/AuthController.php"
    click CourseCtrl "https://github.com/abdessattar23/youdemy/blob/main/app/controllers/CourseController.php"
    click StudentCtrl "https://github.com/abdessattar23/youdemy/blob/main/app/controllers/StudentController.php"
    click TeacherCtrl "https://github.com/abdessattar23/youdemy/blob/main/app/controllers/TeacherController.php"
    click StatCtrl "https://github.com/abdessattar23/youdemy/blob/main/app/controllers/StatisticsController.php"
    click ModelAdmin "https://github.com/abdessattar23/youdemy/blob/main/app/models/Admin.php"
    click ModelCourse "https://github.com/abdessattar23/youdemy/blob/main/app/models/Course.php"
    click ModelStudent "https://github.com/abdessattar23/youdemy/blob/main/app/models/Student.php"
    click ModelTeacher "https://github.com/abdessattar23/youdemy/blob/main/app/models/Teacher.php"
    click ModelUser "https://github.com/abdessattar23/youdemy/blob/main/app/models/User.php"
    click ModelDocument "https://github.com/abdessattar23/youdemy/blob/main/app/models/DocumentCourse.php"
    click ModelVideo "https://github.com/abdessattar23/youdemy/blob/main/app/models/VideoCourse.php"
    click DBConfig "https://github.com/abdessattar23/youdemy/blob/main/app/config/db.php"
    click Scheme "https://github.com/abdessattar23/youdemy/blob/main/scheme.sql"
    click Scheme2 "https://github.com/abdessattar23/youdemy/blob/main/scheme2.sql"
    click ErrorHandler "https://github.com/abdessattar23/youdemy/blob/main/app/helpers/ErrorHandler.php"
    click Utils "https://github.com/abdessattar23/youdemy/blob/main/app/helpers/Utils.php"
    click BaseController "https://github.com/abdessattar23/youdemy/blob/main/core/BaseController.php"
    click Route "https://github.com/abdessattar23/youdemy/blob/main/core/Route.php"
    click Router "https://github.com/abdessattar23/youdemy/blob/main/core/Router.php"
    click Autoload "https://github.com/abdessattar23/youdemy/blob/main/autoload.php"

    classDef client fill:#FFCC00,stroke:#000,stroke-width:2px;
    classDef public fill:#87CEFA,stroke:#1E90FF,stroke-width:2px;
    classDef controllers fill:#4682B4,stroke:#000,stroke-width:2px;
    classDef models fill:#98FB98,stroke:#008000,stroke-width:2px;
    classDef views fill:#FFFFE0,stroke:#DAA520,stroke-width:2px;
    classDef database fill:#F08080,stroke:#B22222,stroke-width:2px;
    classDef core fill:#FFA500,stroke:#FF8C00,stroke-width:2px;
    classDef helpers fill:#D8BFD8,stroke:#9932CC,stroke-width:2px;
    classDef autoload fill:#E0E0E0,stroke:#666,stroke-width:2px;
```
