How debjitpramanick/hotel-booking-web-app works
Project type and purpose
• This is a full‑stack MERN (MongoDB, Express.js, React, Node.js) hotel‑booking web application.
• Frontend: React SPA that consumes a GraphQL API.
• Backend: Node.js/Express server exposing a GraphQL endpoint.
• Data layer: MongoDB for persisting users, hotels, rooms, bookings.
• External services: Stripe for payments (and optionally Firebase if used for file storage or auth utilities).
Main components
a. Presentation Layer (Client)
• Browser / React SPA
• Key parts:
• React Router–managed pages (Home, Explore, HotelPage, Auth, Dashboard, Bookings, Payment, Profile)
• Reusable components: Header, Sidebars, Modals, Loaders, SearchBar, etc.
• GraphQL client (Apollo or fetch) for queries & mutations.
b. API Layer (Server)
• Node.js + Express
• GraphQL middleware (apollo-server-express or express-graphql)
• Middleware functions: isAuth, verifyToken (JWT auth)
• GraphQL schema modules: Query, Mutation, CustomTypes, Type definitions
• Resolvers: bookingQueries, hotelQueries, roomQueries, userQueries, bookingMutations, etc.
c. Data Layer
• MongoDB database
• Mongoose models: User, Hotel, Room, Booking
d. External Services
• Stripe API for payment processing
• (Optional) Firebase utility module if used for image upload or auth
e. Development / Deployment
• GitHub repo, CI/CD to Vercel (frontend) and your Node server host
• .env for MONGO_URL, Stripe keys, JWT secrets
Relationships and interactions
• User (browser) → React SPA
• React SPA → GraphQL API (HTTP POST) for queries & mutations
• GraphQL server → MongoDB for data CRUD
• GraphQL mutations for payments → Stripe API → webhooks → update Booking status
• Auth flow: React SPA sends credentials → login mutation → server issues JWT → client stores token → client attaches JWT in Authorization header on subsequent requests
• Admin/Manager role paths: additional mutations for creating/updating/deleting hotels & rooms
Architectural patterns & design principles
• Three‑tier architecture: Presentation, API, Data
• GraphQL schema-driven development (type-first)
• MVC‑style within server: schema/resolvers (controller) + models (data)
• Component‑based UI in React (atomic design)
• Context API for global state (auth context, theme, etc.)
• Separation of concerns:
• UI logic vs API calls
• Auth middleware vs business logic
What to capture in detail
• Authentication middleware flow: isAuth → verifyToken → context.user
• GraphQL schema structure: Queries vs Mutations modules
• Payment workflow: StripeForm in client → paymentMutation → Stripe SDK on server → webhook callback
• Data relationships: User ←→ Booking ←→ Room ←→ Hotel
• Role‑based access (admin vs manager vs guest)