How sehban123/travel-booking-platform works
Project Type and Purpose
• This is a full-stack web application bootstrapped with Create React App (frontend) and a minimal Express/Node server (server.js + models) acting as a RESTful API.
• Purpose: A travel service booking platform with three user roles—customers, service providers, and administrators—for managing accommodations, transportation, sports adventures, and business inquiries.
High-Level Architecture
Component Layers:
– Client Layer (React SPA)
– API Layer (Express/Node server)
– Data Layer (Database + File Storage)
– External Services (e.g., authentication provider, email/payment gateways)
Main Components
a. Frontend (src/ + public/)
• React components for customer workflows (Accommodation, Transportation, SportAdventure, BusinessInquiry)
• React components for provider workflows (ServiceProviderAuth, ProviderDashboard, BookingRequests)
• React components for admin dashboards and management (AdminLogin, AdminDashboard, AdminAccommodationList, AdminProviderServices, etc.)
• Static assets in public/ and src/css, src/images
b. Backend (server.js + models/)
• server.js: Entry point, sets up Express middleware, routes, and connects to the database
• models/ServiceProviderModel.js: Defines the data schema (likely with Mongoose if MongoDB is used)
• src/config.js or .env: Configuration for DB URI, authentication secrets, file storage paths
c. Database
• No explicit DB folder, but models indicate a document database (MongoDB)
• Collections: users, providers, bookings, inquiries, services
d. File Storage
• src/documents and src/images store uploaded PDFs and images for provider verification
• Could be local filesystem or external object store (e.g., AWS S3) in production
e. External Services (optional)
• Authentication/Authorization (JWT or OAuth)
• Email/SMS notifications for booking confirmations
• Payment Gateway integration
Relationships and Data Flow
• The React client communicates with the Express API via HTTP(S) (REST endpoints).
• The Express API performs CRUD operations on the database and reads/writes files to disk or object storage.
• Administrators and providers use protected API routes (middleware in server.js checks JWT/session).
• Data flows:
– Customer forms → React state → REST POST /bookings → Express → DB
– Provider fetch booking requests → REST GET /provider/:id/requests → Express → DB
– Admin approves provider → REST PATCH /admin/providers/:id/approve → Express → DB
Architectural Patterns and Principles
• Separation of concerns: Presentation (React) vs. Business logic/API (Express) vs. Persistence (DB/files).
• MVC-like pattern on the backend: server.js (Controller + Routes) + models (Model).
• Component-based UI in React.
• Route-based access control via protected routes (e.g., AdminProtectedRoute.js).
• Centralized configuration (.env, config.js).