# ledinhdat041203/hotelmanager-frontend architecture

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

- Interactive diagram: https://gitdiagram.com/ledinhdat041203/hotelmanager-frontend
- Repository: https://github.com/ledinhdat041203/hotelmanager-frontend

## Overview

##### Project type and purpose
- This is a single‑page application (SPA) built with Create React App.
- Its purpose appears to be a room‑booking management UI with pages for login, booking, room management, and booking details, communicating with a backend via RESTful API.

##### File structure
- Top‑level “public” holds static HTML and manifest; “src” holds all React code.
- “src/pages” implements screens (HomePage, LoginPage, BookingPage, BookingDetailPage, RoomManagementPage).
- “src/components” contains reusable UI pieces (Header, ProtectedRoute, modals, marginer, accountBox).
- “src/routes” defines client‑side routing.
- “src/api” and “src/services” encapsulate HTTP calls and business logic for auth and room‑type.
- “src/store” (UserContext) and “src/components/accountBox/accountContext” manage user and account state.
- “src/assets” holds images; “src/styles” contains CSS/JS style modules.
- Configuration files like package.json/.env indicate this is purely a front‑end which depends on external API endpoints defined in src/api/config.js.

##### README
- Confirms use of Create React App.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Browser
    Browser["Client Browser"]:::external

    %% Presentation Layer
    subgraph "Presentation Layer" 
        direction TB
        subgraph "Pages (src/pages)" 
            direction TB
            HomePage["HomePage"]:::presentation
            LoginPage["LoginPage"]:::presentation
            BookingPage["BookingPage"]:::presentation
            BookingDetailPage["BookingDetailPage"]:::presentation
            RoomManagementPage["RoomManagementPage"]:::presentation
        end
        subgraph "Components (src/components)" 
            direction TB
            Header["Header"]:::presentation
            ProtectedRoute["ProtectedRoute"]:::presentation
            subgraph "AccountBox (src/components/accountBox)"
                direction TB
                AccountContext["accountContext"]:::presentation
                AccountCommon["common"]:::presentation
                AccountIndex["index"]:::presentation
            end
            Marginer["Marginer"]:::presentation
            subgraph "Modals (src/components/modal)"
                direction TB
                BookingModal["BookingModal"]:::presentation
                CustomerModal["CustomerModal"]:::presentation
                RoomModal["RoomModal"]:::presentation
                RoomSelectionModal["RoomSelectionModal"]:::presentation
                RoomTypeModal["RoomTypeModal"]:::presentation
                ServiceModal["ServiceModal"]:::presentation
            end
        end
        Routing["Routing (src/routes/index.js)"]:::presentation
        UserContext["UserContext (src/store/UserContext.js)"]:::presentation
    end

    %% Service and API Layers
    subgraph "Service & API Layers"
        direction TB
        subgraph "Service Layer (src/services)"
            AuthService["Auth Service"]:::service
            RoomTypeService["Room-Type Service"]:::service
        end
        subgraph "API Layer (src/api)"
            ApiConfig["Config"]:::service
            AuthApi["Auth Endpoints"]:::service
            RoomTypeApi["Room-Type Endpoints"]:::service
        end
    end

    %% External Backend and DB
    subgraph "External Backend & Database"
        direction TB
        BackendApi["Backend API"]:::external
        Database["Database"]:::external
    end

    %% Assets & Styles
    subgraph "Assets & Styles"
        direction TB
        Public["Public Folder"]:::assets
        Images["Images"]:::assets
        GlobalStyles["globalStyles.js"]:::assets
        subgraph "Page Styles"
            BookingPageCss["BookingPage.css"]:::assets
            BookingDetailCss["BookingDetailPage.css"]:::assets
            RoomManagementCss["RoomManagementPage.css"]:::assets
            LoginPageStyles["LoginPageStyles.js"]:::assets
            HeaderCss["Header.css"]:::assets
            LayoutCss["Layout.css"]:::assets
        end
        ModalStyles["modal/*.css"]:::assets
        BookingCardStyles["booking/card.js"]:::assets
    end

    %% Connections
    Browser -->|"renders"| HomePage
    Browser -->|"renders"| LoginPage
    Browser -->|"renders"| BookingPage
    Browser -->|"renders"| BookingDetailPage
    Browser -->|"renders"| RoomManagementPage

    HomePage -->|"uses"| Header
    BookingPage -->|"uses"| BookingModal
    BookingPage -->|"uses"| RoomSelectionModal
    RoomManagementPage -->|"uses"| RoomModal
    RoomManagementPage -->|"uses"| RoomTypeModal
    RoomManagementPage -->|"uses"| ServiceModal
    BookingDetailPage -->|"uses"| CustomerModal

    PresentationLayerPages[Rend Pages] -->|navigate via| Routing
    Routing -->|"guards"| ProtectedRoute
    Routing -->|provides context| UserContext

    HomePage -->|dispatch| AuthService
    LoginPage -->|dispatch| AuthService
    BookingPage -->|dispatch| RoomTypeService
    RoomManagementPage -->|dispatch| RoomTypeService

    AuthService -->|calls| AuthApi
    RoomTypeService -->|calls| RoomTypeApi
    AuthApi -->|HTTP| ApiConfig
    RoomTypeApi -->|HTTP| ApiConfig

    AuthApi -->|REST| BackendApi
    RoomTypeApi -->|REST| BackendApi
    BackendApi -->|queries| Database

    %% Assets to Presentation
    Public -->|"assets"| Browser
    Images -->|used by| PresentationLayer
    GlobalStyles -->|applied to| PresentationLayer
    PageStyles -->|applied to| Pages
    ModalStyles -->|applied to| Modals
    BookingCardStyles -->|applied to| BookingModal

    %% Click Events
    click HomePage "https://github.com/ledinhdat041203/hotelmanager-frontend/blob/main/src/pages/HomePage.jsx"
    click LoginPage "https://github.com/ledinhdat041203/hotelmanager-frontend/blob/main/src/pages/LoginPage.jsx"
    click BookingPage "https://github.com/ledinhdat041203/hotelmanager-frontend/blob/main/src/pages/BookingPage.jsx"
    click BookingDetailPage "https://github.com/ledinhdat041203/hotelmanager-frontend/blob/main/src/pages/BookingDetailPage.jsx"
    click RoomManagementPage "https://github.com/ledinhdat041203/hotelmanager-frontend/blob/main/src/pages/RoomManagementPage.jsx"
    click Header "https://github.com/ledinhdat041203/hotelmanager-frontend/blob/main/src/components/Header.jsx"
    click ProtectedRoute "https://github.com/ledinhdat041203/hotelmanager-frontend/blob/main/src/components/ProtectedRoute.js"
    click AccountContext "https://github.com/ledinhdat041203/hotelmanager-frontend/blob/main/src/components/accountBox/accountContext.js"
    click AccountCommon "https://github.com/ledinhdat041203/hotelmanager-frontend/blob/main/src/components/accountBox/common.jsx"
    click AccountIndex "https://github.com/ledinhdat041203/hotelmanager-frontend/blob/main/src/components/accountBox/index.jsx"
    click Marginer "https://github.com/ledinhdat041203/hotelmanager-frontend/blob/main/src/components/marginer/index.jsx"
    click BookingModal "https://github.com/ledinhdat041203/hotelmanager-frontend/blob/main/src/components/modal/BookingModal.jsx"
    click CustomerModal "https://github.com/ledinhdat041203/hotelmanager-frontend/blob/main/src/components/modal/CustomerModal.jsx"
    click RoomModal "https://github.com/ledinhdat041203/hotelmanager-frontend/blob/main/src/components/modal/RoomModal.jsx"
    click RoomSelectionModal "https://github.com/ledinhdat041203/hotelmanager-frontend/blob/main/src/components/modal/RoomSelectionModal.jsx"
    click RoomTypeModal "https://github.com/ledinhdat041203/hotelmanager-frontend/blob/main/src/components/modal/RoomTypeModal.jsx"
    click ServiceModal "https://github.com/ledinhdat041203/hotelmanager-frontend/blob/main/src/components/modal/ServiceModal.jsx"
    click Routing "https://github.com/ledinhdat041203/hotelmanager-frontend/blob/main/src/routes/index.js"
    click UserContext "https://github.com/ledinhdat041203/hotelmanager-frontend/blob/main/src/store/UserContext.js"
    click ApiConfig "https://github.com/ledinhdat041203/hotelmanager-frontend/blob/main/src/api/config.js"
    click AuthApi "https://github.com/ledinhdat041203/hotelmanager-frontend/blob/main/src/api/auth.js"
    click RoomTypeApi "https://github.com/ledinhdat041203/hotelmanager-frontend/blob/main/src/api/room-type.js"
    click AuthService "https://github.com/ledinhdat041203/hotelmanager-frontend/blob/main/src/services/auth.js"
    click RoomTypeService "https://github.com/ledinhdat041203/hotelmanager-frontend/blob/main/src/services/room-type.js"
    click Public "https://github.com/ledinhdat041203/hotelmanager-frontend/tree/main/public/"
    click Images "https://github.com/ledinhdat041203/hotelmanager-frontend/tree/main/src/assets/images"
    click GlobalStyles "https://github.com/ledinhdat041203/hotelmanager-frontend/blob/main/src/styles/globalStyles.js"
    click BookingPageCss "https://github.com/ledinhdat041203/hotelmanager-frontend/blob/main/src/styles/BookingPage.css"
    click BookingDetailCss "https://github.com/ledinhdat041203/hotelmanager-frontend/blob/main/src/styles/BookingDetailPage.css"
    click RoomManagementCss "https://github.com/ledinhdat041203/hotelmanager-frontend/blob/main/src/styles/RoomManagementPage.css"
    click LoginPageStyles "https://github.com/ledinhdat041203/hotelmanager-frontend/blob/main/src/styles/LoginPageStyles.js"
    click HeaderCss "https://github.com/ledinhdat041203/hotelmanager-frontend/blob/main/src/styles/Header.css"
    click LayoutCss "https://github.com/ledinhdat041203/hotelmanager-frontend/blob/main/src/styles/Layout.css"
    click ModalStyles "https://github.com/ledinhdat041203/hotelmanager-frontend/tree/main/src/styles/modal/"
    click BookingCardStyles "https://github.com/ledinhdat041203/hotelmanager-frontend/blob/main/src/styles/booking/card.js"

    %% Styles
    classDef presentation fill:#ADD8E6,stroke:#000
    classDef service fill:#90EE90,stroke:#000
    classDef external fill:#FFA500,stroke:#000
    classDef assets fill:#D3D3D3,stroke:#000
```
