# nguyenvananit/booking-hotel-frontend architecture

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

- Interactive diagram: https://gitdiagram.com/nguyenvananit/booking-hotel-frontend
- Repository: https://github.com/nguyenvananit/booking-hotel-frontend

## Overview

##### Project Type and Purpose
- This is a single-page front-end application (“Manage-Hotel-Frontend”) built in React and bundled by Vite.
- Its purpose is to provide a user interface for hotel management: user registration/login, room booking, staff management, services management, reporting/statistics, etc.

##### File Structure Analysis
- Top level:
- public, index.html – static assets and SPA entry point
- src – all React code, styles and configuration (main.jsx, App.jsx/CSS)
- vite.config.js, package*.json, eslint.config.js, vercel.json – build, lint, deploy configs
- src/components organized by functional domains:
- auth (AuthProvider, Login, Logout, RequireAuth, Profile, Registration)
- booking (BookingList, BookingForm, Checkout, Payment, BookingSuccess, etc.)
- room (DetailRoom, RoomListing, RoomCard, ServicesOfRoom, EditRoom)
- staff (StaffList, AddStaff, StaffTask, AssignWork/Task, TimeKeeping)
- service (ServiceList, AddService, ServiceInRoom)
- statistics (StatisticMain, StatisticRoom/Staff/Rate)
- user (UserList)
- common (DateSlider, Header, Parallax, Filters, Paginator, Modals, etc.)
- utils (ApiFunctions.js & domain-specific API wrappers: booking.js, room.js, staff.js, etc.)
- State management: uses React Context for authentication (AuthProvider) and likely local component state for other domains.

a. Front-End Components Layer
- Browser/Client running React SPA
- Main entry: index.html → main.jsx → App.jsx
- Component modules (Auth, Booking, Room, Staff, Service, Statistics, Common)
- Shared utilities: ApiFunctions.js wraps fetch/XHR to back-end endpoints
b. Build/Deployment Layer
- Vite Dev Server (HMR) for local development
- Build output (static JS/CSS) deployed to CDN or Vercel (per vercel.json)
c. External Services & Back-End
- Authentication service (internal API routes: /login, /register, /logout, /profile)
- Hotel management REST API (endpoints for rooms, bookings, staff, services, statistics)
- Database (MySQL/Postgres/Mongo) behind back-end
- Payment Gateway (calls from Checkout/Payment components)
d. Data Flow
1. User interacts with React components → triggers handlers in BookingForm, Login, etc.
2. Handlers call domain utils (e.g., booking.js → ApiFunctions.post('/bookings', data)).
3. API request goes over HTTP to back-end → database read/write → JSON response.
4. Response bubbles up to components → state updated → UI re-renders.
5. Auth flow uses AuthProvider and RequireAuth to guard routes.

##### Architectural Patterns & Principles
- Component-Based Architecture: UI broken into feature modules.
- Single Page Application (SPA) with client-side routing (implied via RequireAuth).
- Context API for cross-cutting concerns (authentication state).
- Separation of concerns: API calls isolated in utils folder.
- Deployment via static hosting (Vercel) and CDN.

##### Essential Details to Capture
- Context Provider boundary and protected routes (RequireAuth)
- Feature-based folder structure
- Utility layer that abstracts all HTTP calls
- Deployment targets (Vercel) and build tool (Vite)
- External dependencies (Payment Gateway, Auth service, DB)

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Browser Client
    subgraph "Browser / Client"
        direction TB
        subgraph "Core Entry Point"
            direction TB
            IndexHTML["index.html"]:::ui
            MainJSX["main.jsx"]:::ui
            AppJSX["App.jsx"]:::ui
            AppCSS["App.css"]:::ui
        end
        subgraph "Auth Module"
            direction TB
            AuthProvider["AuthProvider.jsx"]:::ui
            RequireAuth["RequireAuth.jsx"]:::ui
            Login["Login.jsx"]:::ui
            Logout["Logout.jsx"]:::ui
            Profile["Profile.jsx"]:::ui
            Registration["Registration.jsx"]:::ui
            CreateAccount["CreateAccount.jsx"]:::ui
        end
        subgraph "Booking Module"
            direction TB
            BookingList["BookingList.jsx"]:::ui
            BookingDetail["BookingDetail.jsx"]:::ui
            HistoryBooking["HistoryBooking.jsx"]:::ui
            SearchBooking["SearchBooking.jsx"]:::ui
            BookingForm["BookingForm.jsx"]:::ui
            Checkout["Checkout.jsx"]:::ui
            PaymentComp["Payment.jsx"]:::ui
            BookingSummary["BookingSummary.jsx"]:::ui
            BookingSuccess["BookingSuccess.jsx"]:::ui
        end
        subgraph "Room Module"
            direction TB
            RoomListing["RoomListing.jsx"]:::ui
            RoomCard["RoomCard.jsx"]:::ui
            ExistingRooms["ExistingRooms.jsx"]:::ui
            RoomComp["Room.jsx"]:::ui
            DetailRoom["DetailRoom.jsx"]:::ui
            EditRoom["EditRoom.jsx"]:::ui
            ServicesOfRoom["ServicesOfRoom.jsx"]:::ui
        end
        subgraph "Staff Module"
            direction TB
            StaffManage["StaffManage.jsx"]:::ui
            StaffList["StaffList.jsx"]:::ui
            AddStaff["AddStaff.jsx"]:::ui
            AssignWork["AssignWork.jsx"]:::ui
            AssignTask["AssignTask.jsx"]:::ui
            RoomTask["RoomTask.jsx"]:::ui
            StaffTask["StaffTask.jsx"]:::ui
            TimeKeeping["TimeKeeping.jsx"]:::ui
        end
        subgraph "Service Module"
            direction TB
            ServiceList["ServiceList.jsx"]:::ui
            AddService["AddService.jsx"]:::ui
            ServiceInRoom["ServiceInRoom.jsx"]:::ui
        end
        subgraph "Statistics Module"
            direction TB
            StatisticMain["StatisticMain.tsx"]:::ui
            StatisticRoom["StatisticRoom.jsx"]:::ui
            StatisticStaff["StatisticStaff.jsx"]:::ui
            StatisticRate["StatisticRate.jsx"]:::ui
        end
        subgraph "User Module"
            direction TB
            UserList["UserList.jsx"]:::ui
        end
        subgraph "Common & Layout"
            direction TB
            DateSlider["DateSlider.jsx"]:::ui
            Header["Header.jsx"]:::ui
            Parallax["Parallax.jsx"]:::ui
            OtpModal["OtpModal.jsx"]:::ui
            Policy["Policy.jsx"]:::ui
            RoomCarousel["RoomCarousel.jsx"]:::ui
            RoomFilters["RoomFilters.jsx"]:::ui
            RoomPaginator["RoomPaginator.jsx"]:::ui
            RoomSearch["RoomSearch.jsx"]:::ui
            RoomSearchResult["RoomSearchResult.jsx"]:::ui
            RoomSelectorModal["RoomSelectorModal.jsx"]:::ui
            RoomTypeSelector["RoomTypeSelector.jsx"]:::ui
            HotelService["HotelService.jsx"]:::ui
            MainHeader["MainHeader.jsx"]:::ui
            NavBar["NavBar.jsx"]:::ui
            Footer["Footer.jsx"]:::ui
        end
        subgraph "Home & Admin"
            direction TB
            Home["Home.jsx"]:::ui
            Admin["Admin.jsx"]:::ui
        end
        subgraph "Utils Layer"
            direction TB
            ApiFunctions["ApiFunctions.js"]:::api
            AuthUtils["auth.js"]:::api
            BookingUtils["booking.js"]:::api
            RoomUtils["room.js"]:::api
            StaffUtils["staff.js"]:::api
            ServicesUtils["services.js"]:::api
            RateUtils["rate.js"]:::api
            UserUtils["user.js"]:::api
            Helpers["helpers.js"]:::api
            Descriptions["descriptions.js"]:::api
            Toast["toast.js"]:::api
        end
    end

    %% Development & Deployment
    ViteDevServer["Vite Dev Server"]:::external
    CDNHosting["CDN / Vercel Hosting"]:::external

    %% Back-End & External
    subgraph "Back-End API" 
        direction TB
        AuthAPI["Auth API"]:::api
        BookingAPI["Booking API"]:::api
        RoomAPI["Room API"]:::api
        StaffAPI["Staff API"]:::api
        ServiceAPI["Service API"]:::api
        StatisticsAPI["Statistics API"]:::api
        UserAPI["User API"]:::api
    end
    PaymentGateway["Payment Gateway"]:::external
    Database[(Database)]:::db

    %% Data Flows
    IndexHTML --> MainJSX
    MainJSX --> AppJSX
    AppJSX --> AuthProvider
    AppJSX --> subgraphModules["Feature Modules"] 
    ApiFunctions --> AuthAPI
    ApiFunctions --> BookingAPI
    ApiFunctions --> RoomAPI
    ApiFunctions --> StaffAPI
    ApiFunctions --> ServiceAPI
    ApiFunctions --> StatisticsAPI
    ApiFunctions --> UserAPI

    Checkout --> PaymentGateway
    AuthAPI --> Database
    BookingAPI --> Database
    RoomAPI --> Database
    StaffAPI --> Database
    ServiceAPI --> Database
    StatisticsAPI --> Database
    UserAPI --> Database

    ViteDevServer -.-> IndexHTML
    CDNHosting -.-> IndexHTML

    %% Click Events
    click IndexHTML "https://github.com/nguyenvananit/booking-hotel-frontend/blob/main/public/index.html"
    click MainJSX "https://github.com/nguyenvananit/booking-hotel-frontend/blob/main/src/main.jsx"
    click AppJSX "https://github.com/nguyenvananit/booking-hotel-frontend/blob/main/src/App.jsx"
    click AppCSS "https://github.com/nguyenvananit/booking-hotel-frontend/blob/main/src/App.css"
    click AuthProvider "https://github.com/nguyenvananit/booking-hotel-frontend/blob/main/src/components/auth/AuthProvider.jsx"
    click RequireAuth "https://github.com/nguyenvananit/booking-hotel-frontend/blob/main/src/components/auth/RequireAuth.jsx"
    click Login "https://github.com/nguyenvananit/booking-hotel-frontend/blob/main/src/components/auth/Login.jsx"
    click Logout "https://github.com/nguyenvananit/booking-hotel-frontend/blob/main/src/components/auth/Logout.jsx"
    click Profile "https://github.com/nguyenvananit/booking-hotel-frontend/blob/main/src/components/auth/Profile.jsx"
    click Registration "https://github.com/nguyenvananit/booking-hotel-frontend/blob/main/src/components/auth/Registration.jsx"
    click CreateAccount "https://github.com/nguyenvananit/booking-hotel-frontend/blob/main/src/components/auth/CreateAccount.jsx"
    click BookingForm "https://github.com/nguyenvananit/booking-hotel-frontend/blob/main/src/components/booking/BookingForm.jsx"
    click Checkout "https://github.com/nguyenvananit/booking-hotel-frontend/blob/main/src/components/booking/Checkout.jsx"
    click PaymentComp "https://github.com/nguyenvananit/booking-hotel-frontend/blob/main/src/components/booking/Payment.jsx"
    click RoomListing "https://github.com/nguyenvananit/booking-hotel-frontend/blob/main/src/components/room/RoomListing.jsx"
    click DetailRoom "https://github.com/nguyenvananit/booking-hotel-frontend/blob/main/src/components/room/DetailRoom.jsx"
    click StaffList "https://github.com/nguyenvananit/booking-hotel-frontend/blob/main/src/components/staff/StaffList.jsx"
    click AddStaff "https://github.com/nguyenvananit/booking-hotel-frontend/blob/main/src/components/staff/AddStaff.jsx"
    click ServiceList "https://github.com/nguyenvananit/booking-hotel-frontend/blob/main/src/components/service/ServiceList.jsx"
    click StatisticMain "https://github.com/nguyenvananit/booking-hotel-frontend/blob/main/src/components/statistics/StatisticMain.tsx"
    click UserList "https://github.com/nguyenvananit/booking-hotel-frontend/blob/main/src/components/user/UserList.jsx"
    click Header "https://github.com/nguyenvananit/booking-hotel-frontend/blob/main/src/components/common/Header.jsx"
    click ApiFunctions "https://github.com/nguyenvananit/booking-hotel-frontend/blob/main/src/components/utils/ApiFunctions.js"
    click ViteDevServer "https://github.com/nguyenvananit/booking-hotel-frontend/blob/main/vite.config.js"
    click CDNHosting "https://github.com/nguyenvananit/booking-hotel-frontend/blob/main/vercel.json"

    %% Styles
    classDef ui fill:#cce5ff,stroke:#6699cc,stroke-width:1px
    classDef api fill:#ccffcc,stroke:#66cc66,stroke-width:1px
    classDef db fill:#ffcc99,stroke:#cc9933,stroke-width:1px
    classDef external fill:#ffebcc,stroke:#cc9933,stroke-width:1px
```
