# gregobhm/web_asm architecture

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

- Interactive diagram: https://gitdiagram.com/gregobhm/web_asm
- Repository: https://github.com/gregobhm/web_asm

## Overview

##### Project Type and Purpose
- This is a full-stack, MVC-style PHP web application (likely an Attendance Management System given models like Asistencia, Aula, Clase, Estudiante, Nota, etc.).
- It uses Composer, a MySQL (or similar) database, OAuth authentication (Google, Microsoft), email notifications, and plain PHP views & assets.

##### File Structure
- public/ → Web-accessible entry point (index.php), CSS/JS/IMG
- controllers/ → Request handling & application logic (AuthController, HomeController)
- models/ → Domain entities & database access (Asistencia, Curso, Usuario, etc.)
- views/ → Presentation templates (components/, dashboards/, home, login, register, etc.)
- auth/ → OAuth integration scripts (google.php, microsoft.php, notify.php)
- config/ & config.json → Constants, database connection settings
- utils/ → Helper classes (CorreoConfirmacion, NotificadorCorreo abstraction)
- vendor/ → Third-party libraries (via Composer)

##### Key Architectural Patterns
- MVC (Model–View–Controller) layered design
- 3-Tier separation: Presentation (views + public), Business Logic (controllers + utils), Data (models + database)
- External integration: OAuth providers & SMTP/email notifier

a. Clients & Browsers
b. Web Server & PHP Runtime
– public/index.php (Front Controller / Router)
– Composer autoloader bringing in controllers, models, utils, vendor libs
c. Application Layer
– Controllers (AuthController, HomeController)
– Utility Services (CorreoConfirmacion, NotificadorCorreo)
d. Data Layer
– Models (Asistencia, Usuario, etc.)
– Database (MySQL with schema from sql/ams.sql)
e. External Services
– OAuth Providers (Google, Microsoft)
– SMTP Mail Server

##### Relationships & Data Flow
1. User → HTTP Request → public/index.php
2. index.php → Router → Appropriate Controller
3. Controller → calls Models for CRUD → MySQL Database
4. Controller → selects View → sends HTML/JS/CSS back to User
5. Controllers/Utils → send email via SMTP (CorreoConfirmacion)
6. Auth endpoints → redirect to OAuth Providers → callback to auth/google.php or auth/microsoft.php

- “Clients” (Browser, Mobile)
- “Web Tier” (Nginx/Apache + PHP-FPM, public/index.php)
- “App Tier” subdivided into MVC:
– Controllers (AuthController, HomeController)
– Models (Asistencia, Usuario, etc.)
– Utils/Services (Email Notifier)
- “Data Tier” (MySQL Database)
- “External Services” (Google OAuth, Microsoft OAuth, SMTP)
- From Clients to Web Server (HTTP)
- Web Server to Controllers (internal call)
- Controllers to Models (method calls)
- Models to Database (SQL queries)
- Controllers/Utils to SMTP & OAuth (HTTPS requests)
- Responses flow back accordingly
- Blue for “Web & App Tier”
- Orange for “Data Tier”
- Grey for “Utilities & Config”

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Clients
    subgraph "Clients"##lightblue
        Browser["Browser"]
        Mobile["Mobile"]
    end

    %% Web Tier
    subgraph "Web Tier"##blue
        WebServer["Nginx/Apache + PHP-FPM"]
        FrontController["public/index.php"]
        Composer["vendor/"]
    end

    %% Config Service
    subgraph "Configuration Service"##grey
        JSON["config.json"]
        Const["config/constants.php"]
        DBConfig["config/database.php"]
    end

    %% Application Tier
    subgraph "App Tier"##blue
        subgraph "Controllers"##blue
            AuthCtrl["AuthController"]
            HomeCtrl["HomeController"]
        end
        subgraph "Models"##blue
            Asistencia["Asistencia"]
            Aula["Aula"]
            Clase["Clase"]
            Comentario["Comentario"]
            Curso["Curso"]
            Estudiante["Estudiante"]
            Nota["Nota"]
            Unidad["Unidad"]
            Usuario["Usuario"]
        end
        subgraph "Views"##blue
            HomeView["home.php"]
            LoginView["login.php"]
            RegisterView["register.php"]
            TestiView["testimonios.php"]
            MentorView["mentores.php"]
            HeadComp["components/head.php"]
            HeaderComp["components/header.php"]
            NavComp["components/nav.php"]
            FooterComp["components/footer.php"]
            DashboardView["dashboard.php"]
            DashboardsDir["dashboards/"]
            Calificaciones["docente/calificaciones.php"]
            EstudianteViews["estudiante/"]
        end
        subgraph "Utils & Services"##grey
            Correo["CorreoConfirmacion"]
            Notificador["NotificadorCorreo"]
            NotifyAuth["auth/notify.php"]
        end
    end

    %% Data Tier
    subgraph "Data Tier"##orange
        MySQL["MySQL Database"]
        Schema["sql/ams.sql"]
    end

    %% External Services
    subgraph "External Services"##lightgreen
        GoogleOAuth["Google OAuth"]
        MicrosoftOAuth["Microsoft OAuth"]
        SMTP["SMTP Mail Server"]
    end

    %% Public Assets
    subgraph "Public Assets"##grey
        CSS1["public/css/auths.css"]
        CSS2["public/css/estilos.css"]
        JS["public/js/script.js"]
        IMG["public/img/"]
    end

    %% Connections
    Browser -->|"HTTP Request"| WebServer
    Mobile -->|"HTTP Request"| WebServer
    WebServer --> FrontController
    FrontController --> Composer
    FrontController --> AuthCtrl
    FrontController --> HomeCtrl
    FrontController --> JSON
    FrontController --> Const
    FrontController --> DBConfig

    AuthCtrl --> Asistencia
    AuthCtrl --> Usuario
    AuthCtrl --> Correo
    AuthCtrl --> NotifyAuth
    HomeCtrl --> Curso
    HomeCtrl --> Estudiante

    Asistencia --> MySQL
    Aula --> MySQL
    Clase --> MySQL
    Comentario --> MySQL
    Curso --> MySQL
    Estudiante --> MySQL
    Nota --> MySQL
    Unidad --> MySQL
    Usuario --> MySQL
    Schema --> MySQL

    AuthCtrl -->|"redirect"| GoogleOAuth
    AuthCtrl -->|"redirect"| MicrosoftOAuth
    NotifyAuth --> SMTP
    Correo --> SMTP

    AuthCtrl --> LoginView
    AuthCtrl --> RegisterView
    HomeCtrl --> HomeView
    HomeCtrl --> DashboardView
    DashboardView --> DashboardsDir
    HomeCtrl --> TestiView
    HomeCtrl --> MentorView
    HomeCtrl --> Calificaciones
    HomeCtrl --> EstudianteViews

    FrontController --> CSS1
    FrontController --> CSS2
    FrontController --> JS
    FrontController --> IMG

    %% Click Events
    click FrontController "https://github.com/gregobhm/web_asm/blob/main/public/index.php"
    click Composer "https://github.com/gregobhm/web_asm/tree/main/vendor/"
    click JSON "https://github.com/gregobhm/web_asm/blob/main/config.json"
    click Const "https://github.com/gregobhm/web_asm/blob/main/config/constants.php"
    click DBConfig "https://github.com/gregobhm/web_asm/blob/main/config/database.php"
    click AuthCtrl "https://github.com/gregobhm/web_asm/blob/main/controllers/AuthController.php"
    click HomeCtrl "https://github.com/gregobhm/web_asm/blob/main/controllers/HomeController.php"
    click Asistencia "https://github.com/gregobhm/web_asm/blob/main/models/Asistencia.php"
    click Aula "https://github.com/gregobhm/web_asm/blob/main/models/Aula.php"
    click Clase "https://github.com/gregobhm/web_asm/blob/main/models/Clase.php"
    click Comentario "https://github.com/gregobhm/web_asm/blob/main/models/Comentario.php"
    click Curso "https://github.com/gregobhm/web_asm/blob/main/models/Curso.php"
    click Estudiante "https://github.com/gregobhm/web_asm/blob/main/models/Estudiante.php"
    click Nota "https://github.com/gregobhm/web_asm/blob/main/models/Nota.php"
    click Unidad "https://github.com/gregobhm/web_asm/blob/main/models/Unidad.php"
    click Usuario "https://github.com/gregobhm/web_asm/blob/main/models/Usuario.php"
    click HomeView "https://github.com/gregobhm/web_asm/blob/main/views/home.php"
    click LoginView "https://github.com/gregobhm/web_asm/blob/main/views/login.php"
    click RegisterView "https://github.com/gregobhm/web_asm/blob/main/views/register.php"
    click TestiView "https://github.com/gregobhm/web_asm/blob/main/views/testimonios.php"
    click MentorView "https://github.com/gregobhm/web_asm/blob/main/views/mentores.php"
    click HeadComp "https://github.com/gregobhm/web_asm/blob/main/views/components/head.php"
    click HeaderComp "https://github.com/gregobhm/web_asm/blob/main/views/components/header.php"
    click NavComp "https://github.com/gregobhm/web_asm/blob/main/views/components/nav.php"
    click FooterComp "https://github.com/gregobhm/web_asm/blob/main/views/components/footer.php"
    click DashboardView "https://github.com/gregobhm/web_asm/blob/main/views/dashboard.php"
    click DashboardsDir "https://github.com/gregobhm/web_asm/tree/main/views/dashboards/"
    click Calificaciones "https://github.com/gregobhm/web_asm/blob/main/views/docente/calificaciones.php"
    click EstudianteViews "https://github.com/gregobhm/web_asm/tree/main/views/estudiante/"
    click CSS1 "https://github.com/gregobhm/web_asm/blob/main/public/css/auths.css"
    click CSS2 "https://github.com/gregobhm/web_asm/blob/main/public/css/estilos.css"
    click JS "https://github.com/gregobhm/web_asm/blob/main/public/js/script.js"
    click IMG "https://github.com/gregobhm/web_asm/tree/main/public/img/"
    click GoogleOAuth "https://github.com/gregobhm/web_asm/blob/main/auth/google.php"
    click MicrosoftOAuth "https://github.com/gregobhm/web_asm/blob/main/auth/microsoft.php"
    click NotifyAuth "https://github.com/gregobhm/web_asm/blob/main/auth/notify.php"
    click Correo "https://github.com/gregobhm/web_asm/blob/main/utils/CorreoConfirmacion.php"
    click Notificador "https://github.com/gregobhm/web_asm/blob/main/utils/abstract/NotificadorCorreo.php"
    click Schema "https://github.com/gregobhm/web_asm/blob/main/sql/ams.sql"

    %% Styles
    classDef lightblue fill:#E3F2FD,stroke:#90CAF9
    classDef blue fill:#BBDEFB,stroke:#2196F3
    classDef orange fill:#FFE0B2,stroke:#FB8C00
    classDef grey fill:#CFD8DC,stroke:#607D8B
    classDef lightgreen fill:#C8E6C9,stroke:#66BB6A
```
