# 2001uri15/sgssi-proyecto architecture

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

- Interactive diagram: https://gitdiagram.com/2001uri15/sgssi-proyecto
- Repository: https://github.com/2001uri15/sgssi-proyecto

## Overview

##### Project Type and Purpose
- AlquiCar is a full-stack, containerized PHP web application for car rentals, deployed via Docker Compose.
- It uses Nginx as a reverse proxy, PHP scripts (app/) for business logic and templating, MySQL as the data store, and PHPMyAdmin for database management.

##### File Structure Analysis
- Top-level artifacts:
- Dockerfile, docker-compose.yml – define containers (web, db, phpmyadmin).
- nginx/ – TLS certs and Nginx configuration.
- app/ – PHP code, CSRF protection, templates, CSS, JavaScript, and PHPMailer integration (external SMTP).
- conf/custom.ini – app-specific settings.
- database.sql( .zip ) – initial schema and seed data.
- logs/ – persistent PHP error log.
- Patterns: monolithic PHP backend serving HTML/CSS/JS, MVC-style separation via app/plantillas (views) and process_* scripts (controllers).

##### README Insights
- Describes a three-service setup:
1. web (Nginx + PHP-FPM)
2. mysql (persistent storage)
3. phpmyadmin (DB admin interface)
- Ports: 81 for web, 3306 for MySQL, 8080 for PHPMyAdmin.

##### Main Components
a. Client Browser
b. Nginx Container (reverse proxy, SSL termination)
c. PHP-FPM Application Container (app/ directory mounted, custom.ini)
d. MySQL Container (database.sql import)
e. PHPMyAdmin Container (admin UI for MySQL)
f. External SMTP Service (PHPMailer)
g. Shared Volumes (logs/, app/, conf/)

##### Relationships and Interactions
- Client → HTTP(S) → Nginx (ports 81/443)
- Nginx → FastCGI → PHP-FPM
- PHP-FPM → SQL queries → MySQL
- Administrator → HTTP → PHPMyAdmin → MySQL
- PHP scripts → SMTP → External mail server (via PHPMailer)
- Volumes mount config, code, and logs between host and containers.

##### Architectural Patterns & Principles
- Containerization via Docker Compose (isolated services, reproducible environments).
- Clear separation of concerns: web server (NGINX) vs. application logic (PHP-FPM) vs. data (MySQL).
- MVC-style PHP templating (app/plantillas).
- Secure communications: TLS at Nginx, CSRF protection.
- Centralized configuration (conf/custom.ini).

##### Technologies & Frameworks
- Nginx, PHP-FPM, MySQL, PHP, PHPMailer, Docker, Docker Compose, PHPMyAdmin, JavaScript (validaciones.js), CSS.

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Layers
    Browser["Client Browser"]:::frontend
    Admin["Administrator"]:::frontend

    subgraph "Docker Compose Network"
        direction TB
        NginxContainer["Nginx Container"]:::frontend
        AppContainer["PHP-FPM App Container"]:::app
        MySQLContainer["MySQL Container"]:::data
        PhpmyAdminContainer["PHPMyAdmin Container"]:::data

        %% Volumes
        Volume_app["Volume: app/"]:::volume
        Volume_conf["Volume: conf/"]:::volume
        Volume_logs["Volume: logs/"]:::volume

        %% Init Scripts
        MySQLInit["Init SQL: database.sql"]:::data
        MySQLInitZip["Init SQL Zip: database.sql.zip"]:::data
    end

    SMTP["External SMTP Service"]:::external

    %% Data Flows
    Browser -->|"HTTP 81/443"| NginxContainer
    NginxContainer -->|"FastCGI"| AppContainer
    AppContainer -->|"SQL Query 3306"| MySQLContainer
    AppContainer -->|"SMTP"| SMTP
    Admin -->|"HTTP 8080"| PhpmyAdminContainer
    PhpmyAdminContainer -->|"SQL Query 3306"| MySQLContainer

    %% Volume Mounts
    Volume_app -.->|"/var/www/html"| AppContainer
    Volume_conf -.->|"/etc/nginx/conf.d & custom.ini"| NginxContainer
    Volume_conf -.->|"/etc/nginx/conf.d & custom.ini"| AppContainer
    Volume_logs -.->|"/var/log/php_errors.log"| AppContainer

    %% Initialization
    MySQLInit -->|Import| MySQLContainer
    MySQLInitZip -->|Import| MySQLContainer

    %% Click Events
    click NginxContainer "https://github.com/2001uri15/sgssi-proyecto/tree/main/nginx/"
    click AppContainer "https://github.com/2001uri15/sgssi-proyecto/tree/main/app/"
    click Config "https://github.com/2001uri15/sgssi-proyecto/blob/main/conf/custom.ini"
    click Compose "https://github.com/2001uri15/sgssi-proyecto/blob/main/docker-compose.yml"
    click Logs "https://github.com/2001uri15/sgssi-proyecto/blob/main/logs/php_errors.log"
    click MySQLInit "https://github.com/2001uri15/sgssi-proyecto/blob/main/database.sql"
    click MySQLInitZip "https://github.com/2001uri15/sgssi-proyecto/blob/main/database.sql.zip"
    click PhpmyAdminContainer "https://github.com/2001uri15/sgssi-proyecto/blob/main/docker-compose.yml"

    %% Styles
    classDef frontend fill:#D0E8FF,stroke:#0366D6,color:#0366D6;
    classDef app fill:#E0F8D8,stroke:#228B22,color:#228B22;
    classDef data fill:#FFE4B5,stroke:#CD8500,color:#CD8500;
    classDef external fill:#F0F0F0,stroke:#888888,color:#444444;
    classDef volume fill:#E8E8F0,stroke:#8888AA,color:#555577;
```
