# aliasar1/hotel-management-system architecture

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

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

## Overview

##### Project type and purpose
- This is a Windows-Forms based desktop application written in C# (.NET Framework) that implements a Hotel Management System (HMS).
- It uses an MS SQL Server database (script: HotelManagementDB.sql) to persist hotels, bookings, guests, employees, rooms, services, discounts, payments, etc.
- The system supports a “SaaS-like” model: a super-admin provisions hotels (users), each hotel owner logs in, changes password, and exercises CRUD operations on all domain entities.

##### File structure
- Top-level solution (Hotel Management System.sln) and project folder with .csproj, App.config, Program.cs.
- DatabaseConnection.cs & Statics.cs serve as the data-access helper and constants layer.
- The “Screens” folder houses ~20 WinForms screens (Login, Dashboard, BookingsScreen, RoomsScreen, etc.) each split into Designer.cs, .cs, .resx.
- packages.config lists NuGet dependencies (if any) used in the project.

##### Key architecture insights from README
- Layers implied:
- Presentation (WinForms screens + Guna UI)
- Business logic (code-behind in each form + Statics)
- Data access (DatabaseConnection.cs)
- Database (MS SQL)
- Core CRUD features for all entities and aggregate reporting for bookings/revenue.

##### Main components
a. Presentation Layer (WinForms UI)
- Forms: Login, SuperAdminLogin, Create/Reset Password, SplashScreen, Dashboard, then domain screens (Hotels, Employees, Guests, Rooms, RoomTypes, Departments, Services, Discounts, Bookings, Payments, Reports)
- Guna UI Framework (external library)
b. Business Logic Layer (BLL)
- Form code-behind classes encapsulating validation, user-session management, business rules (e.g., calculating revenue, applying discounts)
- Statics.cs: shared constants, tokens for foreign-key workarounds
c. Data Access Layer (DAL)
- DatabaseConnection.cs: opens SQL connections, executes parameterized commands, returns DataSets or DataReaders
d. Database
- MS SQL Server instance with tables: Hotel, User (super-admin, hotel-admin, employees), Department, RoomType, Room, Service, Discount, Booking, Guest, Payment
- Relationships:
- Hotel 1–* Room, Employee, Service, Discount
- Employee 1–* Booking, Guest (via role)
- Booking *–1 Guest, *–1 Room, *–1 Discount
- Payment 1–1 Booking
e. External/Infrastructure
- App.config for connection strings
- SQL script for schema (HotelManagementDB.sql)
- Visual Studio IDE

##### Relationships and interactions
- User launches the WinForms app → SplashScreen → Login/SuperAdminLogin form
- On successful authentication, Dashboard loads; user clicks domain modules → corresponding Form instance
- Form code-behind calls DatabaseConnection methods to run SQL queries/stored procedures
- Results are displayed in DataGridViews or controls; business logic applies discount, calculates totals, updates Statics if needed
- CRUD operations modify the SQL Server database; triggers or constraints enforce data integrity
- Reports module queries aggregate data and renders summary to user

##### Architectural patterns and principles
- Layered architecture (UI → BLL → DAL → DB)
- Separation of concerns: each Form only handles presentation + direct calls to DAL; no UI SQL strings scattered in Dashboard.cs beyond DAL helper
- Basic n-tier approach; could be evolved into true Repository/Service patterns
- Use of configuration (App.config) for environment decoupling
- Token-based foreign key workaround (from Statics.cs) due to initial constraints

##### Technologies and frameworks
- .NET Framework (C#)
- Windows Forms + Guna UI controls
- MS SQL Server
- Visual Studio
- ADO.NET (SqlConnection, SqlCommand, DataAdapter)

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Presentation Layer
    subgraph "Presentation Layer" 
        direction TB
        Prog["Program.cs (Entry Point)"]:::ui
        Splash["SplashScreen.cs (UI)"]:::ui
        Dashboard["Dashboard.cs (UI)"]:::ui
        Login["Login.cs (UI)"]:::ui
        SuperAdminLogin["SuperAdminLogin.cs (UI)"]:::ui
        CreatePwd["CreatePassword.cs (UI)"]:::ui
        ResetPwd["ResetPassword.cs (UI)"]:::ui
        subgraph "Domain Module Screens"
            direction TB
            Hotels["HotelsScreen.cs"]:::ui
            AdminHotels["AdminHotelsView.cs"]:::ui
            Employees["EmployeesScreen.cs"]:::ui
            Guests["GuestsScreen.cs"]:::ui
            Departments["DepartmentsScreen.cs"]:::ui
            RoomTypes["RoomType.cs"]:::ui
            Rooms["RoomsScreen.cs"]:::ui
            Services["ServicesScreen.cs"]:::ui
            Discounts["DiscountScreen.cs"]:::ui
            Bookings["BookingsScreen.cs"]:::ui
            Payments["CheckoutScreen.cs"]:::ui
            HotelIntro["HotelIntroScreen.cs"]:::ui
            ShowDefault["ShowDefaultScreen.cs"]:::ui
        end
    end

    %% Business Logic Layer
    subgraph "Business Logic Layer"
        direction TB
        Statics["Statics.cs (Constants & Tokens)"]:::bll
    end

    %% Data Access Layer
    subgraph "Data Access Layer"
        direction TB
        DBConn["DatabaseConnection.cs (DAL Helper)"]:::dal
    end

    %% Database
    DB["MS SQL Server\n(Tables: Hotel, User, Department,\nRoomType, Room, Service, Discount,\nBooking, Guest, Payment)"]:::db

    %% Configuration & External
    AppConfig["App.config (Connection Strings)"]:::doc
    Packages["packages.config"]:::doc
    Guna["Guna DLL (UI Controls)"]:::ext
    Icons["Icons (Assets)"]:::ext
    SqlScript["HotelManagementDB.sql"]:::doc
    Solution["Hotel Management System.sln"]:::doc
    Csproj["Hotel Management System.csproj"]:::doc
    Properties["Properties (Assembly Settings)"]:::doc

    %% Connections
    Prog -->|launches| Splash
    Splash -->|1: Show Login| Login
    Splash -->|1: Show Super-Admin Login| SuperAdminLogin
    Login -->|2: Authenticates| Statics
    SuperAdminLogin -->|2: Authenticates| Statics
    Statics -->|calls| Dashboard
    Dashboard -->|opens module| Hotels
    Dashboard -->|opens module| Employees
    Dashboard -->|opens module| Guests
    Dashboard -->|opens module| Departments
    Dashboard -->|opens module| RoomTypes
    Dashboard -->|opens module| Rooms
    Dashboard -->|opens module| Services
    Dashboard -->|opens module| Discounts
    Dashboard -->|opens module| Bookings
    Dashboard -->|opens module| Payments
    Dashboard -->|opens module| HotelIntro
    Dashboard -->|opens module| ShowDefault

    Hotels -->|uses BLL| Statics
    Employees -->|uses BLL| Statics
    Guests -->|uses BLL| Statics
    Departments -->|uses BLL| Statics
    RoomTypes -->|uses BLL| Statics
    Rooms -->|uses BLL| Statics
    Services -->|uses BLL| Statics
    Discounts -->|uses BLL| Statics
    Bookings -->|uses BLL| Statics
    Payments -->|uses BLL| Statics
    HotelIntro -->|uses BLL| Statics
    ShowDefault -->|uses BLL| Statics

    Statics -->|calls DAL| DBConn
    Hotels -->|calls DAL| DBConn
    Employees -->|calls DAL| DBConn
    Guests -->|calls DAL| DBConn
    Departments -->|calls DAL| DBConn
    RoomTypes -->|calls DAL| DBConn
    Rooms -->|calls DAL| DBConn
    Services -->|calls DAL| DBConn
    Discounts -->|calls DAL| DBConn
    Bookings -->|calls DAL| DBConn
    Payments -->|calls DAL| DBConn
    HotelIntro -->|calls DAL| DBConn
    ShowDefault -->|calls DAL| DBConn

    DBConn -->|executes queries| DB

    AppConfig -->|provides config| DBConn
    Packages -->|NuGet refs| Prog
    Guna -->|UI library| Prog
    Icons -->|assets| Prog
    SqlScript -->|DB schema| DB
    Solution -->|project metadata| Prog
    Csproj -->|project file| Prog
    Properties -->|assembly info| Prog

    %% Click Events
    click Prog "https://github.com/aliasar1/hotel-management-system/blob/master/Hotel Management System/Program.cs"
    click Dashboard "https://github.com/aliasar1/hotel-management-system/blob/master/Hotel Management System/Dashboard.cs"
    click Splash "https://github.com/aliasar1/hotel-management-system/blob/master/Hotel Management System/SplashScreen.cs"
    click Login "https://github.com/aliasar1/hotel-management-system/blob/master/Hotel Management System/Login.cs"
    click SuperAdminLogin "https://github.com/aliasar1/hotel-management-system/blob/master/Hotel Management System/Screens/SuperAdminLogin.cs"
    click CreatePwd "https://github.com/aliasar1/hotel-management-system/blob/master/Hotel Management System/Screens/CreatePassword.cs"
    click ResetPwd "https://github.com/aliasar1/hotel-management-system/blob/master/Hotel Management System/Screens/ResetPassword.cs"
    click Hotels "https://github.com/aliasar1/hotel-management-system/blob/master/Hotel Management System/Screens/HotelsScreen.cs"
    click AdminHotels "https://github.com/aliasar1/hotel-management-system/blob/master/Hotel Management System/Screens/AdminHotelsView.cs"
    click Employees "https://github.com/aliasar1/hotel-management-system/blob/master/Hotel Management System/Screens/EmployeesScreen.cs"
    click Guests "https://github.com/aliasar1/hotel-management-system/blob/master/Hotel Management System/Screens/GuestsScreen.cs"
    click Departments "https://github.com/aliasar1/hotel-management-system/blob/master/Hotel Management System/Screens/DepartmentsScreen.cs"
    click RoomTypes "https://github.com/aliasar1/hotel-management-system/blob/master/Hotel Management System/Screens/RoomType.cs"
    click Rooms "https://github.com/aliasar1/hotel-management-system/blob/master/Hotel Management System/Screens/RoomsScreen.cs"
    click Services "https://github.com/aliasar1/hotel-management-system/blob/master/Hotel Management System/Screens/ServicesScreen.cs"
    click Discounts "https://github.com/aliasar1/hotel-management-system/blob/master/Hotel Management System/Screens/DiscountScreen.cs"
    click Bookings "https://github.com/aliasar1/hotel-management-system/blob/master/Hotel Management System/Screens/BookingsScreen.cs"
    click Payments "https://github.com/aliasar1/hotel-management-system/blob/master/Hotel Management System/Screens/CheckoutScreen.cs"
    click HotelIntro "https://github.com/aliasar1/hotel-management-system/blob/master/Hotel Management System/Screens/HotelIntroScreen.cs"
    click ShowDefault "https://github.com/aliasar1/hotel-management-system/blob/master/Hotel Management System/Screens/ShowDefaultScreen.cs"
    click Statics "https://github.com/aliasar1/hotel-management-system/blob/master/Hotel Management System/Statics.cs"
    click DBConn "https://github.com/aliasar1/hotel-management-system/blob/master/Hotel Management System/DatabaseConnection.cs"
    click AppConfig "https://github.com/aliasar1/hotel-management-system/blob/master/Hotel Management System/App.config"
    click Packages "https://github.com/aliasar1/hotel-management-system/blob/master/Hotel Management System/packages.config"
    click Guna "https://github.com/aliasar1/hotel-management-system/tree/master/Hotel Management System/Guna DLL"
    click Icons "https://github.com/aliasar1/hotel-management-system/tree/master/Hotel Management System/Icons"
    click SqlScript "https://github.com/aliasar1/hotel-management-system/blob/master/HotelManagementDB.sql"
    click Solution "https://github.com/aliasar1/hotel-management-system/blob/master/Hotel Management System.sln"
    click Csproj "https://github.com/aliasar1/hotel-management-system/blob/master/Hotel Management System/Hotel Management System.csproj"
    click Properties "https://github.com/aliasar1/hotel-management-system/tree/master/Hotel Management System/Properties"

    %% Styles
    classDef ui fill:#cce5ff,stroke:#004085,color:#004085
    classDef bll fill:#d4edda,stroke:#155724,color:#155724
    classDef dal fill:#fff3cd,stroke:#856404,color:#856404
    classDef db fill:#e2e3e5,stroke:#6c757d,color:#6c757d,stroke-dasharray: 5 5
    classDef doc fill:#f8d7da,stroke:#721c24,color:#721c24
    classDef ext fill:#d1ecf1,stroke:#0c5460,color:#0c5460
```
