# daswsi-utp/hotelreservapp-front architecture

> Architecture diagram of the GitHub repository daswsi-utp/hotelreservapp-front, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-05-13). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/daswsi-utp/hotelreservapp-front
- Repository: https://github.com/daswsi-utp/hotelreservapp-front

## Overview

##### Project type and purpose
- This is a full-stack Hotel Booking System whose repository contains the React.js front-end (SPA) and a “bd” folder with SQL scripts for the hotel database.
- The README confirms it’s a web application built with React, Vite, Tailwind CSS, and it uses a SQL database (bd_hotel.sql).

##### File structure
- Top-level:
- public/index.html, public/img/… – static assets, favicon, logo
- src/main.jsx – entry point bootstrapping React/Vite
- src/App.jsx – root component and router setup
- src/components – reusable UI components (admin vs common vs guest)
- src/pages – page-level views (login, admin dashboard, guest booking, rooms, etc.)
- src/context/AuthContext.jsx – global auth state provider
- src/data/roomsData.js – static seed data or mock data
- bd folder: SQL schema and queries for the database.

##### README for additional insights
- Uses React Router for client-side routing
- Tailwind CSS for styling
- React Confetti for UI effect
- No back-end code here; expect a separate REST API and a SQL database.

a. Main components
- Client (Browser)
- React SPA (Vite build)
- Routes: /login, /guest/…, /admin/…
- Components: AuthContext, UI components, pages
- API Server (external microservice)
- REST endpoints for authentication, rooms CRUD, reservations, messages, promotions, users
- Security: JWT or session-based auth
- Database
- PostgreSQL (bd_hotel.sql) or another relational DB
- Tables: Users, Rooms, Reservations, Messages, Promotions, etc.
- (Optional) CDN / Static hosting
- Host built SPA assets on Netlify, Vercel, S3/CloudFront
- (Optional) Third-party services
- Email/SMS service for booking confirmations
- Analytics or monitoring (Sentry, LogRocket)

b. Relationships and interactions
- Browser → SPA (static files served over HTTPS)
- SPA → API Server (HTTP/HTTPS calls)
- AuthContext injects JWT into headers
- Pages call GET /rooms, POST /reservations, GET /admin/users, etc.
- API Server → Database (TCP connection)
- SQL queries defined in bd_hotel.sql
- (If used) CDN caches static assets; API calls bypass CDN to origin.

c. Architectural patterns & design principles
- SPA with client-side routing (React Router)
- Context API for state management (AuthContext)
- Component-based UI hierarchy (atoms, molecules, pages)
- RESTful API design on the back-end
- Layering: presentation (React), application (API), data (database)

d. Key technologies/frameworks
- Front-end: React, Vite, Tailwind CSS, React Router, React Context
- Build & deploy: npm scripts, Vercel/Netlify or S3 + CloudFront
- Back-end (assumed): Node.js/Express or Java/Spring Boot
- Database: PostgreSQL (bd_hotel.sql)

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Layers
    Browser["Browser"]:::infra
    subgraph "React SPA (UI Layer)"
        direction TB
        main["src/main.jsx"]:::ui
        app["src/App.jsx"]:::ui
        auth["src/context/AuthContext.jsx"]:::ui
        subgraph "Components"
            direction TB
            adminComp["src/components/admin"]:::ui
            commonComp["src/components/common"]:::ui
            adminLayout["AdminLayout.jsx"]:::ui
            sidebar["Sidebar.jsx"]:::ui
            statCard["StatCard.jsx"]:::ui
            btn["Button.jsx"]:::ui
            header["Header.jsx"]:::ui
            footer["Footer.jsx"]:::ui
            roomCard["RoomCard.jsx"]:::ui
        end
        subgraph "Pages"
            direction TB
            guestDir["src/pages/guest"]:::ui
            homePage["HomePage.jsx"]:::ui
            roomsPage["RoomsPage.jsx"]:::ui
            detailPage["RoomDetailPage.jsx"]:::ui
            bookingPage["BookingPage.jsx"]:::ui
            adminDir["src/pages/admin"]:::ui
            dashboardPage["DashboardPage.jsx"]:::ui
            roomsMgmt["RoomsManagementPage.jsx"]:::ui
            addRoom["AddRoomPage.jsx"]:::ui
            editRoom["EditRoomPage.jsx"]:::ui
            reservationsPage["ReservationsPage.jsx"]:::ui
            messagesPage["MessagesPage.jsx"]:::ui
            promotionsPage["PromotionsPage.jsx"]:::ui
            usersPage["UsersPage.jsx"]:::ui
        end
        data["src/data/roomsData.js"]:::ui
        publicDir["public"]:::ui
        publicIndex["index.html"]:::ui
        readme["README.md"]:::ui
        pkg["package.json"]:::ui
        bdDir["bd"]:::ui
        schema["bd_hotel.sql"]:::ui
        query["Query_BD.txt"]:::ui
    end

    subgraph "API Server (Backend Layer)"
        direction TB
        AuthService["Auth Service\n(POST /login, JWT)"]:::api
        RoomsService["Rooms Service\n(GET/POST/PUT /rooms)"]:::api
        ReservationsService["Reservations Service\n(POST /reservations)"]:::api
        UsersService["Users Service\n(GET/POST /users)"]:::api
        MessagesService["Messages Service\n(GET/POST /messages)"]:::api
        PromotionsService["Promotions Service\n(GET/POST /promotions)"]:::api
    end

    subgraph "Database (Data Layer)"
        direction TB
        DB[(HotelDB)]:::db
        UsersTable["Users"]:::db
        RoomsTable["Rooms"]:::db
        ReservationsTable["Reservations"]:::db
        MessagesTable["Messages"]:::db
        PromotionsTable["Promotions"]:::db
    end

    %% Connections
    Browser -->|"loads SPA"| main
    main --> app
    app --> auth
    auth --> adminComp
    auth --> commonComp
    adminComp --> adminLayout
    adminLayout --> sidebar
    adminLayout --> statCard
    commonComp --> btn
    commonComp --> header
    commonComp --> footer
    commonComp --> roomCard
    app --> guestDir
    guestDir --> homePage
    guestDir --> roomsPage
    guestDir --> detailPage
    guestDir --> bookingPage
    app --> adminDir
    adminDir --> dashboardPage
    adminDir --> roomsMgmt
    adminDir --> addRoom
    adminDir --> editRoom
    adminDir --> reservationsPage
    adminDir --> messagesPage
    adminDir --> promotionsPage
    adminDir --> usersPage
    app --> data
    app --> publicDir
    publicDir --> publicIndex
    app --> readme
    app --> pkg
    app --> bdDir
    bdDir --> schema
    bdDir --> query

    app -->|"HTTP/HTTPS calls"| AuthService
    app --> RoomsService
    app --> ReservationsService
    app --> UsersService
    app --> MessagesService
    app --> PromotionsService

    AuthService -->|"SQL queries"| DB
    RoomsService --> DB
    ReservationsService --> DB
    UsersService --> DB
    MessagesService --> DB
    PromotionsService --> DB

    DB --> UsersTable
    DB --> RoomsTable
    DB --> ReservationsTable
    DB --> MessagesTable
    DB --> PromotionsTable

    %% Click Events
    click main "https://github.com/daswsi-utp/hotelreservapp-front/blob/main/src/main.jsx"
    click app "https://github.com/daswsi-utp/hotelreservapp-front/blob/main/src/App.jsx"
    click auth "https://github.com/daswsi-utp/hotelreservapp-front/blob/main/src/context/AuthContext.jsx"
    click adminComp "https://github.com/daswsi-utp/hotelreservapp-front/tree/main/src/components/admin"
    click commonComp "https://github.com/daswsi-utp/hotelreservapp-front/tree/main/src/components/common"
    click adminLayout "https://github.com/daswsi-utp/hotelreservapp-front/blob/main/src/components/admin/AdminLayout.jsx"
    click sidebar "https://github.com/daswsi-utp/hotelreservapp-front/blob/main/src/components/admin/Sidebar.jsx"
    click statCard "https://github.com/daswsi-utp/hotelreservapp-front/blob/main/src/components/admin/StatCard.jsx"
    click btn "https://github.com/daswsi-utp/hotelreservapp-front/blob/main/src/components/common/Button.jsx"
    click header "https://github.com/daswsi-utp/hotelreservapp-front/blob/main/src/components/common/Header.jsx"
    click footer "https://github.com/daswsi-utp/hotelreservapp-front/blob/main/src/components/common/Footer.jsx"
    click roomCard "https://github.com/daswsi-utp/hotelreservapp-front/blob/main/src/components/common/RoomCard.jsx"
    click guestDir "https://github.com/daswsi-utp/hotelreservapp-front/tree/main/src/pages/guest"
    click homePage "https://github.com/daswsi-utp/hotelreservapp-front/blob/main/src/pages/guest/HomePage.jsx"
    click roomsPage "https://github.com/daswsi-utp/hotelreservapp-front/blob/main/src/pages/guest/RoomsPage.jsx"
    click detailPage "https://github.com/daswsi-utp/hotelreservapp-front/blob/main/src/pages/guest/RoomDetailPage.jsx"
    click bookingPage "https://github.com/daswsi-utp/hotelreservapp-front/blob/main/src/pages/guest/BookingPage.jsx"
    click adminDir "https://github.com/daswsi-utp/hotelreservapp-front/tree/main/src/pages/admin"
    click dashboardPage "https://github.com/daswsi-utp/hotelreservapp-front/blob/main/src/pages/admin/DashboardPage.jsx"
    click roomsMgmt "https://github.com/daswsi-utp/hotelreservapp-front/blob/main/src/pages/admin/RoomsManagementPage.jsx"
    click addRoom "https://github.com/daswsi-utp/hotelreservapp-front/blob/main/src/pages/admin/AddRoomPage.jsx"
    click editRoom "https://github.com/daswsi-utp/hotelreservapp-front/blob/main/src/pages/admin/EditRoomPage.jsx"
    click reservationsPage "https://github.com/daswsi-utp/hotelreservapp-front/blob/main/src/pages/admin/ReservationsPage.jsx"
    click messagesPage "https://github.com/daswsi-utp/hotelreservapp-front/blob/main/src/pages/admin/MessagesPage.jsx"
    click promotionsPage "https://github.com/daswsi-utp/hotelreservapp-front/blob/main/src/pages/admin/PromotionsPage.jsx"
    click usersPage "https://github.com/daswsi-utp/hotelreservapp-front/blob/main/src/pages/admin/UsersPage.jsx"
    click data "https://github.com/daswsi-utp/hotelreservapp-front/blob/main/src/data/roomsData.js"
    click publicDir "https://github.com/daswsi-utp/hotelreservapp-front/tree/main/public"
    click publicIndex "https://github.com/daswsi-utp/hotelreservapp-front/blob/main/public/index.html"
    click bdDir "https://github.com/daswsi-utp/hotelreservapp-front/tree/main/bd"
    click schema "https://github.com/daswsi-utp/hotelreservapp-front/blob/main/bd/bd_hotel.sql"
    click query "https://github.com/daswsi-utp/hotelreservapp-front/blob/main/bd/Query_BD.txt"
    click pkg "https://github.com/daswsi-utp/hotelreservapp-front/blob/main/package.json"
    click readme "https://github.com/daswsi-utp/hotelreservapp-front/blob/main/README.md"

    %% Styles
    classDef ui fill:#E3F2FD,stroke:#1E88E5,color:#0D47A1;
    classDef api fill:#E8F5E9,stroke:#43A047,color:#1B5E20;
    classDef db fill:#FFF3E0,stroke:#FB8C00,color:#E65100;
    classDef infra fill:#F3E5F5,stroke:#8E24AA,color:#4A148C;
```
