# huynhducphu2502/hotel-management architecture

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

- Interactive diagram: https://gitdiagram.com/huynhducphu2502/hotel-management
- Repository: https://github.com/huynhducphu2502/hotel-management

## Overview

##### Project’s Main Components
- User Interface Layer: Represented by the FXML files (located in src/main/resources/iuh/fit/view and its subdirectories) which define the various UI panels for login, main dashboard, room booking, customer and employee management, invoicing, backup/restore, and statistics.
- Controllers Layer: All the classes in the src/main/java/iuh/fit/controller folder (including its features subfolders) form the presentation/business logic controllers that process user events from the UI and interact with other layers.
- Data Access Layer (DAO): The DAO classes in src/main/java/iuh/fit/dao and its subpackages abstract the interactions with the database, performing CRUD operations on entities such as Customer, Employee, Room, Invoice, etc.
- Domain/Model Layer: The classes in src/main/java/iuh/fit/models (as well as the enums and wrapper classes) represent the business entities and their attributes, which are passed across layers.
- Utility and Security Components: Additional utilities (src/main/java/iuh/fit/utils) provide supportive operations such as database connections, file handling, backup, and more. The security package (and related resource files) handles password hashing and configuration for application security.
- Database: While the physical database isn’t part of the codebase, the existence of SQL scripts (in the sql_script folder) for production and testing suggests integration with a relational database.

##### Relationships and Interactions
- Directional flow starting from the UI layer (JavaFX FXML views) that triggers user actions.
- That these actions are handled by the Controllers, which then invoke business logic.
- Controllers interact with the DAO layer to carry out persistence operations or retrieve data.
- The DAOs work with the underlying Database (possibly through helper utilities, e.g., DBHelper) and use SQL scripts for schema management.
- Utilities and security services support various layers by providing helper methods for tasks such as property management, backup/restore functions, and secure password handling.

##### Architectural Patterns and Design Principles
- Layered (n-tier) architecture: Distinct separation between UI, controller, data access, and business entities.
- MVC Pattern: The splitting of the visual elements (FXML/JavaFX UI views) from the Controllers that manage logic and DAOs/Models handling data.
- Modularity: The project is organized into different modules (or features) such as employee management, room booking, invoicing, statistics, and backup/restore.
- Use of dependency injection and configuration management (as indicated by property files and a Maven pom.xml) to handle build, settings, and environmental differences.

##### Technologies, Frameworks, and Other Elements
- Java with Maven (pom.xml) for project management.
- JavaFX for the User Interface (as seen through .fxml files and stylesheets in src/main/resources/iuh/fit/styles).
- JDBC or a similar library for database connectivity (implied by the database helper classes).
- SQL for database operations (along with dedicated SQL scripts).
- Security implementations (password hashing, property-based security configurations).

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Presentation Layer
    subgraph "Presentation Layer"
        UI["FXML Views (Login, Dashboard, Booking, Management, Invoicing, Backup, Statistics)"]:::presentation
    end

    %% Controller/Business Logic Layer
    subgraph "Controller/Business Logic Layer"
        CT["Controllers"]:::controllers
    end

    %% Data Access Layer
    subgraph "Data Access Layer"
        DAO["DAO Layer"]:::dao
    end

    %% Domain Model Layer
    subgraph "Domain Model Layer"
        DM["Model Layer"]:::models
    end

    %% Utility & Security Components
    subgraph "Utility & Security"
        UT["Utilities"]:::utility
        SEC["Security Services"]:::security
    end

    %% Configuration & Database Integration
    subgraph "Configuration & Database"
        CONF["Configuration (pom.xml, setting.properties)"]:::config
        SQL["SQL Scripts"]:::database
    end

    %% Connections
    UI -->|"triggers"| CT
    CT -->|"invokes"| DAO
    DAO -->|"manages"| DM

    CT -->|"uses"| UT
    CT -->|"uses"| SEC

    DAO -->|"uses"| UT
    DAO -->|"uses"| SEC

    CONF -->|"configures"| CT
    CONF -->|"configures"| DAO
    CONF -->|"configures"| SQL

    SQL -->|"executes on"| DAO

    %% Click Events
    click UI "https://github.com/huynhducphu2502/hotel-management/tree/main/src/main/resources/iuh/fit/view"
    click CT "https://github.com/huynhducphu2502/hotel-management/tree/main/src/main/java/iuh/fit/controller"
    click DAO "https://github.com/huynhducphu2502/hotel-management/tree/main/src/main/java/iuh/fit/dao"
    click DM "https://github.com/huynhducphu2502/hotel-management/tree/main/src/main/java/iuh/fit/models"
    click UT "https://github.com/huynhducphu2502/hotel-management/tree/main/src/main/java/iuh/fit/utils"
    click SEC "https://github.com/huynhducphu2502/hotel-management/tree/main/src/main/java/iuh/fit/security"
    click CONF "https://github.com/huynhducphu2502/hotel-management/blob/main/pom.xml"
    click SQL "https://github.com/huynhducphu2502/hotel-management/blob/main/sql_script/script_production_database.sql"

    %% Styles
    classDef presentation fill:#AEDFF7,stroke:#333,stroke-width:2px;
    classDef controllers fill:#F7E3AE,stroke:#333,stroke-width:2px;
    classDef dao fill:#FFD59E,stroke:#333,stroke-width:2px;
    classDef models fill:#D0F0C0,stroke:#333,stroke-width:2px;
    classDef utility fill:#CFE2F3,stroke:#333,stroke-width:2px;
    classDef security fill:#F4CCCC,stroke:#333,stroke-width:2px;
    classDef config fill:#FFF2CC,stroke:#333,stroke-width:2px;
    classDef database fill:#EAD1DC,stroke:#333,stroke-width:2px;
```
