# marcsastrecabre/sistemagestiohotel architecture

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

- Interactive diagram: https://gitdiagram.com/marcsastrecabre/sistemagestiohotel
- Repository: https://github.com/marcsastrecabre/sistemagestiohotel

## Overview

##### Project Type and Purpose
- This is a Java-based desktop application built using JavaFX (as indicated by the FXML files) and Maven (see pom.xml).
- Its purpose is to manage hotel operations including the management of persons (clients and employees), reservations, tasks, and invoicing. It connects directly with an SQL database where eight interrelated tables store the core domain data.

##### File Structure Analysis
- The project uses a typical Maven structure. Under src/main/java/com/mycompany/s_gestio_hotel, you find the core application entry point (App.java), along with several controller classes (FacturaController, IniciController, PersonaController, ReservaController, TascaController) that handle UI interactions.
- The model package contains Java classes for every domain entity (Client, Empleat, Factura, Habitacio, Reserva, etc.) and utility classes like Connexio, GesitioDades, and a Model class holding the in-memory representation.
- The src/main/resources folder contains FXML files for each screen (factura.fxml, inici.fxml, persona.fxml, reserva.fxml, tasca.fxml) that form the presentation layer.
- Build and project configuration files (e.g., pom.xml, nbactions.xml) show that Maven is used for dependency management and building.

##### README Insights
- The README details both the conceptual and logical/relational designs of the database, showing how tables like PERSONA, EMPLEAT, CLIENT, etc., are connected via foreign keys.
- It explains that on startup, the application loads all data into memory, and further changes in the UI are synchronized with the database.

a. Main Components:
- Presentation Layer: FXML views (in resources) and user interactions.
- Controller Layer: Controller classes (FacturaController, IniciController, PersonaController, ReservaController, TascaController) handling UI events.
- Domain/Model Layer: Model classes corresponding to each database table (Client, Empleat, Factura, Habitacio, Reserva, etc.), plus classes managing data (Model, GesitioDades).
- Persistence Layer (Database): Eight interrelated tables described in the README (PERSONA, EMPLEAT, CLIENT, TASCA, EMPLEAT_TASCA, FACTURA, HABITACIÓ, RESERVA).
- Infrastructure: Connection management (Connexio) and configuration (Maven, pom.xml).

b. Relationships and Interactions:
- From the UI (FXML Views) to Controllers.
- From Controllers to the Model layer where core business logic is maintained.
- From the Model to the Database (via connection and data management classes) and vice versa.
- That changes in the UI trigger updates in the in-memory model and automatically sync with the database.
- Relations reflecting the database foreign key associations (e.g., CLIENT links to PERSONA; RESERVA links to CLIENT, HABITACIÓ, and FACTURA).

c. Architectural Patterns and Design Principles:
- Model-View-Controller (MVC): Controllers mediate user input from the FXML-based views and update the Model.
- Tight coupling between the UI, model, and database for direct, immediate update propagation.
- Use of Maven for dependency/build management indicates standard modularity and separation of concerns.

d. Technologies and Frameworks:
- Java (core language).
- JavaFX (for the UI, using FXML files).
- Maven (build and dependency management).
- JDBC or similar (for database connectivity; see class Connexio and GesitioDades).
- SQL (as evident from the SQL scripts in the README).

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Presentation Layer
    subgraph "Presentation Layer"
        UI["FXML Views"]:::presentation
    end

    %% Controller Layer
    subgraph "Controller Layer"
        Controllers["Controller Classes (FacturaController, IniciController, etc.)"]:::controller
    end

    %% Domain/Model Layer
    subgraph "Domain/Model Layer"
        Entities["Entity Models & Business Logic"]:::model
        DataAccess["Data Access (Connexio & GesitioDades)"]:::dataAccess
    end

    %% Persistence Layer (SQL Database)
    subgraph "Persistence Layer"
        Database["SQL Database"]:::db
    end

    %% Build & Configuration Infrastructure
    subgraph "Build & Configuration"
        BuildPom["pom.xml"]:::build
        BuildNb["nbactions.xml"]:::build
    end

    %% Connections
    UI -->|"triggers"| Controllers
    Controllers -->|"updates"| Entities
    Entities -->|"syncs_with"| DataAccess
    DataAccess -->|"queries"| Database
    %% Note: Data synchronization is bidirectional
    DataAccess -- "updates" --> Entities

    %% Click Events
    click UI "https://github.com/marcsastrecabre/sistemagestiohotel/tree/master/src/main/resources/com/mycompany/s_gestio_hotel/"
    click Controllers "https://github.com/marcsastrecabre/sistemagestiohotel/tree/master/src/main/java/com/mycompany/s_gestio_hotel/"
    click Entities "https://github.com/marcsastrecabre/sistemagestiohotel/tree/master/src/main/java/com/mycompany/s_gestio_hotel/model/"
    click DataAccess "https://github.com/marcsastrecabre/sistemagestiohotel/tree/master/src/main/java/com/mycompany/s_gestio_hotel/model/"
    click BuildPom "https://github.com/marcsastrecabre/sistemagestiohotel/blob/master/pom.xml"
    click BuildNb "https://github.com/marcsastrecabre/sistemagestiohotel/blob/master/nbactions.xml"

    %% Styles
    classDef presentation fill:#add8e6,stroke:#000,stroke-width:1px;
    classDef controller fill:#ffeb99,stroke:#000,stroke-width:1px;
    classDef model fill:#c3f7c3,stroke:#000,stroke-width:1px;
    classDef dataAccess fill:#f9cc9c,stroke:#000,stroke-width:1px;
    classDef db fill:#d3d3d3,stroke:#000,stroke-width:1px;
    classDef build fill:#d1c4e9,stroke:#000,stroke-width:1px;
```
