# bryanmg20/hotel_laureles architecture

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

- Interactive diagram: https://gitdiagram.com/bryanmg20/hotel_laureles
- Repository: https://github.com/bryanmg20/hotel_laureles

## Overview

##### Project type and purpose
- This is a full-stack hotel reservation web application (“Hotel_Laureles”).
- Frontend: React (SPA) served via Nginx in Docker.
- Backend: Python Flask REST API in Docker, implements reservation, check-in/out, billing, payments, room management, user management.
- Persistence: MySQL database in Docker, initialized via los_laureles.sql.

##### File structure
- Top-level directories:
- backend/ – Flask service
- fronted/ – React client (typo “fronted” rather than “frontend”)
- mysql/ – MySQL service and init script
- backend/app/models → ORM models (Habitacion, Usuario)
- backend/app/routes → REST endpoints (admin_* and user routes)
- fronted/src/components → UI components (public & admin)
- fronted/src/context → React Contexts (AuthContext, CartContext)
- Docker-related files in each service: Dockerfile(.dev), docker-compose.yml, .env

##### README
- Minimal description: “Proyecto final de base de datos.”

##### Components
a. Main Components
1. Client Browser (User & Admin UIs)
2. Nginx Reverse Proxy / Static Server (serves React build)
3. React Application (SPA)
4. Flask REST API
5. MySQL Database
6. Docker Compose Network (orchestrates containers)
b. Relationships & Data Flows
- Browser ↔ (HTTPS) ↔ Nginx ↔ React App
- React App → (REST calls) → Flask API
- Flask API ↔ (SQL queries) ↔ MySQL DB
- Admin UI (subset of React) ↔ same Flask API endpoints
c. Architectural Patterns / Principles
- Container-based microservices (three containers)
- Stateless RESTful API
- React Context for state (Auth, Cart)
- Separation of concerns: presentation (React), business logic (Flask), persistence (MySQL)
d. Key Technologies
- Docker & Docker Compose
- Nginx
- React (JSX, Context API)
- Flask (Python, blueprinted routes)
- MySQL

## Diagram (Mermaid)

```mermaid
flowchart TD
    classDef frontend fill:#D6EAF8,stroke:#1B4F72,color:#1B2631
    classDef backend fill:#D5F5E3,stroke:#196F3D,color:#145A32
    classDef db fill:#FCF3CF,stroke:#B9770E,color:#784212
    classDef infra fill:#FADBD8,stroke:#922B21,color:#641E16

    Browser["Client Browser"]:::infra

    subgraph "Docker Compose Network"
        direction TB

        subgraph "Frontend Service" 
            direction TB
            Nginx["Nginx Reverse Proxy / Static Server"]:::frontend
            React["React SPA Container"]:::frontend

            Nginx -->|"serves static assets"| React

            click React "https://github.com/bryanmg20/hotel_laureles/tree/main/fronted/src"
            click Nginx "https://github.com/bryanmg20/hotel_laureles/blob/main/fronted/nginx.conf"
            click Nginx "https://github.com/bryanmg20/hotel_laureles/blob/main/fronted/Dockerfile.dev"
        end

        subgraph "Backend Service"
            direction TB
            Flask["Flask REST API Container"]:::backend

            Flask -->|"handles business logic"| Flask
            click Flask "https://github.com/bryanmg20/hotel_laureles/blob/main/backend/run.py"
            click Flask "https://github.com/bryanmg20/hotel_laureles/blob/main/backend/app/config.py"
            click Flask "https://github.com/bryanmg20/hotel_laureles/blob/main/backend/.env"
            click Flask "https://github.com/bryanmg20/hotel_laureles/tree/main/backend/Dockerfile"
            click Flask "https://github.com/bryanmg20/hotel_laureles/blob/main/backend/docker-compose.yml"

            subgraph "Flask Modules"
                direction TB
                Models["Models: habitacion.py, usuario.py"]:::backend
                Routes["Routes: admin_*.py, reserva.py, usuario.py"]:::backend
                click Models "https://github.com/bryanmg20/hotel_laureles/blob/main/backend/app/models/habitacion.py"
                click Models "https://github.com/bryanmg20/hotel_laureles/blob/main/backend/app/models/usuario.py"
                click Routes "https://github.com/bryanmg20/hotel_laureles/blob/main/backend/app/routes/admin_reserva.py"
                click Routes "https://github.com/bryanmg20/hotel_laureles/blob/main/backend/app/routes/reserva.py"
            end

            Models --> Flask
            Routes --> Flask
        end

        subgraph "MySQL Service"
            direction TB
            MySQL["MySQL Container"]:::db
            click MySQL "https://github.com/bryanmg20/hotel_laureles/blob/main/mysql/los_laureles.sql"
            click MySQL "https://github.com/bryanmg20/hotel_laureles/blob/main/mysql/.env"
            click MySQL "https://github.com/bryanmg20/hotel_laureles/blob/main/mysql/docker-compose.yml"
        end
    end

    Browser -->|"HTTPS"| Nginx
    React -->|"REST API calls"| Flask
    Flask -->|"SQL queries"| MySQL

    class Browser infra
    class Flask backend
    class MySQL db
```
