How thilaksan8/time-slot-booking-app works
Purpose and Runtime Topology
This is a full-stack MERN time-slot booking system. A React/Vite single-page client manages booking UI and calls an Express API; the API persists users and bookings in MongoDB through Mongoose. The frontend is deployed to Vercel and the backend to Render; MongoDB Atlas is the database service.
Entry points:
• Client bootstrap: client/src/main.jsx, application composition: client/src/App.jsx
• Server bootstrap and HTTP listener: Server/server.js
• Database connection boundary: Server/config/db.js
Client Application and Session State
The React application organizes its UI around home, authentication, booking management, and navigation. AuthContext is the cross-cutting session/authentication state provider, while UI components consume API service functions rather than communicating with the server directly.
Core paths:
• client/src/context/AuthContext.jsx
• client/src/pages/Home.jsx
• client/src/components/Navbar.jsx
Booking UI Workflow
Users select and manage appointments through booking-oriented components. Available slots are rendered separately from occupied slots, enabling the UI to disable or exclude reservations already present in the booking dataset. Create/update/delete actions originate in the form and booked-slot views, then trigger refreshes of booking state.
Core paths:
• client/src/components/BookingForm.jsx
• client/src/components/AvailableSlots.jsx
• client/src/components/BookedSlots.jsx
Client-to-API Service Boundary
Service modules centralize HTTP interactions, separating React rendering/state concerns from backend endpoint details. Booking operations map to the CRUD API; authentication has dedicated service and form layers.
Core paths:
• client/src/services/api.js
• client/src/services/bookingService.js
• client/src/services/authService.js
Express Routing and Request Control
The Node/Express server is the API boundary. Requests are split into booking, authentication, and admin route groups. Middleware enforces authentication and authorization before protected handlers; this supports role-aware access even though the README frames it as a future enhancement.
Core paths:
• Server/server.js
• Server/routes/bookingRoute.js
• Server/routes/authRoute.js
• Server/routes/adminRoute.js
• Server/middleware/authMiddleware.js
• Server/middleware/authorizeMiddleware.js
Controllers and Booking Consistency
Controllers implement request-level application behavior: booking CRUD plus authentication. The booking controller is the key consistency point for rejecting invalid or duplicate time-slot reservations and producing responses the client can use to refresh availability.
Core paths:
• Server/controllers/BookingController.js
• Server/controllers/authController.js
• Server/routes/bookingRoute.js
Persistence Model
Mongoose models define the persisted domain: bookings are the appointment records underlying slot availability, and users support authentication/role-based authorization. Connection configuration reads environment-specific database settings; Server/.env.example establishes the operational configuration boundary.
Core paths:
• Server/models/Booking.js
• Server/models/User.js
• Server/config/db.js
• Server/.env.example
Main entry points: server.js API server · App.jsx App composition · Home.jsx Home · bookingRoute.js Booking routes
Components 25
React Client
- Client bootstrap
client/src/main.jsx - App composition
client/src/App.jsx - Auth session state · Cross-cutting authentication state provider.
client/src/context/AuthContext.jsx - Home
client/src/pages/Home.jsx - Navigation
client/src/components/Navbar.jsx - Booking form · Starts create and update booking actions.
client/src/components/BookingForm.jsx - Available slots · Renders reservable time slots.
client/src/components/AvailableSlots.jsx - Booked slots · Displays occupied slots and booking management actions.
client/src/components/BookedSlots.jsx - Booking API service · Centralizes booking CRUD calls.
client/src/services/bookingService.js - Auth API service
client/src/services/authService.js - API client
client/src/services/api.js
Express API
- API server · Configures Express and starts the HTTP listener.
Server/server.js - Booking routes
Server/routes/bookingRoute.js - Auth routes
Server/routes/authRoute.js - Admin routes
Server/routes/adminRoute.js - Authentication guard
Server/middleware/authMiddleware.js - Authorization guard · Enforces role-aware access.
Server/middleware/authorizeMiddleware.js - Booking controller · Validates slot reservations and prevents duplicate bookings.
Server/controllers/BookingController.js - Authentication controller
Server/controllers/authController.js
Persistence
- Booking model · Appointment records determine slot availability.
Server/models/Booking.js - User model · User and role records for authentication.
Server/models/User.js - Database connection · Reads environment-specific database settings.
Server/config/db.js
Hosting
- MongoDB Atlas
- Vercel
- Render
Connections 28
- Client bootstrap → App composition: mounts
- App composition → Auth session state: provides session
- App composition → Home: renders
- App composition → Navigation: renders
- Home → Booking form: uses
- Home → Available slots: shows
- Home → Booked slots: shows
- Booking form → Booking API service: creates or updates
- Booked slots → Booking API service: manages bookings
- Booking API service → API client: uses
- Auth session state → Auth API service: authenticates via
- Auth API service → API client: uses
- API client → API server: HTTP API requests
- API server → Booking routes: mounts
- API server → Auth routes: mounts
- API server → Admin routes: mounts
- Booking routes → Authentication guard: protects requests
- Authentication guard → Booking controller: permits handler
- Booking routes → Booking controller: dispatches CRUD
- Auth routes → Authentication controller: dispatches
- Admin routes → Authorization guard: enforces roles
- Booking controller → Booking model: reads and writes
- Authentication controller → User model: reads and writes
- Database connection → MongoDB Atlas: connects to
- Booking model → Database connection: uses connection
- User model → Database connection: uses connection
- Vercel → Client bootstrap: hosts client
- Render → API server: hosts API