How saradbashyal/roomsewa-project works
1. System Purpose
This is a property/room booking platform with three deployable surfaces: a Node.js backend API, a customer-facing React frontend, and a separate React admin panel. Core domains are users/authentication, room listings, bookings and payments, reviews, notifications, contacts, and recommendations.
2. Runtime Entry Points
• Backend HTTP server starts through Backend/server.js and application wiring in Backend/main.js.
• Customer SPA bootstraps at Frontend/src/main.jsx, with top-level routing/application composition in Frontend/src/App.jsx.
• Admin SPA bootstraps at admin-panel/src/main.jsx, with its root in admin-panel/src/App.jsx.
• Both frontend applications are Vite projects; the customer frontend includes Vercel deployment configuration at Frontend/vercel.json.
3. API and Request Boundary
The backend follows a layered Express-style boundary: routers expose domain endpoints, controllers implement request behavior, and Mongoose-style models persist data.
• Route definitions: Backend/Router/auth.route.js, Backend/Router/booking.router.js, Backend/Router/room.router.js.
• Domain handlers: Backend/controllers/auth.controllers.js, Backend/controllers/booking.controllers.js, Backend/controllers/room.controllers.js.
• Auth and failure boundaries are centralized in Backend/middleware/auth.js, Backend/middleware/asyncHandler.js, and Backend/utils/ApiError.js.
Additional routers cover administration, contact requests, notifications, recommendations, and reviews.
4. Core Booking and Listing Domain
Rooms, bookings, users, reviews, and notification records are the primary persisted business entities.
• Models: Backend/models/Room.model.js, Backend/models/Booking.model.js, Backend/models/User.model.js.
• Supporting records: Backend/models/Review.model.js, Backend/models/Notification.model.js, Backend/models/History.model.js.
• Availability/booking-slot behavior is separated into Backend/utils/slot.util.js; booking behavior is driven from Backend/controllers/booking.controllers.js.
The customer UI exposes listing creation and management, discovery, details, and booking history through Frontend/src/pages/AddProperty.jsx, Frontend/src/pages/RoomDetails.jsx, and Frontend/src/pages/MyBookings.jsx.
5. Identity, Payments, and Communications
Authentication is handled through dedicated routes/controllers and token utilities, with frontend-side auth state helpers.
• Backend/Router/auth.route.js
• Backend/controllers/auth.controllers.js
• Backend/utils/token.js
• Frontend/src/utils/auth.js
External integrations are encapsulated behind utilities/configuration: MongoDB (Backend/config/mongo.config.js), email/Nodemailer (Backend/config/nodemailer.config.js, Backend/utils/email.util.js), Cloudinary uploads (Backend/utils/cloudinary.util.js), and eSewa payment processing (Backend/utils/esewa.util.js). Payment completion states have dedicated UI pages at Frontend/src/pages/PaymentSuccess.jsx and Frontend/src/pages/PaymentFailure.jsx.
6. Recommendations and Notifications
Recommendation logic is backend-owned and exposed as an API domain rather than calculated in the client.
• Backend/controllers/recommendation.controllers.js
• Backend/utils/recommendationEngine.util.js
• Frontend/src/pages/RecommendationsPage.jsx
Notifications similarly span persisted records, controller/route access, and a shared notification utility: Backend/models/Notification.model.js, Backend/controllers/notification.controllers.js, and Backend/utils/notification.util.js.
7. Client and Administration Flows
The customer frontend calls the backend through Frontend/src/services/api.js; pages/components render search, room details, listing management, booking history, and personalized recommendations.
The admin panel is an independent client with its own API adapter and authentication context:
• admin-panel/src/utils/api.js
• admin-panel/src/context/AuthContext.jsx
• admin-panel/src/components/Login.jsx
Its operational domains—dashboard analytics, users, rooms, bookings, and reviews—are represented by admin-panel/src/Pages/DashboardPage.jsx, admin-panel/src/Pages/BookingsPage.jsx, and admin-panel/src/Pages/UsersPage.jsx, backed by administrative backend endpoints in Backend/Router/admin.router.js and Backend/controllers/admin.controllers.js.
Components 18
Backend API
Express API and domain services.
- HTTP Server
Backend/server.js - Express App
Backend/main.js - Domain Routes · Auth, booking, room, admin, contacts, notifications, recommendations, and reviews.
Backend/Router/booking.router.js - Auth & Errors · Token authentication and async failure handling.
Backend/middleware/auth.js - Booking & Availability · Creates bookings and manages available slots.
Backend/controllers/booking.controllers.js - Room Listings
Backend/controllers/room.controllers.js - Identity · Authentication and token issuance.
Backend/controllers/auth.controllers.js - Administration · Operational analytics and management endpoints.
Backend/controllers/admin.controllers.js - Recommendations & Notifications · Backend-owned personalized recommendations and notification access.
Backend/controllers/recommendation.controllers.js - Business Records · Rooms, bookings, users, reviews, notifications, and history.
Backend/models/Booking.model.js
Customer SPA
Customer-facing Vite React application.
- Customer Bootstrap
Frontend/src/main.jsx - Customer App & Pages · Discovery, room details, listing management, bookings, payments, and recommendations.
Frontend/src/App.jsx - API Client & Auth State
Frontend/src/services/api.js
Admin SPA
Independent operational React application.
- Admin Bootstrap
admin-panel/src/main.jsx - Admin Operations UI · Dashboard, users, rooms, bookings, and reviews.
admin-panel/src/Pages/DashboardPage.jsx - Admin API & Session
admin-panel/src/utils/api.js
External Services
- MongoDB
Backend/config/mongo.config.js - Payments, Email & Uploads · eSewa, Nodemailer, and Cloudinary adapters.
Backend/utils/esewa.util.js
Connections 20
- HTTP Server → Express App: starts
- Express App → Domain Routes: mounts
- Domain Routes → Auth & Errors: protects requests
- Domain Routes → Identity: auth endpoints
- Domain Routes → Booking & Availability: booking endpoints
- Domain Routes → Room Listings: room endpoints
- Domain Routes → Administration: admin endpoints
- Domain Routes → Recommendations & Notifications: engagement endpoints
- Identity → Business Records: users
- Booking & Availability → Business Records: bookings
- Room Listings → Business Records: rooms and reviews
- Recommendations & Notifications → Business Records: notifications and history
- Business Records → MongoDB: persists
- Booking & Availability → Payments, Email & Uploads: payment completion
- Customer Bootstrap → Customer App & Pages: renders
- Customer App & Pages → API Client & Auth State: uses
- API Client & Auth State → Domain Routes: API requests
- Admin Bootstrap → Admin Operations UI: renders
- Admin Operations UI → Admin API & Session: uses
- Admin API & Session → Domain Routes: admin API requests