# thainguyen86/hotel_managerment_frontend architecture

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

- Interactive diagram: https://gitdiagram.com/thainguyen86/hotel_managerment_frontend
- Repository: https://github.com/thainguyen86/hotel_managerment_frontend

## Overview

##### Project Type and Purpose
- This is a single-page application (SPA) built with Create React App.
- It serves as a hotel management dashboard, handling user auth, room booking, revenue reports, settings, and transactions.
- No server-side code lives here; the frontend communicates with external REST APIs.

##### File Structure
Top-level directories & files:
- public/ – static HTML entry point (index.html), PWA manifest, robots.txt
- src/ – React source code:
– context/ (NavBarItemContext)
– feature/NavBar (NavBarItem component)
– hook (useAuth)
– ui/ (layout & shared components: AppLayout, Header, NavBar, BookingForm)
– page/ (domain pages grouped by function: auth, dashboard, hotel, roomBook, roomSetting, transaction, user)
– service/apiServices.js (REST client) & utils/axiosCustomize.js
– App.js (root), index.js (render)
- Dockerfile, Jenkinsfile – containerization & CI/CD
- tailwind.config.js, postcss.config.js – styling pipeline

##### Key Insights from README
- Bootstrapped with Create React App (CRA)
- Standard CRA dev scripts (npm start, build, test, eject)
- No in-repo backend: all data flows through apiServices to external endpoints

##### Main Components & Their Relationships
- Browser (end user) – loads public/index.html → React app
- React Root (src/index.js → App.js)
– Provides global Context (NavBarItemContext)
– Wraps AppLayout (shell)
- UI Layer (src/ui)
– Header, NavBar, BookingForm, etc.
- Feature/Pages (src/page)
– Routing component (inside AppLayout) selects page by URL
– Auth pages call useAuth hook → apiServices
– Dashboard pages render charts & tables
– Hotel, RoomBooking, RoomSetting, Transaction, UserManagement pages
- Hooks & Context (src/hook + src/context)
– useAuth manages login state & tokens
– NavBarItemContext provides UI state for navigation
- Services (src/service)
– apiServices.js wraps REST calls (GET/POST/PUT/DELETE)
– axiosCustomize applies base URL, interceptors (auth headers, error handling)
- External REST API(s)
– Authentication service (JWT or session)
– Hotel/Room/Booking data endpoints
– Reporting endpoints
- CI/CD & Deployment
– Jenkins pipeline builds Docker image via Dockerfile
– Deployed container serves static build via NGINX or similar

##### Architectural Patterns & Principles
- Component-based UI (Presentational vs. Container)
- Context API for global state (NavBar, Auth status)
- Custom hooks for cross-cutting concerns (useAuth)
- Service layer abstracts HTTP calls
- Clear separation: UI → Pages → Services → External API

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Client
    Browser["Browser / Client"]:::external
    click Browser "https://github.com/thainguyen86/hotel_managerment_frontend/blob/main/public/index.html"

    %% React App Container
    subgraph "React App (Create React App)" 
        direction TB
        ReactRoot["React Root\n(src/index.js → App.js)"]:::frontend
        click ReactRoot "https://github.com/thainguyen86/hotel_managerment_frontend/blob/main/src/index.js"
        click ReactRoot "https://github.com/thainguyen86/hotel_managerment_frontend/blob/main/src/App.js"

        subgraph "Context & Hooks Layer"
            direction TB
            Context["NavBarItemContext\n(src/context/NavBarItemContext.jsx)"]:::frontend
            click Context "https://github.com/thainguyen86/hotel_managerment_frontend/blob/main/src/context/NavBarItemContext.jsx"
            Hook["useAuth Hook\n(src/hook/useAuth.jsx)"]:::frontend
            click Hook "https://github.com/thainguyen86/hotel_managerment_frontend/blob/main/src/hook/useAuth.jsx"
        end

        subgraph "UI Components Layer\n(src/ui)" 
            direction TB
            AppLayout["AppLayout"]:::frontend
            click AppLayout "https://github.com/thainguyen86/hotel_managerment_frontend/blob/main/src/ui/AppLayout.jsx"
            Header["Header"]:::frontend
            click Header "https://github.com/thainguyen86/hotel_managerment_frontend/blob/main/src/ui/Header.jsx"
            NavBar["NavBar"]:::frontend
            click NavBar "https://github.com/thainguyen86/hotel_managerment_frontend/blob/main/src/ui/NavBar.jsx"
            BookingForm["BookingForm"]:::frontend
            click BookingForm "https://github.com/thainguyen86/hotel_managerment_frontend/blob/main/src/ui/BookingForm.jsx"
        end

        subgraph "Page Components Layer\n(src/page)"
            direction TB

            subgraph "Auth Pages"
                SignUp["SignUp"]:::frontend
                click SignUp "https://github.com/thainguyen86/hotel_managerment_frontend/blob/main/src/page/auth/SignUp.jsx"
                LogIn["LogIn"]:::frontend
                click LogIn "https://github.com/thainguyen86/hotel_managerment_frontend/blob/main/src/page/auth/logIn.jsx"
            end

            subgraph "Dashboard Pages"
                DashBoard["DashBoard"]:::frontend
                click DashBoard "https://github.com/thainguyen86/hotel_managerment_frontend/blob/main/src/page/dashboard/DashBoard.jsx"
                RevenueReport["RevenueReport"]:::frontend
                click RevenueReport "https://github.com/thainguyen86/hotel_managerment_frontend/blob/main/src/page/dashboard/RevenueReport.js"
                RoomDensity["RoomDensityMonthly"]:::frontend
                click RoomDensity "https://github.com/thainguyen86/hotel_managerment_frontend/blob/main/src/page/dashboard/RoomDensityMonthly.js"
                RoomType["RoomTypeMonthly"]:::frontend
                click RoomType "https://github.com/thainguyen86/hotel_managerment_frontend/blob/main/src/page/dashboard/RoomTypeMonthly.js"
            end

            subgraph "Hotel Management"
                Hotel["Hotel"]:::frontend
                click Hotel "https://github.com/thainguyen86/hotel_managerment_frontend/blob/main/src/page/hotel/Hotel.jsx"
            end

            subgraph "Room Booking"
                RoomList["RoomList"]:::frontend
                click RoomList "https://github.com/thainguyen86/hotel_managerment_frontend/blob/main/src/page/roomBook/RoomList.jsx"
                BookingList["BookingList"]:::frontend
                click BookingList "https://github.com/thainguyen86/hotel_managerment_frontend/blob/main/src/page/roomBook/BookingList.jsx"
                RoomCheckout["RoomCheckout"]:::frontend
                click RoomCheckout "https://github.com/thainguyen86/hotel_managerment_frontend/blob/main/src/page/roomBook/RoomCheckout.jsx"
                RoomStatus["RoomStatus"]:::frontend
                click RoomStatus "https://github.com/thainguyen86/hotel_managerment_frontend/blob/main/src/page/roomBook/RoomStatus.jsx"
            end

            subgraph "Room Settings"
                CustomerType["CustomerType"]:::frontend
                click CustomerType "https://github.com/thainguyen86/hotel_managerment_frontend/blob/main/src/page/roomSetting/CustomerType.jsx"
                RoomTypeSetting["RoomType"]:::frontend
                click RoomTypeSetting "https://github.com/thainguyen86/hotel_managerment_frontend/blob/main/src/page/roomSetting/RoomType.jsx"
            end

            subgraph "Transactions"
                Transaction["Transaction"]:::frontend
                click Transaction "https://github.com/thainguyen86/hotel_managerment_frontend/blob/main/src/page/transaction/Transaction.jsx"
            end

            subgraph "User Management"
                UserManagement["UserManagement"]:::frontend
                click UserManagement "https://github.com/thainguyen86/hotel_managerment_frontend/blob/main/src/page/user/UserManagement.jsx"
            end
        end

        subgraph "Service Layer\n(src/service)" 
            direction TB
            APIService["apiServices.js"]:::service
            click APIService "https://github.com/thainguyen86/hotel_managerment_frontend/blob/main/src/service/apiServices.js"
            AxiosCustom["axiosCustomize.js"]:::service
            click AxiosCustom "https://github.com/thainguyen86/hotel_managerment_frontend/blob/main/src/service/utils/axiosCustomize.js"
        end
    end

    %% External APIs
    ExternalAPI["External REST APIs"]:::external
    %% Infrastructure
    subgraph "CI/CD & Deployment"
        direction TB
        Jenkins["Jenkins Pipeline"]:::infra
        click Jenkins "https://github.com/thainguyen86/hotel_managerment_frontend/tree/main/Jenkinsfile"
        DockerfileNode["Dockerfile"]:::infra
        click DockerfileNode "https://github.com/thainguyen86/hotel_managerment_frontend/tree/main/Dockerfile"
        Container["Deployed Container"]:::infra
    end

    %% Data & Control Flows
    Browser -->|"loads index.html"| ReactRoot
    ReactRoot --> Context
    ReactRoot --> Hook
    ReactRoot --> AppLayout
    ReactRoot --> Pages
    ReactRoot --> APIService
    Context --> AppLayout
    Context --> Pages
    Hook --> APIService
    AppLayout --> Pages
    Pages --> APIService
    APIService -->|HTTP Requests| ExternalAPI
    ExternalAPI -->|HTTP Responses| APIService

    Jenkins --> DockerfileNode
    DockerfileNode --> Container

    %% Styles
    classDef frontend fill:#E0F2FF,stroke:#0288D1,stroke-width:1px;
    classDef service fill:#E8F5E9,stroke:#2E7D32,stroke-width:1px;
    classDef infra fill:#FFF3E0,stroke:#EF6C00,stroke-width:1px;
    classDef external fill:#F5F5F5,stroke:#9E9E9E,stroke-width:1px;
```
