How nguyenvanhuy2005/beachstay-hub works
Main Components
• Client/Frontend: This is a single-page application (SPA) that includes several subdomains:
• Public-facing pages (e.g., Home, About, Booking, Blog, Room Details).
• Admin dashboard pages (e.g., AdminDashboardPage, AdminLoginPage).
• Shared components like layout (Header, Footer, LanguageSwitcher), booking forms, and UI components.
• API & Integration Layer: The src/api directory (e.g., bookingApi.ts) provides client-side API calls.
• UI Library & Utilities: Extensive custom UI components (in src/components/ui), hooks (src/hooks), contexts (src/contexts), and utilities (src/lib) that structure and enhance the app functionality.
• Backend/Services: The “supabase” folder and src/integrations/supabase indicate:
• Integration with Supabase services for database operations.
• Serverless functions handling operations such as creating image buckets, storage buckets, and sending booking notifications.
Detail the Relationships and Interactions
• The client (browser) loads the index.html which bootstraps the frontend, rendering React components defined in the src directory.
• The frontend is organized into pages and components—public pages and admin pages are separated for access control and functionality.
• User interactions (e.g., booking a room) trigger API calls from the src/api layer. The requests eventually engage with Supabase’s backend functions to update the database, manage storage, or send notifications.
• Integration components (src/integrations/supabase) serve as the intermediary between the client-side logic and Supabase’s serverless functions.
• The build process and deployments are managed through Vite and configuration files (like vite.config.ts, tailwind.config.ts), ensuring instant previews and auto-reloading during development.
Architectural Patterns
• Component-based Architecture: The React components are neatly organized (e.g., separate folders for admin, booking, home, layout, ui) following a clear separation of concerns.
• Modular and Layered Organization: Distinct directories for APIs, hooks, contexts, and utilities help maintain the project in layers – presentation (components/pages), business logic (contexts/hooks), and integration (API, supabase integrations).
• Serverless Functions: The use of Supabase functions indicates an event-driven architecture for specific backend operations.
Relevant Technologies and Their Roles
• Vite: For fast development and hot-module reloading.
• TypeScript & React: Primary technologies for building a robust and maintainable frontend.
• shadcn-ui & Tailwind CSS: For building a consistent, theme-able UI with reusable components.
• Supabase: As the backend-as-a-service providing database, storage, and serverless function capabilities.
1. Presentation Layer: Browser/Client with React application. Include subcomponents like Home, Admin dashboard, Booking page.
2. Logic/API Layer: API calls (bookingApi.ts) and integration with Supabase (src/integrations/supabase and functions).
3. Data/Backend Layer: Supabase database and serverless functions (with specific functions for images and notifications).
• To represent the entry point (index.html / main.tsx) clearly, as well as the central role of routing (src/pages) in segregating user experiences.