# huynhducphu2502/hotel-management-lite architecture

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

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

## Overview

##### Project Identification
- Type & Purpose: This is a full-stack desktop Java application for hotel management. It supports multiple functionalities (customer management, employee management, room booking, service management, statistics, etc.) combined with a well-defined JavaFX user interface.
- Key Technologies: Java (with Maven as build tool via pom.xml), JavaFX (FXML files, CSS for styling), JPA (persistence.xml for database configuration) and SQL for database interaction. The clear separation of controllers, DAOs, models, and UI resources indicates an MVC (Model-View-Controller) and layered architecture.

##### Analyzing the File Structure
- Top-Level Organization:
- src/main/java: Contains Java source code arranged by packages such as “controller”, “dao”, “models”, “security”, “utils”, and “devtools”.
- sql folder: Contains SQL scripts that likely initialize or set up the database.
- pom.xml: The Maven build file, which confirms dependencies and project structure.
- Architectural Implications:
- Controllers: The “controller” package is subdivided into features and further into submodules (customer, employee, room, service, statistics), indicating dedicated controllers for each hotel management functionality.
- DAOs: The “dao” package encapsulates database access logic, suggesting a persistence layer that interacts with a database (likely through JPA).
- Models: The “models” package represents domain entities and enums, providing the business logic foundation.
- Persistence and Security: The presence of persistence.xml (in META-INF) and security utilities further support a layered architecture that handles data and security separately.

- Controller Layer: Feature-specific controllers (grouped by customer, employee, room, service, statistics).
- Service/DAO Layer: Data Access Objects and database interaction logic. This includes DAOs for accounts, customers, employees, rooms, services, etc.
- Business Logic / Domain Model: Models and enums that encapsulate business rules.
- Persistence / Database: The SQL scripts, configuration (persistence.xml), and connection helper utilities (e.g., DBHelper, EntityManagerUtil) that manage the database.
- Auxiliary Components: Security (PasswordHashing, PreferencesKey), Utilities (RegexChecker, Conversion Helpers), and Devtools for initializing sample data and testing.

- The Domain Model Layer should be depicted as the foundation that both the controllers and the DAO layer rely on.
- Connections indicating integration points for external configurations (such as sql scripts and persistence.xml) that bootstrap the database setup.

- Architectural Patterns and Design Principles:
- MVC Pattern: Separate responsibilities among Models, Views (FXML/CSS), and Controllers.
- Layered Architecture: Distinct separation between presentation, application (controller), business logic, and data access.
- Modularity: Divide functionalities into components like customer, employee, room, etc., which makes the system easier to maintain and extend.
- Use of Dependency Injection (implied through the use of DAO patterns and JPA persistence).

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% User Interface Layer
    subgraph "User Interface Layer"
        UI_FXML["FXML Views"]:::ui
        UI_CSS["CSS Styles"]:::ui
        UI_Features["Feature-specific UI Components"]:::ui
    end

    %% Controller Layer
    subgraph "Controller Layer"
        Main_Controllers["Main Controllers"]:::controller
        Feature_Controllers["Feature Controllers"]:::controller
    end

    %% Service/DAO Layer
    subgraph "Service/DAO Layer"
        DAO["DAO Layer"]:::dao
    end

    %% Business Domain
    subgraph "Business Domain"
        Domain_Model["Domain Model"]:::domain
    end

    %% Persistence/Database Layer
    subgraph "Persistence/Database Layer"
        Persistence_Config["Persistence Config"]:::persistence
        SQL_Scripts["SQL Scripts"]:::persistence
    end

    %% Security Layer
    subgraph "Security Layer"
        Security_Utilities["Security Utilities"]:::security
    end

    %% Auxiliary Components
    subgraph "Auxiliary Components"
        Utility_Classes["Utility Classes"]:::utils
        Devtools["Devtools"]:::utils
    end

    %% Flow Connections
    UI_FXML -->|"initiates"| Main_Controllers
    UI_CSS  -->|"initiates"| Main_Controllers
    UI_Features -->|"initiates"| Feature_Controllers

    Main_Controllers -->|"processes"| Feature_Controllers
    Main_Controllers -->|"calls"| DAO
    Feature_Controllers -->|"calls"| DAO

    Main_Controllers -->|"uses"| Domain_Model
    Feature_Controllers -->|"uses"| Domain_Model
    DAO -->|"manipulates"| Domain_Model
    DAO -->|"persists"| Persistence_Config
    DAO -->|"persists"| SQL_Scripts

    Main_Controllers -->|"secures"| Security_Utilities
    DAO -->|"utilizes"| Utility_Classes
    Devtools -->|"initializes"| Persistence_Config
    Devtools -->|"initializes"| SQL_Scripts

    %% Click Events
    click UI_FXML "https://github.com/huynhducphu2502/hotel-management-lite/tree/main/src/main/resources/iuh/fit/view/ui"
    click UI_CSS "https://github.com/huynhducphu2502/hotel-management-lite/tree/main/src/main/resources/iuh/fit/styles"
    click UI_Features "https://github.com/huynhducphu2502/hotel-management-lite/tree/main/src/main/resources/iuh/fit/view/features"
    click Main_Controllers "https://github.com/huynhducphu2502/hotel-management-lite/tree/main/src/main/java/iuh/fit/controller"
    click Feature_Controllers "https://github.com/huynhducphu2502/hotel-management-lite/tree/main/src/main/java/iuh/fit/controller/features"
    click DAO "https://github.com/huynhducphu2502/hotel-management-lite/tree/main/src/main/java/iuh/fit/dao"
    click Domain_Model "https://github.com/huynhducphu2502/hotel-management-lite/tree/main/src/main/java/iuh/fit/models"
    click Persistence_Config "https://github.com/huynhducphu2502/hotel-management-lite/blob/main/src/main/resources/META-INF/persistence.xml"
    click SQL_Scripts "https://github.com/huynhducphu2502/hotel-management-lite/blob/main/sql/script.sql"
    click Security_Utilities "https://github.com/huynhducphu2502/hotel-management-lite/tree/main/src/main/java/iuh/fit/security"
    click Utility_Classes "https://github.com/huynhducphu2502/hotel-management-lite/tree/main/src/main/java/iuh/fit/utils"
    click Devtools "https://github.com/huynhducphu2502/hotel-management-lite/tree/main/src/main/java/iuh/fit/devtools"

    %% Styles
    classDef ui fill:#B3E5FC,stroke:#039BE5,stroke-width:2px;
    classDef controller fill:#C8E6C9,stroke:#2E7D32,stroke-width:2px;
    classDef dao fill:#FFE0B2,stroke:#E65100,stroke-width:2px;
    classDef domain fill:#D1C4E9,stroke:#512DA8,stroke-width:2px;
    classDef persistence fill:#F0F4C3,stroke:#827717,stroke-width:2px;
    classDef security fill:#FFCDD2,stroke:#B71C1C,stroke-width:2px;
    classDef utils fill:#CFD8DC,stroke:#455A64,stroke-width:2px;
```
