# thilaksan8/time-slot-booking-app architecture

> Architecture diagram of the GitHub repository thilaksan8/time-slot-booking-app, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-08-15). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/thilaksan8/time-slot-booking-app
- Repository: https://github.com/thilaksan8/time-slot-booking-app

## Overview

#### 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/server.js`](https://github.com/thilaksan8/time-slot-booking-app/blob/main/Server/server.js) (API server), [`client/src/App.jsx`](https://github.com/thilaksan8/time-slot-booking-app/blob/main/client/src/App.jsx) (App composition), [`client/src/pages/Home.jsx`](https://github.com/thilaksan8/time-slot-booking-app/blob/main/client/src/pages/Home.jsx) (Home), [`Server/routes/bookingRoute.js`](https://github.com/thilaksan8/time-slot-booking-app/blob/main/Server/routes/bookingRoute.js) (Booking routes)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_client["React Client"]
  node_client_bootstrap["Client bootstrap<br/>Vite entry<br/>[main.jsx]"]
  node_app["App composition<br/>React root<br/>[App.jsx]"]
  node_auth_context["Auth session state<br/>React context<br/>[AuthContext.jsx]"]
  node_home["Home<br/>page<br/>[Home.jsx]"]
  node_navbar["Navigation<br/>[Navbar.jsx]"]
  node_booking_form["Booking form<br/>[BookingForm.jsx]"]
  node_available_slots["Available slots<br/>[AvailableSlots.jsx]"]
  node_booked_slots["Booked slots<br/>[BookedSlots.jsx]"]
  node_booking_service["Booking API service<br/>HTTP service<br/>[bookingService.js]"]
  node_auth_service["Auth API service<br/>HTTP service<br/>[authService.js]"]
  node_api_service["API client<br/>HTTP transport<br/>[api.js]"]
end

subgraph group_api["Express API"]
  node_server["API server<br/>Express bootstrap<br/>[server.js]"]
  node_booking_routes["Booking routes<br/>Express router<br/>[bookingRoute.js]"]
  node_auth_routes["Auth routes<br/>Express router<br/>[authRoute.js]"]
  node_admin_routes["Admin routes<br/>Express router<br/>[adminRoute.js]"]
  node_auth_middleware["Authentication guard<br/>middleware<br/>[authMiddleware.js]"]
  node_authorize_middleware["Authorization guard<br/>middleware"]
  node_booking_controller["Booking controller"]
  node_auth_controller["Authentication controller<br/>[authController.js]"]
end

subgraph group_data["Persistence"]
  node_booking_model[("Booking model<br/>Mongoose model<br/>[Booking.js]")]
  node_user_model[("User model<br/>Mongoose model<br/>[User.js]")]
  node_db_connection["Database connection<br/>Mongoose connection<br/>[db.js]"]
end

subgraph group_hosting["Hosting"]
  node_mongodb_atlas[("MongoDB Atlas<br/>database service")]
  node_vercel{{"Vercel<br/>frontend hosting"}}
  node_render{{"Render<br/>backend hosting"}}
end

node_client_bootstrap -->|"mounts"| node_app
node_app -->|"provides session"| node_auth_context
node_app -->|"renders"| node_home
node_app -->|"renders"| node_navbar
node_home -->|"uses"| node_booking_form
node_home -->|"shows"| node_available_slots
node_home -->|"shows"| node_booked_slots
node_booking_form -->|"creates or updates"| node_booking_service
node_booked_slots -->|"manages bookings"| node_booking_service
node_booking_service -->|"uses"| node_api_service
node_auth_context -->|"authenticates via"| node_auth_service
node_auth_service -->|"uses"| node_api_service
node_api_service -->|"HTTP API requests"| node_server
node_server -->|"mounts"| node_booking_routes
node_server -->|"mounts"| node_auth_routes
node_server -->|"mounts"| node_admin_routes
node_booking_routes -->|"protects requests"| node_auth_middleware
node_auth_middleware -->|"permits handler"| node_booking_controller
node_booking_routes -->|"dispatches CRUD"| node_booking_controller
node_auth_routes -->|"dispatches"| node_auth_controller
node_admin_routes -->|"enforces roles"| node_authorize_middleware
node_booking_controller -->|"reads and writes"| node_booking_model
node_auth_controller -->|"reads and writes"| node_user_model
node_db_connection -->|"connects to"| node_mongodb_atlas
node_booking_model -->|"uses connection"| node_db_connection
node_user_model -->|"uses connection"| node_db_connection
node_vercel -.->|"hosts client"| node_client_bootstrap
node_render -.->|"hosts API"| node_server

click node_client_bootstrap "https://github.com/thilaksan8/time-slot-booking-app/blob/main/client/src/main.jsx"
click node_app "https://github.com/thilaksan8/time-slot-booking-app/blob/main/client/src/App.jsx"
click node_auth_context "https://github.com/thilaksan8/time-slot-booking-app/blob/main/client/src/context/AuthContext.jsx"
click node_home "https://github.com/thilaksan8/time-slot-booking-app/blob/main/client/src/pages/Home.jsx"
click node_navbar "https://github.com/thilaksan8/time-slot-booking-app/blob/main/client/src/components/Navbar.jsx"
click node_booking_form "https://github.com/thilaksan8/time-slot-booking-app/blob/main/client/src/components/BookingForm.jsx"
click node_available_slots "https://github.com/thilaksan8/time-slot-booking-app/blob/main/client/src/components/AvailableSlots.jsx"
click node_booked_slots "https://github.com/thilaksan8/time-slot-booking-app/blob/main/client/src/components/BookedSlots.jsx"
click node_booking_service "https://github.com/thilaksan8/time-slot-booking-app/blob/main/client/src/services/bookingService.js"
click node_auth_service "https://github.com/thilaksan8/time-slot-booking-app/blob/main/client/src/services/authService.js"
click node_api_service "https://github.com/thilaksan8/time-slot-booking-app/blob/main/client/src/services/api.js"
click node_server "https://github.com/thilaksan8/time-slot-booking-app/blob/main/Server/server.js"
click node_booking_routes "https://github.com/thilaksan8/time-slot-booking-app/blob/main/Server/routes/bookingRoute.js"
click node_auth_routes "https://github.com/thilaksan8/time-slot-booking-app/blob/main/Server/routes/authRoute.js"
click node_admin_routes "https://github.com/thilaksan8/time-slot-booking-app/blob/main/Server/routes/adminRoute.js"
click node_auth_middleware "https://github.com/thilaksan8/time-slot-booking-app/blob/main/Server/middleware/authMiddleware.js"
click node_authorize_middleware "https://github.com/thilaksan8/time-slot-booking-app/blob/main/Server/middleware/authorizeMiddleware.js"
click node_booking_controller "https://github.com/thilaksan8/time-slot-booking-app/blob/main/Server/controllers/BookingController.js"
click node_auth_controller "https://github.com/thilaksan8/time-slot-booking-app/blob/main/Server/controllers/authController.js"
click node_booking_model "https://github.com/thilaksan8/time-slot-booking-app/blob/main/Server/models/Booking.js"
click node_user_model "https://github.com/thilaksan8/time-slot-booking-app/blob/main/Server/models/User.js"
click node_db_connection "https://github.com/thilaksan8/time-slot-booking-app/blob/main/Server/config/db.js"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_client_bootstrap,node_app,node_auth_context,node_home,node_navbar,node_booking_form,node_available_slots,node_booked_slots,node_booking_service,node_auth_service,node_api_service toneBlue
class node_server,node_booking_routes,node_auth_routes,node_admin_routes,node_auth_middleware,node_authorize_middleware,node_booking_controller,node_auth_controller toneAmber
class node_booking_model,node_user_model,node_db_connection toneMint
class node_mongodb_atlas,node_vercel,node_render toneRose
```

## Components

### React Client

- [Client bootstrap](https://github.com/thilaksan8/time-slot-booking-app/blob/main/client/src/main.jsx): Vite entry · `client/src/main.jsx`
- [App composition](https://github.com/thilaksan8/time-slot-booking-app/blob/main/client/src/App.jsx): React root · `client/src/App.jsx`
- [Auth session state](https://github.com/thilaksan8/time-slot-booking-app/blob/main/client/src/context/AuthContext.jsx): React context · Cross-cutting authentication state provider. · `client/src/context/AuthContext.jsx`
- [Home](https://github.com/thilaksan8/time-slot-booking-app/blob/main/client/src/pages/Home.jsx): page · `client/src/pages/Home.jsx`
- [Navigation](https://github.com/thilaksan8/time-slot-booking-app/blob/main/client/src/components/Navbar.jsx): `client/src/components/Navbar.jsx`
- [Booking form](https://github.com/thilaksan8/time-slot-booking-app/blob/main/client/src/components/BookingForm.jsx): Starts create and update booking actions. · `client/src/components/BookingForm.jsx`
- [Available slots](https://github.com/thilaksan8/time-slot-booking-app/blob/main/client/src/components/AvailableSlots.jsx): Renders reservable time slots. · `client/src/components/AvailableSlots.jsx`
- [Booked slots](https://github.com/thilaksan8/time-slot-booking-app/blob/main/client/src/components/BookedSlots.jsx): Displays occupied slots and booking management actions. · `client/src/components/BookedSlots.jsx`
- [Booking API service](https://github.com/thilaksan8/time-slot-booking-app/blob/main/client/src/services/bookingService.js): HTTP service · Centralizes booking CRUD calls. · `client/src/services/bookingService.js`
- [Auth API service](https://github.com/thilaksan8/time-slot-booking-app/blob/main/client/src/services/authService.js): HTTP service · `client/src/services/authService.js`
- [API client](https://github.com/thilaksan8/time-slot-booking-app/blob/main/client/src/services/api.js): HTTP transport · `client/src/services/api.js`

### Express API

- [API server](https://github.com/thilaksan8/time-slot-booking-app/blob/main/Server/server.js): Express bootstrap · Configures Express and starts the HTTP listener. · `Server/server.js`
- [Booking routes](https://github.com/thilaksan8/time-slot-booking-app/blob/main/Server/routes/bookingRoute.js): Express router · `Server/routes/bookingRoute.js`
- [Auth routes](https://github.com/thilaksan8/time-slot-booking-app/blob/main/Server/routes/authRoute.js): Express router · `Server/routes/authRoute.js`
- [Admin routes](https://github.com/thilaksan8/time-slot-booking-app/blob/main/Server/routes/adminRoute.js): Express router · `Server/routes/adminRoute.js`
- [Authentication guard](https://github.com/thilaksan8/time-slot-booking-app/blob/main/Server/middleware/authMiddleware.js): middleware · `Server/middleware/authMiddleware.js`
- [Authorization guard](https://github.com/thilaksan8/time-slot-booking-app/blob/main/Server/middleware/authorizeMiddleware.js): middleware · Enforces role-aware access. · `Server/middleware/authorizeMiddleware.js`
- [Booking controller](https://github.com/thilaksan8/time-slot-booking-app/blob/main/Server/controllers/BookingController.js): controller · Validates slot reservations and prevents duplicate bookings. · `Server/controllers/BookingController.js`
- [Authentication controller](https://github.com/thilaksan8/time-slot-booking-app/blob/main/Server/controllers/authController.js): controller · `Server/controllers/authController.js`

### Persistence

- [Booking model](https://github.com/thilaksan8/time-slot-booking-app/blob/main/Server/models/Booking.js): Mongoose model · Appointment records determine slot availability. · `Server/models/Booking.js`
- [User model](https://github.com/thilaksan8/time-slot-booking-app/blob/main/Server/models/User.js): Mongoose model · User and role records for authentication. · `Server/models/User.js`
- [Database connection](https://github.com/thilaksan8/time-slot-booking-app/blob/main/Server/config/db.js): Mongoose connection · Reads environment-specific database settings. · `Server/config/db.js`

### Hosting

- **MongoDB Atlas**: database service
- **Vercel**: frontend hosting
- **Render**: backend hosting

## Connections

- 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
