# aricchong12/oop-project architecture

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

- Interactive diagram: https://gitdiagram.com/aricchong12/oop-project
- Repository: https://github.com/aricchong12/oop-project

## Overview

##### Project type & purpose (what you’re diagramming)
This is a **Java desktop Hotel Management System (HMS)** built with **MVC**:
- **View:** Java Swing UI screens (`View/*`)
- **Controller:** user-action handlers + orchestration (`Controller/*`)
- **Model:** domain entities (`Model/*`)
- **Database:** DB access layer (`Database/Database.java`) against a relational schema (`hotel_management_system.sql`)
Primary use cases implied by file names: **login/register**, **room status**, **check-in/check-out**, **booking**, **payment**.

##### What the file tree tells you (architectural boundaries)
Top-level modules are already cleanly separated:

##### View (Swing UI)
- `Welcome`, `Login`, `Register`
- `MainFrame` (likely main window / navigation shell)
- `RoomStatus`
- `CheckIn`, `CheckOut`
- `Success` (confirmation screen)
These are UI “components” that produce events (button clicks, form submits) and display results.

##### Controller (application orchestration)
- `CustomerController` (auth/registration/customer profile)
- `RoomController` (availability/status updates)
- `BookingController` (check-in/check-out logic likely maps here)
- `PaymentController` (billing/payment operations)
Controllers should be drawn as the **application/service layer** that sits between UI and DB.

##### Model (domain/entities)
- `Customer`, `Room`, `Booking`, `Payment`
These represent records/tables and in-memory objects.

##### Database (data access)
- `Database/Database.java` is the single visible DB boundary. It probably provides:
- connection management (JDBC)
- query/execute helpers
- transaction boundaries (if implemented)
This is your **persistence layer**.

##### SQL schema

The README explicitly states:
- MVC separation
- Controllers “manage transactions, update models, and coordinate database operations”
So emphasize:
- **unidirectional dependency:** View → Controller → Database
- **Models are shared types** across layers (Views may hold/consume them, Controllers definitely construct/update them, Database maps rows ↔ models)

##### Relational Database

- **Desktop Client (JVM)**: contains View + Controller + Model + Database.java
- **DB Server**: contains the relational database engine + schema

##### Important architectural patterns to highlight
- **MVC** as the primary pattern.
- **Layered architecture** inside the desktop app:
- Presentation (Swing Views)
- Application/Control (Controllers)
- Domain (Models)
- Persistence (Database.java + SQL DB)
- If `Database.java` is a single gateway, call it out as a **“Database Gateway / Repository-like helper”** (even if it’s not a strict repository pattern).

- **Java Swing** on the View boundary
- **Java (JVM)** on the client boundary
- **JDBC** (likely) between `Database.java` and the RDBMS

##### Clear labels for each component

- Desktop App (contains View/Controller/Model/Database helper)
- SQL Database (external)

- Which Views talk to which Controllers
- Controllers using `Database.java`
- `Database.java` mapping to Models and persisting to DB tables

This satisfies “don’t overthink it” while still maximizing component separation and traceability to the actual repo.

**Views → Controllers**
- `Welcome` → (navigation to) `Login` / `Register`
- `Login` → `CustomerController`
- `Register` → `CustomerController`
- `MainFrame` → (hosts) `RoomStatus`, `CheckIn`, `CheckOut`
- `RoomStatus` → `RoomController`
- `CheckIn` → `BookingController` (and `RoomController` if room assignment is separate)
- `CheckOut` → `BookingController` + `PaymentController`
- `Success` ← result/confirmation from Controllers

**Controllers → Models**
- `CustomerController` ↔ `Customer`
- `RoomController` ↔ `Room`
- `BookingController` ↔ `Booking`, `Room`, `Customer`
- `PaymentController` ↔ `Payment`, `Booking`, `Customer`

**Controllers → Database**
- All Controllers → `Database.java` → SQL Database

## Diagram (Mermaid)

```mermaid
flowchart TD
  %% =========================
  %% High-level Container View
  %% =========================
  subgraph "Container Diagram (High Level)"
    direction TB

    subgraph "Desktop Client (Java JVM)"
      direction TB
      C_App["Hotel Management System (Desktop App)"]:::container
    end

    DBMS[("SQL Database\n(Relational RDBMS)")]:::db

    C_App -->|"JDBC queries/transactions"| DBMS
  end

  %% ==================================
  %% Detailed Component/Layers Diagram
  %% ==================================
  subgraph "Component Diagram (MVC Layers)"
    direction TB

    %% ---- View Layer ----
    subgraph "View Layer (Java Swing)"
      direction TB
      V_Dir["View/ (Swing UI Package)"]:::dir

      V_Welcome["Welcome"]:::view
      V_Login["Login"]:::view
      V_Register["Register"]:::view
      V_MainFrame["MainFrame\n(Navigation Shell)"]:::view
      V_RoomStatus["RoomStatus"]:::view
      V_CheckIn["CheckIn"]:::view
      V_CheckOut["CheckOut"]:::view
      V_Success["Success\n(Confirmation)"]:::view

      V_Dir --> V_Welcome
      V_Dir --> V_Login
      V_Dir --> V_Register
      V_Dir --> V_MainFrame
      V_Dir --> V_RoomStatus
      V_Dir --> V_CheckIn
      V_Dir --> V_CheckOut
      V_Dir --> V_Success

      V_Welcome -->|"navigateTo"| V_Login
      V_Welcome -->|"navigateTo"| V_Register

      V_MainFrame -->|"hosts"| V_RoomStatus
      V_MainFrame -->|"hosts"| V_CheckIn
      V_MainFrame -->|"hosts"| V_CheckOut
    end

    %% ---- Controller Layer ----
    subgraph "Controller Layer (Application Orchestration)"
      direction TB
      C_Dir["Controller/ (Controllers Package)"]:::dir

      C_Customer["CustomerController\n(auth/registration/customer ops)"]:::controller
      C_Room["RoomController\n(room availability/status)"]:::controller
      C_Booking["BookingController\n(check-in/check-out/booking logic)"]:::controller
      C_Payment["PaymentController\n(billing/payment logic)"]:::controller

      C_Dir --> C_Customer
      C_Dir --> C_Room
      C_Dir --> C_Booking
      C_Dir --> C_Payment
    end

    %% ---- Domain Model Layer ----
    subgraph "Domain Model Layer (Entities)"
      direction TB
      M_Dir["Model/ (Entities Package)"]:::dir

      M_Customer["Customer"]:::model
      M_Room["Room"]:::model
      M_Booking["Booking"]:::model
      M_Payment["Payment"]:::model

      M_Dir --> M_Customer
      M_Dir --> M_Room
      M_Dir --> M_Booking
      M_Dir --> M_Payment
    end

    %% ---- Persistence Layer ----
    subgraph "Persistence Layer"
      direction TB
      P_Dir["Database/ (Data Access Package)"]:::dir
      P_DB["Database.java\n(Database Gateway / JDBC Helper)"]:::persistence
      P_Dir --> P_DB
    end

    %% ---- Schema ----
    subgraph "SQL Schema"
      direction TB
      S_SQL["hotel_management_system.sql\n(DDL/Seed)"]:::schema
      T_Customers[("customers")]:::table
      T_Rooms[("rooms")]:::table
      T_Bookings[("bookings")]:::table
      T_Payments[("payments")]:::table

      S_SQL -->|"defines"| T_Customers
      S_SQL -->|"defines"| T_Rooms
      S_SQL -->|"defines"| T_Bookings
      S_SQL -->|"defines"| T_Payments
    end

    %% =======================
    %% View -> Controller flow
    %% =======================
    V_Login -->|"authenticate"| C_Customer
    V_Register -->|"createCustomer"| C_Customer

    V_RoomStatus -->|"listRooms/availability"| C_Room

    V_CheckIn -->|"createBooking/assignRoom"| C_Booking
    V_CheckIn -->|"roomSelection/status"| C_Room

    V_CheckOut -->|"closeBooking"| C_Booking
    V_CheckOut -->|"settleBill"| C_Payment

    %% Success confirmations
    C_Customer -->|"success/failure"| V_Success
    C_Booking -->|"success/failure"| V_Success
    C_Payment -->|"success/failure"| V_Success

    %% =======================
    %% Controller -> Model use
    %% =======================
    C_Customer <-->|"create/update/validate"| M_Customer
    C_Room <-->|"read/updateStatus"| M_Room
    C_Booking <-->|"create/update"| M_Booking
    C_Booking <-->|"assign/update"| M_Room
    C_Booking <-->|"lookup/attach"| M_Customer
    C_Payment <-->|"create/update"| M_Payment
    C_Payment <-->|"reference"| M_Booking
    C_Payment <-->|"reference"| M_Customer

    %% ==========================
    %% Controller -> Persistence
    %% ==========================
    C_Customer -->|"SELECT/INSERT customers"| P_DB
    C_Room -->|"SELECT/UPDATE rooms"| P_DB
    C_Booking -->|"INSERT/UPDATE bookings"| P_DB
    C_Booking -->|"UPDATE roomStatus"| P_DB
    C_Payment -->|"INSERT payments"| P_DB

    %% ==========================
    %% Persistence <-> Model map
    %% ==========================
    P_DB <-->|"Row↔Entity mapping"| M_Customer
    P_DB <-->|"Row↔Entity mapping"| M_Room
    P_DB <-->|"Row↔Entity mapping"| M_Booking
    P_DB <-->|"Row↔Entity mapping"| M_Payment

    %% ==========================
    %% Persistence -> DB + Tables
    %% ==========================
    P_DB -->|"JDBC"| DBMS
    DBMS -->|"stores"| T_Customers
    DBMS -->|"stores"| T_Rooms
    DBMS -->|"stores"| T_Bookings
    DBMS -->|"stores"| T_Payments

    %% ==========================
    %% Model <-> Table alignment
    %% ==========================
    M_Customer -.->|"mapsTo"| T_Customers
    M_Room -.->|"mapsTo"| T_Rooms
    M_Booking -.->|"mapsTo"| T_Bookings
    M_Payment -.->|"mapsTo"| T_Payments
  end

  %% ============
  %% Click Events
  %% ============
  click V_Dir "https://github.com/aricchong12/oop-project/tree/main/View/"
  click V_Welcome "https://github.com/aricchong12/oop-project/blob/main/View/Welcome.java"
  click V_Login "https://github.com/aricchong12/oop-project/blob/main/View/Login.java"
  click V_Register "https://github.com/aricchong12/oop-project/blob/main/View/Register.java"
  click V_MainFrame "https://github.com/aricchong12/oop-project/blob/main/View/MainFrame.java"
  click V_RoomStatus "https://github.com/aricchong12/oop-project/blob/main/View/RoomStatus.java"
  click V_CheckIn "https://github.com/aricchong12/oop-project/blob/main/View/CheckIn.java"
  click V_CheckOut "https://github.com/aricchong12/oop-project/blob/main/View/CheckOut.java"
  click V_Success "https://github.com/aricchong12/oop-project/blob/main/View/Success.java"

  click C_Dir "https://github.com/aricchong12/oop-project/tree/main/Controller/"
  click C_Customer "https://github.com/aricchong12/oop-project/blob/main/Controller/CustomerController.java"
  click C_Room "https://github.com/aricchong12/oop-project/blob/main/Controller/RoomController.java"
  click C_Booking "https://github.com/aricchong12/oop-project/blob/main/Controller/BookingController.java"
  click C_Payment "https://github.com/aricchong12/oop-project/blob/main/Controller/PaymentController.java"

  click M_Dir "https://github.com/aricchong12/oop-project/tree/main/Model/"
  click M_Customer "https://github.com/aricchong12/oop-project/blob/main/Model/Customer.java"
  click M_Room "https://github.com/aricchong12/oop-project/blob/main/Model/Room.java"
  click M_Booking "https://github.com/aricchong12/oop-project/blob/main/Model/Booking.java"
  click M_Payment "https://github.com/aricchong12/oop-project/blob/main/Model/Payment.java"

  click P_Dir "https://github.com/aricchong12/oop-project/tree/main/Database/"
  click P_DB "https://github.com/aricchong12/oop-project/blob/main/Database/Database.java"

  click S_SQL "https://github.com/aricchong12/oop-project/blob/main/hotel_management_system.sql"

  %% ======
  %% Styles
  %% ======
  classDef container fill:#E6F4FF,stroke:#1D4ED8,stroke-width:2px,color:#0B2A4A;
  classDef view fill:#DBEAFE,stroke:#2563EB,stroke-width:1.5px,color:#0B2A4A;
  classDef controller fill:#FFEDD5,stroke:#EA580C,stroke-width:1.5px,color:#4A1D0B;
  classDef model fill:#DCFCE7,stroke:#16A34A,stroke-width:1.5px,color:#0B3A1C;
  classDef persistence fill:#E5E7EB,stroke:#374151,stroke-width:1.5px,color:#111827;
  classDef db fill:#111827,stroke:#000000,stroke-width:2px,color:#FFFFFF;
  classDef table fill:#0B1220,stroke:#111827,stroke-width:1.5px,color:#FFFFFF;
  classDef schema fill:#F3F4F6,stroke:#6B7280,stroke-width:1.5px,color:#111827;
  classDef dir fill:#EEF2FF,stroke:#4338CA,stroke-dasharray:4 3,stroke-width:1.2px,color:#1F2937;
```
