# lqtuan123/lms architecture

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

- Interactive diagram: https://gitdiagram.com/lqtuan123/lms
- Repository: https://github.com/lqtuan123/lms

## Overview

##### Project Type & Purpose
- This is a monolithic, full-stack Laravel web application with two main “faces”:
- A public-facing frontend (Blade templates + rich JS/CSS asset bundles)
- An administrative backend (“backend” controllers + assets)
- It exposes a JSON REST API (/routes/api.php) for mobile or third-party clients, and supports CLI automation via Artisan commands (app/Console/Commands).
- It is organized into domain-specific modules (app/Modules/Blog, Book, Group, Teaching_1, Teaching_2, Teaching_3, Exercise, Resource, Tuongtac, etc.) each implementing an internal MVC (Controllers, Models, Views, Routes, Migrations, Services).

##### File Structure & Architectural Patterns
- Top-level:
- app/Http (HTTP controllers & middleware)
- app/Models (Eloquent models)
- app/Modules (self-contained feature folders with their own MVC + routes + migrations + views)
- app/Services & app/Helpers (domain services, utility classes)
- resources/views (global views—frontend & backend)
- public/backend & public/frontend (compiled CSS/JS/images for each UI)
- Uses Laravel’s MVC pattern and Service Provider system (app/Providers/ModuleServiceProvider auto-registers modules).
- Configuration (config/*), database migrations (database/migrations & each module’s Migrations), and seeders.

a. Clients (Web Browser public + Web Browser admin + Mobile/API Consumer)
b. HTTP Layer (Nginx/Apache → index.php → Laravel kernel → Middleware → Route dispatcher)
c. Controllers
- Frontend Controllers (app/Http/Controllers/frontend + resources/views)
- Backend Controllers (app/Http/Controllers/Admin + resources/views/backend)
- API Controllers (app/Http/Controllers/Api)
d. Domain Modules (each module folder under app/Modules)
- Inside each: MVC triad + module-specific routes
e. Services & Helpers (e.g. PointService, RatingService, SocialService)
f. Data Layer
- Eloquent Models (app/Models & app/Modules/*/Models)
- Database (MySQL/Postgres)
- Cache (Redis/Memcached)
- Filesystem (local or S3 via config/filesystems)
g. Infrastructure
- OAuth2 Passport (config/passport.php + oauth_* tables)
- Mail (app/Mail + external SMTP)
- Queue / Jobs (config/queue.php)
- Scheduler (app/Console/Commands + cron)

##### Interactions & Data Flows
- Clients → HTTP Server → Laravel Pipeline → Appropriate Controller
- Controllers → Services/Domain Logic → Eloquent Models → Database
- Controllers → Views → Clients (HTML) or JSON (API)
- Controllers/Services → Mailer/Queue/External APIs → Responses
- Artisan Commands → Services → Models → DB (offline workflows)
- Modules communicate only through services or shared models, enforcing separation.

##### Architectural Patterns & Principles
- Modular Monolith: self-contained modules with internal MVC, auto-discovered via ModuleServiceProvider.
- Dependency Injection via Laravel’s Service Container.
- MVC at both global and per-module levels.
- RESTful API design for /api.
- Separation of concerns: Views, Controllers, Models, Services.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Clients
    BrowserPublic["Web Browser (Public)"]:::frontend
    BrowserAdmin["Web Browser (Admin)"]:::frontend
    MobileClient["Mobile/API Consumer"]:::frontend

    %% HTTP Layer
    Server["Nginx/Apache"]:::application
    Entry["public/index.php"]:::application
    Bootstrap["bootstrap/app.php"]:::application
    Kernel["Laravel Kernel"]:::application
    Middleware["Middleware & Route Dispatcher"]:::application

    %% Controllers Layer
    subgraph "Controllers" 
        FC["Frontend Controllers"]:::application
        BC["Backend Controllers"]:::application
        AC["API Controllers"]:::application
        GC["Global Controllers & Middleware"]:::application
    end

    %% Routes
    WebRoutes["Web Routes\n(routes/web.php)"]:::application
    ApiRoutes["JSON REST API Routes\n(routes/api.php)"]:::application

    %% Modules Layer
    subgraph "Domain Modules" 
        Blog["Blog Module"]:::application
        Book["Book Module"]:::application
        GroupMod["Group Module"]:::application
        Exercise["Exercise Module"]:::application
        ResourceMod["Resource Module"]:::application
        Teach1["Teaching_1 Module"]:::application
        Teach2["Teaching_2 Module"]:::application
        Teach3["Teaching_3 Module"]:::application
        Tuongtac["Tuongtac Module"]:::application
    end

    %% Services & Helpers
    subgraph "Services & Helpers"
        PointS["PointService"]:::application
        RatingS["RatingService"]:::application
        SocialS["SocialService"]:::application
        Helpers["Debug Helper"]:::application
    end

    %% Models Layer
    subgraph "Models"
        GlobalModels["Global Models"]:::application
        ModuleModels["Module Models"]:::application
    end

    %% Data Stores
    Database["MySQL/Postgres"]:::data
    Cache["Redis/Memcached"]:::data
    Filesystem["Filesystem (Local/S3)"]:::data

    %% Infrastructure
    subgraph Infrastructure
        OAuth["OAuth2 Passport"]:::infra
        Mail["Mail & SMTP"]:::infra
        Queue["Queue/Jobs"]:::infra
        Scheduler["Scheduler & Artisan CLI"]:::infra
    end

    %% Asset Bundles
    AssetsPub["public/frontend (Assets)"]:::frontend
    AssetsAdmin["public/backend (Assets)"]:::frontend

    %% Flows
    BrowserPublic -->|HTTP Request| Server
    BrowserAdmin -->|HTTP Request| Server
    MobileClient -->|API Request| Server
    Server --> Entry --> Bootstrap --> Kernel --> Middleware
    Middleware --> WebRoutes --> FC -->|"renders HTML"| BrowserPublic
    Middleware --> WebRoutes --> BC -->|"renders HTML"| BrowserAdmin
    Middleware --> ApiRoutes --> AC -->|"returns JSON"| MobileClient

    FC --> Services & Helpers
    BC --> Services & Helpers
    AC --> Services & Helpers
    FC --> ViewsFE["Blade Views\n(resources/views/frontend)"]:::frontend
    BC --> ViewsBE["Blade Views\n(resources/views/backend)"]:::frontend

    Services & Helpers -->|uses| PointS
    Services & Helpers -->|uses| RatingS
    Services & Helpers -->|uses| SocialS
    Services & Helpers -->|uses| Helpers

    subgraph "Module Services"
        ModuleServices["Module Service Providers"]:::application
    end
    ModuleServices --> Blog & Book & GroupMod & Exercise & ResourceMod & Teach1 & Teach2 & Teach3 & Tuongtac
    FC & BC & AC --> ModuleServices

    Blog & Book & GroupMod & Exercise & ResourceMod & Teach1 & Teach2 & Teach3 & Tuongtac --> ModuleModels
    ModuleModels --> Database
    GlobalModels --> Database

    Services & Helpers --> GlobalModels
    ModuleModels --> Cache
    ModuleModels --> Filesystem

    %% Infrastructure Flows
    Services & Helpers -->|queues| Queue
    AC -->|auth| OAuth
    FC & BC -->|mail| Mail
    Scheduler --> Services & Helpers --> GlobalModels

    %% Artisan Commands
    CLI["Artisan Commands"]:::infra
    CLI --> Services & Helpers
    CLI --> GlobalModels
    CLI --> Database

    %% Asset Bundles
    FC --> AssetsPub
    BC --> AssetsAdmin

    %% Click Events
    click FC "https://github.com/lqtuan123/lms/tree/main/app/Http/Controllers/frontend"
    click BC "https://github.com/lqtuan123/lms/tree/main/app/Http/Controllers/Backend"
    click BC "https://github.com/lqtuan123/lms/tree/main/app/Http/Controllers/Admin"
    click AC "https://github.com/lqtuan123/lms/tree/main/app/Http/Controllers/Api"
    click GC "https://github.com/lqtuan123/lms/tree/main/app/Http/Controllers"
    click GC "https://github.com/lqtuan123/lms/tree/main/app/Http/Middleware"
    click Blog "https://github.com/lqtuan123/lms/tree/main/app/Modules/Blog"
    click Book "https://github.com/lqtuan123/lms/tree/main/app/Modules/Book"
    click GroupMod "https://github.com/lqtuan123/lms/tree/main/app/Modules/Group"
    click Exercise "https://github.com/lqtuan123/lms/tree/main/app/Modules/Exercise"
    click ResourceMod "https://github.com/lqtuan123/lms/tree/main/app/Modules/Resource"
    click Teach1 "https://github.com/lqtuan123/lms/tree/main/app/Modules/Teaching_1"
    click Teach2 "https://github.com/lqtuan123/lms/tree/main/app/Modules/Teaching_2"
    click Teach3 "https://github.com/lqtuan123/lms/tree/main/app/Modules/Teaching_3"
    click Tuongtac "https://github.com/lqtuan123/lms/tree/main/app/Modules/Tuongtac"
    click ModuleServices "https://github.com/lqtuan123/lms/blob/main/app/Modules/Blog/Routes/web.php"
    click ModuleServices "https://github.com/lqtuan123/lms/tree/main/app/Modules/Book/Migrations"
    click ModuleServices "https://github.com/lqtuan123/lms/tree/main/app/Modules/Exercise/Models"
    click ModuleServices "https://github.com/lqtuan123/lms/tree/main/app/Modules/Group/Views"
    click GlobalModels "https://github.com/lqtuan123/lms/tree/main/app/Models"
    click CLI "https://github.com/lqtuan123/lms/tree/main/app/Console/Commands"
    click PointS "https://github.com/lqtuan123/lms/blob/main/app/Services/PointService.php"
    click RatingS "https://github.com/lqtuan123/lms/blob/main/app/Services/RatingService.php"
    click Helpers "https://github.com/lqtuan123/lms/blob/main/app/Helpers/Debug.php"
    click SocialS "https://github.com/lqtuan123/lms/blob/main/app/Modules/Tuongtac/Services/SocialService.php"
    click OAuth "https://github.com/lqtuan123/lms/blob/main/config/passport.php"
    click Mail "https://github.com/lqtuan123/lms/blob/main/config/mail.php"
    click Queue "https://github.com/lqtuan123/lms/blob/main/config/queue.php"
    click Filesystem "https://github.com/lqtuan123/lms/blob/main/config/filesystems.php"
    click CLI "https://github.com/lqtuan123/lms/tree/main/app/Console/Commands"
    click AssetsPub "https://github.com/lqtuan123/lms/tree/main/public/frontend"
    click AssetsAdmin "https://github.com/lqtuan123/lms/tree/main/public/backend"
    click Entry "https://github.com/lqtuan123/lms/blob/main/public/index.php"
    click Bootstrap "https://github.com/lqtuan123/lms/blob/main/bootstrap/app.php"

    %% Styles
    classDef frontend fill:#d4f5d4,stroke:#2b7a2b,color:#000
    classDef application fill:#d4e4f5,stroke:#1f4e79,color:#000
    classDef data fill:#f5e4d4,stroke:#79421f,color:#000
    classDef infra fill:#e0e0e0,stroke:#666,color:#000
```
