# wassim-rached/project-php-2023 architecture

> Architecture diagram of the GitHub repository wassim-rached/project-php-2023, 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/wassim-rached/project-php-2023
- Repository: https://github.com/wassim-rached/project-php-2023

## Overview

##### Project type and purpose
- This is a small full-stack PHP web application (“Mini Projet 2023 – Gestion des Stages”) for managing internships (stages) with CRUD pages for students, teachers, defenses (“soutenances”) and an admin authentication layer.
- It uses PHP (with PDO), MySQL, Nginx (with a Docker Compose setup), plus static CSS/JS for the UI.

##### File structure
- Top-level:
- docker-compose.yml → defines services (web, db).
- nginx-conf/default.conf → Nginx virtual-host config.
- sql/create.sql & insert.sql → DB schema & seed.
- css/, js/ → static assets.
- src/ → PHP code, subdivided into:
– authentication (login.php, logout.php)
– enseignant, etudiant, soutenance modules (CRUD pages)
– utils (dbconfig, connexion, adminOnlyPage)
– index.php → landing/auth form.
- README.md documents the schema, pages, and flow.

##### README for additional insights
- Confirms a MySQL “stages” database with four tables (Etudiant, Enseignant, Soutenance, Administrateur).
- Describes each page’s responsibility and the use of sessions for admin auth.

##### Main components and their interactions
a. Components:
- User / Browser (interacts over HTTP).
- Nginx web server (reverse–proxy to PHP-FPM).
- PHP application (monolithic code in src/):
- Auth module
- Student, Teacher, Defense modules
- Utils (DB connection, access control)
- MySQL database (containerized).
- Static asset server (served by Nginx).
b. Relationships / Data flows:
1. User submits HTTP request → Nginx
2. Nginx routes to PHP-FPM → appropriate PHP script in src/
3. PHP script uses PDO (via dbconfig & connexion) to query/update MySQL
4. PHP renders HTML embedding CSS/JS assets back to the browser
5. User can navigate, triggering CRUD operations or login/logout
c. Architectural patterns / principles:
- Monolithic PHP code organized by functional modules.
- Single database backing all modules.
- Session-based admin authentication.
- Separation of concerns:
- src/authentication, src/etudiant, src/enseignant, src/soutenance
- Shared utilities in src/utils
d. Key technologies:
- Nginx, Docker Compose
- PHP-FPM, PDO
- MySQL
- HTML5/CSS3/vanilla JavaScript

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Top-level Docker Compose orchestration
    DockerCompose["Docker Compose"]:::doc
    click DockerCompose "https://github.com/wassim-rached/project-php-2023/blob/master/docker-compose.yml"

    %% Presentation Layer
    Browser["Browser"]:::browser

    %% Web and DB Services grouping
    subgraph "Web Service"
        direction TB
        Nginx["Nginx"]:::container
        click Nginx "https://github.com/wassim-rached/project-php-2023/blob/master/nginx-conf/default.conf"
        PHPFPM["PHP-FPM"]:::container

        subgraph "PHP Modules"
            direction TB
            Auth["Authentication Module"]:::auth
            click Auth "https://github.com/wassim-rached/project-php-2023/blob/master/src/authentication/login.php"
            click Auth "https://github.com/wassim-rached/project-php-2023/blob/master/src/authentication/logout.php"
            Etudiant["Etudiant Module"]:::etudiant
            click Etudiant "https://github.com/wassim-rached/project-php-2023/blob/master/src/etudiant/ajouter_etudiant.php"
            click Etudiant "https://github.com/wassim-rached/project-php-2023/blob/master/src/etudiant/liste_etudiants.php"
            click Etudiant "https://github.com/wassim-rached/project-php-2023/blob/master/src/etudiant/modifier_etudiant.php"
            click Etudiant "https://github.com/wassim-rached/project-php-2023/blob/master/src/etudiant/supprimer_etudiant.php"
            Enseignant["Enseignant Module"]:::enseignant
            click Enseignant "https://github.com/wassim-rached/project-php-2023/blob/master/src/enseignant/ajouter_enseignant.php"
            Soutenance["Soutenance Module"]:::soutenance
            click Soutenance "https://github.com/wassim-rached/project-php-2023/blob/master/src/soutenance/ajouter_soutenance.php"
            click Soutenance "https://github.com/wassim-rached/project-php-2023/blob/master/src/soutenance/rechercher.php"
            Utils["Shared Utilities"]:::utils
            click Utils "https://github.com/wassim-rached/project-php-2023/blob/master/src/utils/dbconfig.php"
            click Utils "https://github.com/wassim-rached/project-php-2023/blob/master/src/utils/connexion.php"
            click Utils "https://github.com/wassim-rached/project-php-2023/blob/master/src/utils/adminOnlyPage.php"
        end

        CSS["CSS Files"]:::static
        click CSS "https://github.com/wassim-rached/project-php-2023/blob/master/css/main.css"
        click CSS "https://github.com/wassim-rached/project-php-2023/blob/master/css/navbar.css"
        JS["JavaScript Files"]:::static
        click JS "https://github.com/wassim-rached/project-php-2023/blob/master/js/navbar.js"
    end

    subgraph "DB Service"
        MySQL["MySQL Database"]:::database
        click MySQL "https://github.com/wassim-rached/project-php-2023/blob/master/sql/create.sql"
        click MySQL "https://github.com/wassim-rached/project-php-2023/blob/master/sql/insert.sql"
    end

    %% Entry point and Docs
    Entry["Entry Point\nindex.php"]:::entry
    click Entry "https://github.com/wassim-rached/project-php-2023/blob/master/src/index.php"
    README["Project Documentation"]:::doc
    click README "https://github.com/wassim-rached/project-php-2023/blob/master/README.md"

    %% Connections
    DockerCompose --> Nginx
    DockerCompose --> MySQL

    Browser -->|"HTTP/S"| Nginx
    Nginx -->|"FastCGI"| PHPFPM
    PHPFPM --> Auth
    PHPFPM --> Etudiant
    PHPFPM --> Enseignant
    PHPFPM --> Soutenance
    PHPFPM --> Utils

    Nginx -->|"serves"| CSS
    Nginx -->|"serves"| JS

    Auth -->|"PDO MySQL"| MySQL
    Etudiant -->|"PDO MySQL"| MySQL
    Enseignant -->|"PDO MySQL"| MySQL
    Soutenance -->|"PDO MySQL"| MySQL
    Utils -->|"PDO MySQL"| MySQL

    Browser --> Entry
    Entry --> Auth
    Entry --> README

    %% Styles
    classDef browser fill:#ffebcc,stroke:#333,stroke-width:1px
    classDef container fill:#cce5ff,stroke:#004085,stroke-width:1px
    classDef auth fill:#d1ecf1,stroke:#0c5460,stroke-width:1px
    classDef etudiant fill:#fff3cd,stroke:#856404,stroke-width:1px
    classDef enseignant fill:#d4edda,stroke:#155724,stroke-width:1px
    classDef soutenance fill:#f8d7da,stroke:#721c24,stroke-width:1px
    classDef utils fill:#e2e3e5,stroke:#6c757d,stroke-width:1px
    classDef static fill:#d1ecf1,stroke:#0c5460,stroke-width:1px
    classDef database fill:#c3e6cb,stroke:#155724,stroke-width:1px
    classDef doc fill:#e2e3e5,stroke:#6c757d,stroke-width:1px,stroke-dasharray: 5 5
    classDef entry fill:#f5c6cb,stroke:#721c24,stroke-width:1px
```
