# siddharth9300/bookit architecture

> Architecture diagram of the GitHub repository siddharth9300/bookit, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-05-20). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/siddharth9300/bookit
- Repository: https://github.com/siddharth9300/bookit

## Overview

##### Project type and purpose
- This is a full-stack “Book It” hall-booking platform.
- The client folder is a React/Tailwind SPA; the server folder is a Node.js/Express API with MongoDB via Mongoose.

##### File structure
- Top level:
- client/ – React app (components, assets, routing, state)
- server/ – Express app (controllers, middleware, models, routes, DB connection)
- Key files:
- client/src/components – UI & auth/booking/dashboard modules
- client/src/index.js – React entry point
- server/app.js – Express setup & middleware
- server/DB/conn.js – MongoDB connection
- server/controllers/*.js – business logic
- server/router/*Routes.js – REST endpoints
- server/middleware/authenticate.js – JWT/session guard
- server/model/*.js – Mongoose schemas

##### Extract architectural insights from the README
- Client communicates with server via Axios HTTP calls.
- Auth flows (signup, login, password reset) using email verification (nodemailer).
- Role-based dashboards (admin, faculty, HOD).
- Real-time availability via calendar component (polling or re-fetch).

a. Main components
1. Presentation Layer (Client React App)
– Components: Navbar, BookingForm, CalendarView, Dashboards, Auth UI
– State management: useReducer hooks
– Routing: react-router-dom
2. API Layer (Express Server)
– Routes: /auth, /bookings, /halls
– Controllers: authController, bookingController, hallController
– Middleware: authenticate JWT
3. Data Layer
– MongoDB (collections: users, bookings, halls)
– Mongoose ODM
4. External Services
– Email SMTP (verification, password reset)
– Hosting/CDN for client (e.g., Netlify/Vercel)
– Cloud DB (MongoDB Atlas)
b. Relationships & interactions
- Client → Server: Axios HTTP(S) calls → JWT in headers
- Server ↔ Database: Mongoose queries over TCP
- Server → Email service: SMTP via nodemailer
- Client ←→ Calendar real-time data: periodic GET /bookings or WebSocket (if added)
c. Architectural patterns & principles
– Separation of concerns: UI vs. API vs. DB
– RESTful API design
– Role-based access control via middleware
– Environment-driven configuration (URL, secrets, feature flags)
d. Technologies & frameworks
– React, Tailwind CSS, Axios, react-router
– Node.js, Express, Mongoose, MongoDB
– Nodemailer (email)
– Environment variables for feature toggles (HOD, Admin signup)

## Diagram (Mermaid)

```mermaid
flowchart TD
    subgraph "Presentation Layer"
        subgraph "React App"
            IDX["Index Entry Point<br/>client/src/index.js"]:::frontend
            APP["Main App & Routing<br/>client/src/App.js"]:::frontend
        end
        subgraph "UI Components"
            NAV["Navbar"]:::frontend
            BFORM["BookingForm"]:::frontend
            BUPD["BookingUpdateForm"]:::frontend
            BVIEW["BookingView"]:::frontend
            CAL["CalendarView"]:::frontend
            subgraph "Dashboards"
                ADM_D["AdminDashboard"]:::frontend
                FAC_D["FacultyDashboard"]:::frontend
                HOD_D["HodDashboard"]:::frontend
            end
            subgraph "Auth Components"
                LGIN["Login"]:::frontend
                SUP["Signup"]:::frontend
                FPW["ForgotPassword"]:::frontend
                PRS["PasswordReset"]:::frontend
                VSC["VerifySuccess"]:::frontend
                LOGO["Logout"]:::frontend
            end
        end
        REDU["State Management Hook<br/>UseReducer"]:::frontend
        TAILWND["Tailwind Config"]:::frontend
    end

    subgraph "API Layer"
        APS["Express Setup & Middleware<br/>server/app.js"]:::api
        CONN["DB Connection Module<br/>server/DB/conn.js"]:::api
        subgraph "Routes"
            ARO["Authentication Routes<br/>server/router/authRoutes.js"]:::api
            BRO["Booking Routes<br/>server/router/bookingRoutes.js"]:::api
            HRO["Hall Routes<br/>server/router/hallRoutes.js"]:::api
        end
        subgraph "Controllers"
            ACO["Auth Controller<br/>server/controllers/authController.js"]:::api
            BCO["Booking Controller<br/>server/controllers/bookingController.js"]:::api
            HCO["Hall Controller<br/>server/controllers/hallController.js"]:::api
        end
        MIDL["JWT Authentication Middleware<br/>server/middleware/authenticate.js"]:::api
    end

    subgraph "Data Layer"
        DB["MongoDB Atlas"]:::db
        USCH["User Schema<br/>server/model/userSchema.js"]:::db
        BSCH["Booking Schema<br/>server/model/bookingSchema.js"]:::db
        HSCH["Hall Schema<br/>server/model/hallSchema.js"]:::db
    end

    subgraph "External Services"
        SMTP["Email SMTP Service"]:::external
        CDN["Hosting/CDN"]:::external
    end

    %% Data Flows
    IDX -->|renders| APP
    APP -->|renders| NAV
    APP -->|renders| BFORM
    APP -->|renders| BUPD
    APP -->|renders| BVIEW
    APP -->|renders| CAL
    APP -->|routes to| ADM_D
    APP -->|routes to| FAC_D
    APP -->|routes to| HOD_D
    APP -->|renders| LGIN
    APP -->|renders| SUP
    APP -->|renders| FPW
    APP -->|renders| PRS
    APP -->|renders| VSC
    APP -->|renders| LOGO
    APP -->|uses| REDU

    %% Client to API
    NAV -->|Axios HTTP| APS
    BFORM -->|Axios HTTP| APS
    BUPD -->|Axios HTTP| APS
    BVIEW -->|Axios HTTP| APS
    CAL -->|polling / re-fetch| APS
    ADM_D -->|Axios HTTP| APS
    FAC_D -->|Axios HTTP| APS
    HOD_D -->|Axios HTTP| APS

    %% API internals
    APS -->|loads| CONN
    APS -->|registers routes| ARO
    APS -->|registers routes| BRO
    APS -->|registers routes| HRO
    ARO -->|uses| MIDL
    BRO -->|uses| MIDL
    HRO -->|uses| MIDL
    ARO -->|calls| ACO
    BRO -->|calls| BCO
    HRO -->|calls| HCO

    %% Controllers to DB
    ACO -->|uses| USCH
    ACO -->|uses| BSCH
    ACO -->|uses| HSCH
    BCO -->|uses| BSCH
    HCO -->|uses| HSCH
    USCH -->|persist| DB
    BSCH -->|persist| DB
    HSCH -->|persist| DB

    %% Email Service
    ACO -.->|SMTP Email| SMTP

    %% Hosting
    CDN -.-> IDX

    %% Styles
    classDef frontend fill:#CCE5FF,stroke:#004085
    classDef api fill:#D4EDDA,stroke:#155724
    classDef db fill:#FFF3CD,stroke:#856404
    classDef external fill:#E2E3E5,stroke:#6C757D

    %% Click Events
    click IDX "https://github.com/siddharth9300/bookit/blob/main/client/src/index.js"
    click APP "https://github.com/siddharth9300/bookit/blob/main/client/src/App.js"
    click NAV "https://github.com/siddharth9300/bookit/blob/main/client/src/components/Navbar.js"
    click BFORM "https://github.com/siddharth9300/bookit/blob/main/client/src/components/bookings/BookingForm.js"
    click BUPD "https://github.com/siddharth9300/bookit/blob/main/client/src/components/bookings/BookingUpdateForm.js"
    click BVIEW "https://github.com/siddharth9300/bookit/blob/main/client/src/components/bookings/BookingView.js"
    click CAL "https://github.com/siddharth9300/bookit/blob/main/client/src/components/CalendarView.js"
    click ADM_D "https://github.com/siddharth9300/bookit/blob/main/client/src/components/dashboard/AdminDashboard.js"
    click FAC_D "https://github.com/siddharth9300/bookit/blob/main/client/src/components/dashboard/FacultyDashboard.js"
    click HOD_D "https://github.com/siddharth9300/bookit/blob/main/client/src/components/dashboard/HodDashboard.js"
    click LGIN "https://github.com/siddharth9300/bookit/blob/main/client/src/components/auth/Login.js"
    click SUP "https://github.com/siddharth9300/bookit/blob/main/client/src/components/auth/Signup.js"
    click FPW "https://github.com/siddharth9300/bookit/blob/main/client/src/components/auth/ForgotPassword.js"
    click PRS "https://github.com/siddharth9300/bookit/blob/main/client/src/components/auth/PasswordReset.js"
    click VSC "https://github.com/siddharth9300/bookit/blob/main/client/src/components/auth/VerifySuccess.js"
    click LOGO "https://github.com/siddharth9300/bookit/blob/main/client/src/components/auth/Logout.js"
    click REDU "https://github.com/siddharth9300/bookit/blob/main/client/src/reducer/UseReducer.js"
    click TAILWND "https://github.com/siddharth9300/bookit/blob/main/client/tailwind.config.js"
    click APS "https://github.com/siddharth9300/bookit/blob/main/server/app.js"
    click CONN "https://github.com/siddharth9300/bookit/blob/main/server/DB/conn.js"
    click ACO "https://github.com/siddharth9300/bookit/blob/main/server/controllers/authController.js"
    click BCO "https://github.com/siddharth9300/bookit/blob/main/server/controllers/bookingController.js"
    click HCO "https://github.com/siddharth9300/bookit/blob/main/server/controllers/hallController.js"
    click MIDL "https://github.com/siddharth9300/bookit/blob/main/server/middleware/authenticate.js"
    click USCH "https://github.com/siddharth9300/bookit/blob/main/server/model/userSchema.js"
    click BSCH "https://github.com/siddharth9300/bookit/blob/main/server/model/bookingSchema.js"
    click HSCH "https://github.com/siddharth9300/bookit/blob/main/server/model/hallSchema.js"
    click ARO "https://github.com/siddharth9300/bookit/blob/main/server/router/authRoutes.js"
    click BRO "https://github.com/siddharth9300/bookit/blob/main/server/router/bookingRoutes.js"
    click HRO "https://github.com/siddharth9300/bookit/blob/main/server/router/hallRoutes.js"
```
