# shigaev/edu.platform architecture

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

- Interactive diagram: https://gitdiagram.com/shigaev/edu.platform
- Repository: https://github.com/shigaev/edu.platform

## Overview

##### Main Components
- Client Layer:
- Web Browser / Clients that access the public site and the admin interface.
- Frontend Application (public site):
- This includes the entry point (frontend/public/index.php), controllers, models, and views.
- Also shows assets like CSS, JS, images, and fonts.
- Accompanied by the “src/frontend” folder that contains JavaScript and SCSS components built by Webpack.
- Backend Application (admin interface):
- Similarly composed of its entry point (backend/public/index.php), controllers, models, and views.
- Has its own configuration, routing, and asset structure.
- The “src/backend” directory provides frontend assets and styling for the admin area.
- Core/Framework Components:
- The “core” directory includes essential classes like the Router, Controller, ActiveRecord (Model implementation), Db for database interactions, Settings, and View.
- Shared/Common Code:
- The “common” directory, which contains shared models and possibly other resources utilized by both the frontend and backend.
- Database Layer:
- MySQL database that stores persistent data.
- The “db/migrations” directory and the “phinx.php” configuration file indicate that database versioning and migration scripts are managed via Phinx.
- Additional Services and Utilities:
- The “services” directory (e.g., UserAuthService.php) handles business logic such as user authentication.
- Exception handling is centralized in the “exceptions” folder.
- The “config” directories (both at the root and within frontend/backend) indicate separate routing and settings configuration.
- Build and Asset Pipeline:
- The “webpack.config.js”, “package.json”, and “package-lock.json” files indicate an asset bundling/build step that compiles the SCSS and JavaScript used in both frontend and backend modules.

##### Relationships and Interactions
- The client (web browser) sends HTTP requests that are routed to either the frontend or backend via Apache’s VirtualHost configurations.
- The Apache configuration excerpt from the README details two separate VirtualHosts:
- “edu.platform” (points to the frontend/public folder)
- “edu.platform.admin” (points to the backend/public folder)
- Each application (frontend and backend) processes the HTTP request via a common router (in the “core/Router.php”), which directs the request to the appropriate controller.
- The controllers invoke relevant models (sometimes shared via “common/models”) and render views (HTML templates in folders like “frontend/views” or “backend/views”).
- Database interactions occur via the “core/Db.php” and are governed by migrations to create/update tables.
- The asset pipeline with Webpack takes raw SCSS/JS from the “src” directories to produce optimized assets that reside in the “public” folders.
- The services (e.g., UserAuthService) and exception handlers provide additional application logic and error handling.

##### Architectural Patterns and Technologies
- MVC Pattern: Both frontend and backend applications are organized by the Model-View-Controller paradigm.
- Separation of Concerns: Clear distinctions exist between presentation (views), business logic (controllers and services), and data access (models/Core).
- Shared Core Library: Reusable core modules encapsulate common functionalities like routing, database access, and view loading.
- Asset Pipeline: Use of modern tooling (Webpack, SCSS) for frontend build and optimization.
- Database Migration: Phinx is used for managing schema changes, indicating a version-controlled database evolution.

##### Final Reminders to the Principal Software Engineer
- Component is clearly labeled.
- Be detailed—outline every major folder and module that plays a significant role in the overall architecture.

## Diagram (Mermaid)

```mermaid
flowchart TD
    Client["Web Browser/Client"]:::client

    subgraph "Apache VirtualHost"
        VH_FE["edu.platform"]:::apache
        VH_BE["edu.platform.admin"]:::apache
    end

    Client -->|"HTTP_Request"| VH_FE
    Client -->|"HTTP_Request"| VH_BE

    subgraph "Frontend Application"
        FE_Entry["index.php (Frontend)"]:::frontend
        FE_Controllers["Controllers"]:::frontend
        FE_Models["Models"]:::frontend
        FE_Views["Views"]:::frontend
        FE_CSS["CSS Assets"]:::frontend
        FE_JS["JS Assets"]:::frontend
        FE_Fonts["Fonts Assets"]:::frontend
        FE_IMG["Image Assets"]:::frontend
        FE_AssetBuild["Asset Build (src/frontend)"]:::frontend
    end

    subgraph "Backend Application"
        BE_Entry["index.php (Backend)"]:::backend
        BE_Controllers["Controllers"]:::backend
        BE_Models["Models"]:::backend
        BE_Views["Views"]:::backend
        BE_CSS["CSS Assets"]:::backend
        BE_JS["JS Assets"]:::backend
        BE_Fonts["Fonts Assets"]:::backend
        BE_IMG["Image Assets"]:::backend
        BE_AssetBuild["Asset Build (src/backend)"]:::backend
    end

    VH_FE -->|"serves"| FE_Entry
    VH_BE -->|"serves"| BE_Entry

    FE_Entry -->|"initializes"| FE_Controllers
    BE_Entry -->|"initializes"| BE_Controllers

    FE_Controllers -->|"invokes"| FE_Models
    FE_Controllers -->|"renders"| FE_Views
    BE_Controllers -->|"invokes"| BE_Models
    BE_Controllers -->|"renders"| BE_Views

    FE_AssetBuild -->|"builds"| FE_CSS
    FE_AssetBuild -->|"builds"| FE_JS
    FE_AssetBuild -->|"builds"| FE_Fonts
    FE_AssetBuild -->|"builds"| FE_IMG
    BE_AssetBuild -->|"builds"| BE_CSS
    BE_AssetBuild -->|"builds"| BE_JS
    BE_AssetBuild -->|"builds"| BE_Fonts
    BE_AssetBuild -->|"builds"| BE_IMG

    subgraph "Core / Framework"
        Core["Core Library (Router, Controller, Db, View, ActiveRecord)"]:::core
    end

    FE_Controllers -->|"uses"| Core
    BE_Controllers -->|"uses"| Core

    subgraph "Exception Handling"
        ExceptionHandler["Exception Handling"]:::config
    end

    Core -->|"handles"| ExceptionHandler

    subgraph "Common / Shared"
        Common["Common Code (Shared Models)"]:::common
    end

    FE_Models -->|"shared_with"| Common
    BE_Models -->|"shared_with"| Common

    subgraph "Database Layer"
        DB["MySQL Database"]:::database
        Migrations["Migrations (Phinx)"]:::database
        DB_Config["Phinx Configuration"]:::config
    end

    Core -->|"accesses"| DB
    DB -->|"managed_by"| Migrations
    Migrations -->|"configured_by"| DB_Config

    subgraph "Configuration"
        GlobalConfig["Global Config"]:::config
        FE_Config["Frontend Config"]:::config
        BE_Config["Backend Config"]:::config
    end

    Core -->|"configures_with"| GlobalConfig
    FE_Controllers -->|"routed_by"| FE_Config
    BE_Controllers -->|"routed_by"| BE_Config

    Services["UserAuth Service"]:::service
    Core -->|"utilizes"| Services

    subgraph "Build and Asset Pipeline"
        BuildTools["Build Tools (webpack.config.js, package.json, package-lock.json)"]:::build
    end

    BuildTools -->|"processes"| FE_AssetBuild
    BuildTools -->|"processes"| BE_AssetBuild

    %% Click Events for Frontend Application
    click FE_Entry "https://github.com/shigaev/edu.platform/blob/main/frontend/public/index.php"
    click FE_Controllers "https://github.com/shigaev/edu.platform/tree/main/frontend/controllers"
    click FE_Models "https://github.com/shigaev/edu.platform/tree/main/frontend/models"
    click FE_Views "https://github.com/shigaev/edu.platform/tree/main/frontend/views"
    click FE_CSS "https://github.com/shigaev/edu.platform/tree/main/frontend/public/css"
    click FE_JS "https://github.com/shigaev/edu.platform/tree/main/frontend/public/js"
    click FE_Fonts "https://github.com/shigaev/edu.platform/tree/main/frontend/public/fonts"
    click FE_IMG "https://github.com/shigaev/edu.platform/tree/main/frontend/public/img"
    click FE_AssetBuild "https://github.com/shigaev/edu.platform/tree/main/src/frontend"

    %% Click Events for Backend Application
    click BE_Entry "https://github.com/shigaev/edu.platform/blob/main/backend/public/index.php"
    click BE_Controllers "https://github.com/shigaev/edu.platform/tree/main/backend/controllers"
    click BE_Models "https://github.com/shigaev/edu.platform/tree/main/backend/models"
    click BE_Views "https://github.com/shigaev/edu.platform/tree/main/backend/views"
    click BE_CSS "https://github.com/shigaev/edu.platform/tree/main/backend/public/css"
    click BE_JS "https://github.com/shigaev/edu.platform/tree/main/backend/public/js"
    click BE_Fonts "https://github.com/shigaev/edu.platform/tree/main/backend/public/fonts"
    click BE_IMG "https://github.com/shigaev/edu.platform/tree/main/backend/public/img"
    click BE_AssetBuild "https://github.com/shigaev/edu.platform/tree/main/src/backend"

    %% Click Events for Core, Common, Database, and Config
    click Core "https://github.com/shigaev/edu.platform/tree/main/core"
    click Common "https://github.com/shigaev/edu.platform/tree/main/common"
    click Migrations "https://github.com/shigaev/edu.platform/tree/main/db/migrations"
    click DB_Config "https://github.com/shigaev/edu.platform/blob/main/phinx.php"
    click GlobalConfig "https://github.com/shigaev/edu.platform/tree/main/config"
    click FE_Config "https://github.com/shigaev/edu.platform/tree/main/frontend/config"
    click BE_Config "https://github.com/shigaev/edu.platform/tree/main/backend/config"

    %% Click Events for Exception Handling and Services
    click ExceptionHandler "https://github.com/shigaev/edu.platform/tree/main/exceptions"
    click Services "https://github.com/shigaev/edu.platform/blob/main/services/UserAuthService.php"

    %% Click Event for Build Tools
    click BuildTools "https://github.com/shigaev/edu.platform/blob/main/webpack.config.js"

    %% Styles
    classDef client fill:#F9E79F,stroke:#333,stroke-width:2px;
    classDef frontend fill:#AED6F1,stroke:#333,stroke-width:2px;
    classDef backend fill:#A9DFBF,stroke:#333,stroke-width:2px;
    classDef core fill:#F5B7B1,stroke:#333,stroke-width:2px;
    classDef common fill:#D2B4DE,stroke:#333,stroke-width:2px;
    classDef database fill:#FCF3CF,stroke:#333,stroke-width:2px;
    classDef config fill:#D6DBDF,stroke:#333,stroke-width:2px;
    classDef service fill:#FAD7A0,stroke:#333,stroke-width:2px;
    classDef apache fill:#CCD1D1,stroke:#333,stroke-width:2px;
    classDef build fill:#FDEBD0,stroke:#333,stroke-width:2px;
```
