# nguyennguyen0/huongbien architecture

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

- Interactive diagram: https://gitdiagram.com/nguyennguyen0/huongbien
- Repository: https://github.com/nguyennguyen0/huongbien

## Overview

##### Project Type & Purpose
- The project is a Java-based desktop application that manages restaurant operations (table booking, customer management, order processing, invoicing, and statistics). It uses JavaFX for the presentation layer and connects to SQL Server as the database.
- The README clarifies that the project is a software development course assignment aimed at optimizing restaurant management processes.

##### Analyzing the File Structure
- The top-level structure shows a Maven project with a pom.xml file and directories like src/main/java and src/main/resources.
- The code is organized into several packages, each serving a distinct layer or purpose:
- The “ui” package holds all JavaFX UI classes and FXML files that define the presentation layer (layouts, controllers).
- The “bus” package contains business logic classes (e.g., AccountBUS, OrderBUS) that process application rules.
- The “dao” package provides data access objects for persistence operations on entities.
- The “entity” package defines the domain models (such as Account, Customer, Order).
- The “config” package holds configuration classes – global settings, constants and variable definitions.
- The “database” package manages the database connection and contains helper classes that abstract the SQL operations.
- Additional packages like “service” wrap integration with external APIs (e.g., EmailService, ProvinceAPI, QRCodeHandler).
- The “database/datafaker” package facilitates testing by generating fake data.
- There is an “sql” folder with SQL scripts for setting up the database.
- This clear layered separation suggests an MVC-like (or layered) pattern where the UI (presentation layer) interacts with the bus (business logic), which in turn uses the dao (data access) connected to the SQL Server database.

##### Putting It All Together
1. The top layer: UI (JavaFX screens and controllers).
2. The middle layer: Business Logic (bus/package classes) and the Domain Model (entity classes).
3. The lower layer: Data Access (DAO package) and the Database (SQL Server).
4. Side components: External services and configuration/utility modules.
- Links from business logic to external components (e.g., email, secure APIs) indicating integration touchpoints.
- Configuration dependencies separately, noting that project settings (including VM and library configurations) support the entire environment.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Presentation Layer
    subgraph "Presentation Layer (UI)"
        UI1("RestaurantLoginGUI"):::ui
        UI2("RestaurantMainManagerGUI"):::ui
        UI3("RestaurantMainStaffGUI"):::ui
        UI4("UI Controllers"):::ui
        UI5("FXML & CSS Resources"):::ui
    end

    %% Business Logic Layer
    subgraph "Business Logic (BUS Layer)"
        BUS("BUS Services"):::bus
    end

    %% Domain Model Layer
    subgraph "Domain Model (Entities)"
        Entities("Entity Classes"):::domain
    end

    %% Data Access Layer
    subgraph "Data Access (DAO Layer)"
        DAO("DAO Classes"):::dao
    end

    %% Database
    DB("SQL Server Database"):::db

    %% External Services
    subgraph "External Services"
        Ext("External Service Integrations"):::external
    end

    %% Configuration & Utilities
    subgraph "Configuration & Utilities"
        Config("Configuration & Global Settings"):::config
        DBUtils("Database Connection & SQL Helpers"):::config
    end

    %% Data Faker for Testing
    Faker("Data Faker (Testing)"):::faker

    %% Relationships
    UI4 -->|"action/event"| BUS
    BUS -->|"process_domain"| Entities
    BUS -->|"DAO_call"| DAO
    DAO -->|"SQL_operations"| DB
    DAO -->|"data_mapping"| Entities
    BUS -->|"integration_call"| Ext
    Ext -->|"integration_call"| BUS
    BUS -->|"config_dependency"| Config
    DBUtils -->|"connection_management"| DB
    Faker -->|"populate_test_data"| DB

    %% Click Events 
    click UI1 "https://github.com/nguyennguyen0/huongbien/blob/main/src/main/java/com/huongbien/ui/RestaurantLoginGUI.java"
    click UI2 "https://github.com/nguyennguyen0/huongbien/blob/main/src/main/java/com/huongbien/ui/RestaurantMainManagerGUI.java"
    click UI3 "https://github.com/nguyennguyen0/huongbien/blob/main/src/main/java/com/huongbien/ui/RestaurantMainStaffGUI.java"
    click UI4 "https://github.com/nguyennguyen0/huongbien/tree/main/src/main/java/com/huongbien/ui/controller"
    click UI5 "https://github.com/nguyennguyen0/huongbien/tree/main/src/main/resources/com/huongbien/fxml"
    click UI5 "https://github.com/nguyennguyen0/huongbien/tree/main/src/main/resources/com/huongbien/css"
    click BUS "https://github.com/nguyennguyen0/huongbien/tree/main/src/main/java/com/huongbien/bus"
    click DAO "https://github.com/nguyennguyen0/huongbien/tree/main/src/main/java/com/huongbien/dao"
    click Entities "https://github.com/nguyennguyen0/huongbien/tree/main/src/main/java/com/huongbien/entity"
    click DBUtils "https://github.com/nguyennguyen0/huongbien/tree/main/src/main/java/com/huongbien/database"
    click DB "https://github.com/nguyennguyen0/huongbien/tree/main/src/main/sql"
    click Ext "https://github.com/nguyennguyen0/huongbien/tree/main/src/main/java/com/huongbien/service"
    click Config "https://github.com/nguyennguyen0/huongbien/tree/main/src/main/java/com/huongbien/config"
    click Faker "https://github.com/nguyennguyen0/huongbien/tree/main/src/main/java/com/huongbien/database/datafaker"

    %% Styles
    classDef ui fill:#CDE7FF,stroke:#000,stroke-width:1px;
    classDef bus fill:#C6F1C6,stroke:#000,stroke-width:1px;
    classDef domain fill:#E1C6F1,stroke:#000,stroke-width:1px;
    classDef dao fill:#FFD8A8,stroke:#000,stroke-width:1px;
    classDef db fill:#FFEBA1,stroke:#000,stroke-width:1px;
    classDef external fill:#F9F7A1,stroke:#000,stroke-width:1px;
    classDef config fill:#CDE1F9,stroke:#000,stroke-width:1px;
    classDef faker fill:#E0E0E0,stroke:#000,stroke-width:1px;
```
