How thainguyen86/hotel_managerment_frontend works
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