# joshdev27/desarrollo_vii_proyecto_hotelweb architecture

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

- Interactive diagram: https://gitdiagram.com/joshdev27/desarrollo_vii_proyecto_hotelweb
- Repository: https://github.com/joshdev27/desarrollo_vii_proyecto_hotelweb

## Overview

1. **Overall shape**
   - This is a **plain PHP/MySQL hotel reservation system** with a hand-rolled MVC-style structure, not a full framework app.
   - The codebase is split between **request handlers**, **views/templates**, **reusable UI partials**, **database scripts**, and **static assets**.

2. **Request entry and page flow**
   - The main public entry point is **`index.php`**.
   - Requests are then routed into page/controller scripts under **`src/`** and, in some cases, the older **`app/controller/`** layer.
   - Rendering is done through **`views/`** and **`components/`**, which act as the presentation layer.

3. **Application logic layer**
   - The newer page-oriented logic appears in **`src/`**:
     - `src/user/*` for guest/user features
     - `src/admin/*` for admin features
     - `src/login.php`, `src/logout.php`, `src/function.php`, `src/validaciones.php` for cross-cutting auth/helpers/validation
   - There is also an older MVC pair in **`app/controller/`** and **`app/models/`** with separate `admin_*` and `user_*` classes/files.
   - The presence of both suggests an **evolving or partially duplicated architecture**, with `src/` likely the current execution path and `app/` a legacy or parallel structure.

4. **Domain boundaries: user vs admin**
   - The system is clearly divided into two main user experiences:
     - **Guest/user portal**: home, registration, login, profile, reservations, password recovery, contact.
     - **Admin portal**: users, rooms, reservations, stats/reporting, email-related operations.
   - This split is reflected consistently in:
     - `src/user/` vs `src/admin/`
     - `views/user/` vs `views/admin/`
     - `components/user/` vs `components/admin/`

5. **Presentation layer**
   - **`views/`** contains page-level templates for the main user and admin screens.
   - **`components/`** contains reusable partials such as headers, footers, navbars, forms, modals, and email templates.
   - Important subgroups:
     - `components/user/`: login, registration, profile, reservation UI
     - `components/admin/`: room/user/reservation management UI
     - `components/plantillas_correos/`: email HTML templates for reservation confirmation, contact, and password recovery

6. **Data access and persistence**
   - Database connectivity lives in **`database/conection/Database.php`**.
   - The database design is supported by SQL artifacts in:
     - `database/hotel_tablas/` for table creation
     - `database/hotel_sps/` for stored procedures
   - This indicates a **stored-procedure-driven data access pattern**, where PHP calls MySQL procedures rather than embedding all SQL directly in the app.

7. **Core business operations**
   - The stored procedures reveal the main system capabilities:
     - authentication and registration
     - user edit/delete
     - room creation/editing
     - reservations and cancellation
     - reservation confirmation
     - password updates and token handling
     - contact/consultation registration
     - totals/statistics queries
   - So the database is not just storage; it also contains a significant part of the **business rule execution path**.

8. **Authentication and session flow**
   - Login/logout and password recovery are first-class flows.
   - The repo includes session-oriented UI and logic such as `components/user/sesion.php`, `src/login.php`, and `src/logout.php`.
   - Token-related recovery support is backed by the database procedure for adding user tokens and updating passwords.

9. **Reservation and email flow**
   - A reservation likely flows from the user interface through the user-side handler into the database reservation procedure.
   - After booking or confirmation events, the system uses **email templates** under `components/plantillas_correos/` and the corresponding `src/user/correo.php` / `src/admin/correos.php` logic to send notifications.
   - This makes email a separate integration boundary tied to reservation and recovery events.

10. **Static assets and UI dependencies**
   - Front-end assets are under **`public/`**:
     - CSS/SCSS sources in `public/assets/css`
     - JavaScript in `public/assets/js`
     - images in `public/img`
   - Third-party UI libraries are vendored directly:
     - **Font Awesome**
     - **Hamburgers**
   - These are presentation-only dependencies and do not affect backend flow, but they shape the user/admin interface.

11. **Configuration and environment**
   - **`config.php`** and **`.env`** indicate environment-based configuration, likely for DB credentials and runtime settings.
   - The project also includes **Composer** metadata (`composer.json`, `composer.lock`), so PHP dependencies may be managed externally even though no framework is used.

12. **Legacy/backup material**
   - The `backup/` directory contains older controller copies, and there are duplicated concepts across `app/`, `src/`, and `views/`.
   - For an architecture diagram, treat these as **non-primary or historical artifacts** unless verified otherwise.
   - The core production structure is best represented as: **HTTP entry → PHP handlers/controllers → DB procedures/connection → rendered views/components → browser**, with admin and user branches layered on top.

Main entry points: [`src/user`](https://github.com/joshdev27/desarrollo_vii_proyecto_hotelweb/tree/main/src/user) (User flows), [`src/admin`](https://github.com/joshdev27/desarrollo_vii_proyecto_hotelweb/tree/main/src/admin) (Admin flows), [`database/conection/Database.php`](https://github.com/joshdev27/desarrollo_vii_proyecto_hotelweb/blob/main/database/conection/Database.php) (DB conn), [`views/user`](https://github.com/joshdev27/desarrollo_vii_proyecto_hotelweb/tree/main/views/user) (User views)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_runtime["Runtime entry"]
  node_index["index.php<br/>entry point<br/>[index.php]"]
end

subgraph group_app["Application logic"]
  node_src_user["User flows<br/>php pages"]
  node_src_admin["Admin flows<br/>php pages"]
  node_src_auth["Auth helpers<br/>shared php<br/>[function.php]"]
  node_src_login["Login<br/>auth handler<br/>[login.php]"]
  node_src_logout["Logout<br/>auth handler<br/>[logout.php]"]
end

subgraph group_ui["Presentation"]
  node_views_user["User views<br/>templates"]
  node_views_admin["Admin views<br/>templates"]
  node_views_layout["Layouts<br/>template shell<br/>[layout.php]"]
  node_components_user["User parts<br/>partials"]
  node_components_admin["Admin parts<br/>partials"]
  node_components_mail["Mail templates<br/>email partials"]
end

subgraph group_data["Data layer"]
  node_db_conn[("DB conn<br/>php database<br/>[Database.php]")]
  node_db_tables["Tables<br/>sql schema"]
  node_db_sps["Stored procs<br/>sql procedures"]
end

subgraph group_legacy["Legacy MVC"]
  node_app_controller["Controllers<br/>legacy php"]
  node_app_models["Models<br/>legacy php"]
end

subgraph group_static["Static assets"]
  node_public_assets["Assets<br/>css/js/img"]
  node_public_libs["Vendored libs<br/>ui libraries"]
end

node_index -->|"routes to"| node_src_user
node_index -->|"routes to"| node_src_admin
node_src_user -->|"uses"| node_src_auth
node_src_admin -->|"uses"| node_src_auth
node_src_login -->|"auth queries"| node_db_conn
node_src_logout -->|"session"| node_src_auth
node_src_user -->|"calls"| node_db_sps
node_src_admin -->|"calls"| node_db_sps
node_src_user -->|"renders"| node_views_user
node_src_admin -->|"renders"| node_views_admin
node_src_user -->|"includes"| node_components_user
node_src_admin -->|"includes"| node_components_admin
node_src_user -->|"sends mail"| node_components_mail
node_src_admin -->|"sends mail"| node_components_mail
node_views_user -->|"wraps with"| node_views_layout
node_views_admin -->|"wraps with"| node_views_layout
node_db_conn -->|"targets"| node_db_tables
node_db_conn -->|"executes"| node_db_sps
node_app_controller -->|"uses"| node_app_models
node_app_controller -->|"db access"| node_db_conn
node_src_user -->|"uses"| node_public_assets
node_src_admin -->|"uses"| node_public_assets
node_views_user -->|"uses"| node_public_libs
node_views_admin -->|"uses"| node_public_libs

click node_index "https://github.com/joshdev27/desarrollo_vii_proyecto_hotelweb/blob/main/index.php"
click node_src_user "https://github.com/joshdev27/desarrollo_vii_proyecto_hotelweb/tree/main/src/user"
click node_src_admin "https://github.com/joshdev27/desarrollo_vii_proyecto_hotelweb/tree/main/src/admin"
click node_src_auth "https://github.com/joshdev27/desarrollo_vii_proyecto_hotelweb/blob/main/src/function.php"
click node_src_login "https://github.com/joshdev27/desarrollo_vii_proyecto_hotelweb/blob/main/src/login.php"
click node_src_logout "https://github.com/joshdev27/desarrollo_vii_proyecto_hotelweb/blob/main/src/logout.php"
click node_views_user "https://github.com/joshdev27/desarrollo_vii_proyecto_hotelweb/tree/main/views/user"
click node_views_admin "https://github.com/joshdev27/desarrollo_vii_proyecto_hotelweb/tree/main/views/admin"
click node_views_layout "https://github.com/joshdev27/desarrollo_vii_proyecto_hotelweb/blob/main/views/layout.php"
click node_components_user "https://github.com/joshdev27/desarrollo_vii_proyecto_hotelweb/tree/main/components/user"
click node_components_admin "https://github.com/joshdev27/desarrollo_vii_proyecto_hotelweb/tree/main/components/admin"
click node_components_mail "https://github.com/joshdev27/desarrollo_vii_proyecto_hotelweb/tree/main/components/plantillas_correos"
click node_db_conn "https://github.com/joshdev27/desarrollo_vii_proyecto_hotelweb/blob/main/database/conection/Database.php"
click node_db_tables "https://github.com/joshdev27/desarrollo_vii_proyecto_hotelweb/tree/main/database/hotel_tablas"
click node_db_sps "https://github.com/joshdev27/desarrollo_vii_proyecto_hotelweb/tree/main/database/hotel_sps"
click node_app_controller "https://github.com/joshdev27/desarrollo_vii_proyecto_hotelweb/tree/main/app/controller"
click node_app_models "https://github.com/joshdev27/desarrollo_vii_proyecto_hotelweb/tree/main/app/models"
click node_public_assets "https://github.com/joshdev27/desarrollo_vii_proyecto_hotelweb/tree/main/public/assets"
click node_public_libs "https://github.com/joshdev27/desarrollo_vii_proyecto_hotelweb/tree/main/public/Lib"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_index toneBlue
class node_src_user,node_src_admin,node_src_auth,node_src_login,node_src_logout toneAmber
class node_views_user,node_views_admin,node_views_layout,node_components_user,node_components_admin,node_components_mail toneMint
class node_db_conn,node_db_tables,node_db_sps toneRose
class node_app_controller,node_app_models toneIndigo
class node_public_assets,node_public_libs toneTeal
```

## Components

### Runtime entry

HTTP entry and cross-cutting bootstrap

- [index.php](https://github.com/joshdev27/desarrollo_vii_proyecto_hotelweb/blob/main/index.php): entry point · Main public entry that starts request handling · `index.php`

### Application logic

Current request handlers and business flows

- [User flows](https://github.com/joshdev27/desarrollo_vii_proyecto_hotelweb/tree/main/src/user): php pages · Guest-facing handlers for home, registration, reservations, contact, and recovery · `src/user`
- [Admin flows](https://github.com/joshdev27/desarrollo_vii_proyecto_hotelweb/tree/main/src/admin): php pages · Admin handlers for users, rooms, reservations, stats, and mail actions · `src/admin`
- [Auth helpers](https://github.com/joshdev27/desarrollo_vii_proyecto_hotelweb/blob/main/src/function.php): shared php · Cross-cutting login, logout, validation, and utility logic · `src/function.php`
- [Login](https://github.com/joshdev27/desarrollo_vii_proyecto_hotelweb/blob/main/src/login.php): auth handler · Authentication entry and session start · `src/login.php`
- [Logout](https://github.com/joshdev27/desarrollo_vii_proyecto_hotelweb/blob/main/src/logout.php): auth handler · Session termination flow · `src/logout.php`

### Presentation

Page templates and reusable UI partials

- [User views](https://github.com/joshdev27/desarrollo_vii_proyecto_hotelweb/tree/main/views/user): templates · Page templates for the guest and member experience · `views/user`
- [Admin views](https://github.com/joshdev27/desarrollo_vii_proyecto_hotelweb/tree/main/views/admin): templates · Page templates for the admin experience · `views/admin`
- [Layouts](https://github.com/joshdev27/desarrollo_vii_proyecto_hotelweb/blob/main/views/layout.php): template shell · Shared page shell and error page template · `views/layout.php`
- [User parts](https://github.com/joshdev27/desarrollo_vii_proyecto_hotelweb/tree/main/components/user): partials · Reusable user UI pieces such as forms, profile, session, and reservation widgets · `components/user`
- [Admin parts](https://github.com/joshdev27/desarrollo_vii_proyecto_hotelweb/tree/main/components/admin): partials · Reusable admin UI pieces for managing users, rooms, and reservations · `components/admin`
- [Mail templates](https://github.com/joshdev27/desarrollo_vii_proyecto_hotelweb/tree/main/components/plantillas_correos): email partials · HTML templates for reservation confirmation, contact, and password recovery emails · `components/plantillas_correos`

### Data layer

Database connection and SQL artifacts

- [DB conn](https://github.com/joshdev27/desarrollo_vii_proyecto_hotelweb/blob/main/database/conection/Database.php): php database · Database connection and access bootstrap · `database/conection/Database.php`
- [Tables](https://github.com/joshdev27/desarrollo_vii_proyecto_hotelweb/tree/main/database/hotel_tablas): sql schema · Database table creation scripts for users, roles, reservations, rooms, and consultations · `database/hotel_tablas`
- [Stored procs](https://github.com/joshdev27/desarrollo_vii_proyecto_hotelweb/tree/main/database/hotel_sps): sql procedures · Stored procedures for auth, CRUD, reservations, totals, recovery, and messaging · `database/hotel_sps`

### Legacy MVC

Older controller/model layer that overlaps the newer src flow

- [Controllers](https://github.com/joshdev27/desarrollo_vii_proyecto_hotelweb/tree/main/app/controller): legacy php · Older controller layer for admin and user actions · `app/controller`
- [Models](https://github.com/joshdev27/desarrollo_vii_proyecto_hotelweb/tree/main/app/models): legacy php · Older model layer paired with the legacy controllers · `app/models`

### Static assets

Client-side styling, scripts, and vendored UI libraries

- [Assets](https://github.com/joshdev27/desarrollo_vii_proyecto_hotelweb/tree/main/public/assets): css/js/img · Front-end assets, styles, scripts, and images used by the UI · `public/assets`
- [Vendored libs](https://github.com/joshdev27/desarrollo_vii_proyecto_hotelweb/tree/main/public/Lib): ui libraries · Bundled Font Awesome and Hamburgers libraries · `public/Lib`

## Connections

- index.php → User flows: routes to · Public requests enter the user-facing handlers
- index.php → Admin flows: routes to · Admin requests enter the admin handlers
- User flows → Auth helpers: uses · User flows share login, logout, and validation helpers
- Admin flows → Auth helpers: uses · Admin flows rely on shared helpers and validation
- Login → DB conn: auth queries · Login reads/writes via the database connection
- Logout → Auth helpers: session · Logout is part of the shared authentication surface
- User flows → Stored procs: calls · Guest and member actions are backed by stored procedures
- Admin flows → Stored procs: calls · Admin management actions are backed by stored procedures
- User flows → User views: renders · User handlers render user templates
- Admin flows → Admin views: renders · Admin handlers render admin templates
- User flows → User parts: includes · User pages compose reusable UI partials
- Admin flows → Admin parts: includes · Admin pages compose reusable UI partials
- User flows → Mail templates: sends mail · Reservation and recovery flows use email templates
- Admin flows → Mail templates: sends mail · Admin-side confirmation and contact mail flows use email templates
- User views → Layouts: wraps with · User templates share the common page shell
- Admin views → Layouts: wraps with · Admin templates share the common page shell
- DB conn → Tables: targets · Connection layer operates over the hotel schema
- DB conn → Stored procs: executes · Application data access is procedure-driven
- Controllers → Models: uses · Legacy controllers depend on legacy models
- Controllers → DB conn: db access · Legacy logic also reaches the database layer
- User flows → Assets: uses · User pages rely on shared front-end assets
- Admin flows → Assets: uses · Admin pages rely on shared front-end assets
- User views → Vendored libs: uses · User presentation uses vendored UI libraries
- Admin views → Vendored libs: uses · Admin presentation uses vendored UI libraries
