# sanket-singh-sameer/himadriallinoneplatform architecture

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

- Interactive diagram: https://gitdiagram.com/sanket-singh-sameer/himadriallinoneplatform
- Repository: https://github.com/sanket-singh-sameer/himadriallinoneplatform

## Overview

1. This is a two-tier monorepo: a Node/Express backend in `BACKEND/` and a React/Vite frontend in `FRONTEND/`. The frontend is a browser UI; the backend is the sole application server and API layer; MongoDB is the persistent store.

2. The backend entry point is `BACKEND/server.js`. It wires together DB connection (`config/connectDB.js`), route mounting, middleware, and likely global app configuration such as CORS, JSON parsing, cookies, and environment-based startup. All business features are exposed through versioned API routes under `/api/v1/...`.

3. Data access is organized around Mongoose models in `BACKEND/models/`. The main domain entities are users, complaints, CGPI records, notices, mess menus, mess attendance, equipment, outpasses, and rooms. These models define the persistence boundary; controllers operate on them rather than talking to MongoDB directly.

4. Business logic is split by feature into controllers in `BACKEND/controllers/`: authentication, admin, complaints, CGPI, equipment, ID, mess, mess menu, and notices. This suggests a resource-oriented backend where each controller owns one domain slice and translates HTTP requests into model operations and side effects.

5. Authentication and authorization are layered through middleware. `verifyToken.middleware.js` handles logged-in user protection, `checkIfAdmin.middleware.js` gates admin-only operations, and `checkIfCommitte.middleware.js` plus the committee-specific checks enforce more granular role access for hostel committees like mess, discipline, gate, guard, cleaning, hostel, and common room. These middleware form the main security boundary around privileged endpoints.

6. The auth flow is email-centric and token-based. The README indicates college-email registration, OTP verification, password reset, and JWT-based login stored as HTTP-only cookies. Supporting utilities such as `jwtTokenOperations.js`, `cookieOperations.js`, and `otpGeneration.js` suggest the backend owns session/token issuance and verification rather than the frontend.

7. Messaging and notifications are handled by dedicated email integrations. There are two provider-specific folders, `BACKEND/gmail/` and `BACKEND/resend/`, each with config and templates, indicating the app can send OTPs and notifications through email service abstraction. This is an external dependency boundary that supports signup verification and password reset.

8. Media/file handling and external storage are handled as separate utilities. `utils/multer.js` suggests multipart upload handling, while `utils/imagekit.js` indicates image/file assets are offloaded to ImageKit rather than stored in MongoDB. This matters for any diagram showing attachment flows, profile images, or document uploads.

9. Operational automation exists in `utils/outpassScheduler.js`, which implies scheduled backend jobs, likely for cleanup or expiry of time-bound outpass data. This is a background-process concern separate from synchronous request handling.

10. The frontend is a single-page app built with React 19 and Vite. `src/main.jsx` bootstraps the app, `App.jsx` likely defines routing/layout, and `src/Pages/` contains the major screens: Home, Login, Signup, OTP verification, Forgot/Reset Password, Dashboard, Admin, Mark Attendance, Mess Snacks, and Role-Based ID. The UI is organized by page rather than feature modules.

11. Frontend state and API communication are centralized. `src/store/authStore.js` suggests client-side auth/session state, while `Utils/axiosInstance.js` and `Utils/apiPaths.js` provide a shared HTTP client and endpoint map. This means the frontend primarily consumes the backend API and does not own core business rules.

12. The main user journeys are: register with college email, verify OTP, log in, and then access student features such as complaints, notices, mess menu, attendance, and profile/ID functions. Admin and committee users follow a separate authenticated path to manage complaints, notices, mess menus, CGPI data, and role-restricted operations.

13. Static assets and documentation are mixed into the frontend public folder, including hostel documentation PDFs and a mess menu PDF. These are served directly to the browser and are not part of the API flow.

14. Overall, the architecture is a role-aware hostel management platform with clear boundaries: React UI on the client, Express controllers and middleware on the server, MongoDB-backed domain models in the middle, and external services for email and file/media handling.

Main entry points: [`BACKEND/controllers`](https://github.com/sanket-singh-sameer/himadriallinoneplatform/tree/main/BACKEND/controllers) (Controllers), [`BACKEND/server.js`](https://github.com/sanket-singh-sameer/himadriallinoneplatform/blob/main/BACKEND/server.js) (Server), [`FRONTEND/src/App.jsx`](https://github.com/sanket-singh-sameer/himadriallinoneplatform/blob/main/FRONTEND/src/App.jsx) (App Shell), [`BACKEND/routes`](https://github.com/sanket-singh-sameer/himadriallinoneplatform/tree/main/BACKEND/routes) (API Routes)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_backend["Backend"]
  node_backend_server["Server<br/>Express entry<br/>[server.js]"]
  node_backend_db(("DB Connect<br/>Mongo connector<br/>[connectDB.js]"))
  node_backend_routes["API Routes<br/>Route layer"]
  node_backend_middleware["Access Control<br/>Auth middleware"]
  node_backend_controllers["Controllers<br/>Business logic"]
  node_backend_models[("Models")]
  node_backend_auth_utils["Auth Utils<br/>Session utilities"]
  node_backend_upload_utils["Upload Utils<br/>File utilities"]
  node_backend_scheduler(("Outpass Job<br/>Scheduler"))
  node_backend_email_gmail["Gmail Mailer<br/>Email provider"]
  node_backend_email_resend["Resend Mailer<br/>Email provider"]
end

subgraph group_frontend["Frontend"]
  node_frontend_main["Main App<br/>React bootstrap<br/>[main.jsx]"]
  node_frontend_app["App Shell<br/>Routing shell<br/>[App.jsx]"]
  node_frontend_pages["Pages<br/>Screens"]
  node_frontend_state["Auth Store<br/>Client state<br/>[authStore.js]"]
  node_frontend_api["API Client<br/>HTTP client"]
  node_frontend_assets["Public Docs<br/>Static assets"]
end

subgraph group_external["External"]
  node_external_mongo[("MongoDB<br/>Datastore")]
  node_external_imagekit(("ImageKit<br/>Media storage"))
  node_external_email(("Email Services<br/>SMTP/API"))
end

node_backend_server -->|"connects"| node_backend_db
node_backend_server -->|"mounts"| node_backend_routes
node_backend_server -->|"uses"| node_backend_middleware
node_backend_server -->|"uses"| node_backend_auth_utils
node_backend_server -->|"uses"| node_backend_upload_utils
node_backend_routes -->|"delegates"| node_backend_controllers
node_backend_routes -->|"guards"| node_backend_middleware
node_backend_controllers -->|"reads/writes"| node_backend_models
node_backend_controllers -->|"uses"| node_backend_auth_utils
node_backend_controllers -->|"sends"| node_backend_email_gmail
node_backend_controllers -->|"sends"| node_backend_email_resend
node_backend_controllers -->|"handles"| node_backend_upload_utils
node_backend_models -->|"persists"| node_external_mongo
node_backend_upload_utils -->|"uploads"| node_external_imagekit
node_backend_email_gmail -->|"delivers"| node_external_email
node_backend_email_resend -->|"delivers"| node_external_email
node_backend_scheduler -->|"jobs"| node_backend_models
node_frontend_main -->|"boots"| node_frontend_app
node_frontend_app -->|"renders"| node_frontend_pages
node_frontend_app -->|"uses"| node_frontend_state
node_frontend_app -->|"calls"| node_frontend_api
node_frontend_pages -->|"fetches"| node_frontend_api
node_frontend_pages -->|"depends on"| node_frontend_state
node_frontend_api -->|"requests"| node_backend_routes
node_frontend_assets -.->|"serves"| node_frontend_pages

click node_backend_server "https://github.com/sanket-singh-sameer/himadriallinoneplatform/blob/main/BACKEND/server.js"
click node_backend_db "https://github.com/sanket-singh-sameer/himadriallinoneplatform/blob/main/BACKEND/config/connectDB.js"
click node_backend_routes "https://github.com/sanket-singh-sameer/himadriallinoneplatform/tree/main/BACKEND/routes"
click node_backend_middleware "https://github.com/sanket-singh-sameer/himadriallinoneplatform/tree/main/BACKEND/middlewares"
click node_backend_controllers "https://github.com/sanket-singh-sameer/himadriallinoneplatform/tree/main/BACKEND/controllers"
click node_backend_models "https://github.com/sanket-singh-sameer/himadriallinoneplatform/tree/main/BACKEND/models"
click node_backend_auth_utils "https://github.com/sanket-singh-sameer/himadriallinoneplatform/tree/main/BACKEND/utils"
click node_backend_upload_utils "https://github.com/sanket-singh-sameer/himadriallinoneplatform/tree/main/BACKEND/utils"
click node_backend_scheduler "https://github.com/sanket-singh-sameer/himadriallinoneplatform/blob/main/BACKEND/utils/outpassScheduler.js"
click node_backend_email_gmail "https://github.com/sanket-singh-sameer/himadriallinoneplatform/tree/main/BACKEND/gmail"
click node_backend_email_resend "https://github.com/sanket-singh-sameer/himadriallinoneplatform/tree/main/BACKEND/resend"
click node_frontend_main "https://github.com/sanket-singh-sameer/himadriallinoneplatform/blob/main/FRONTEND/src/main.jsx"
click node_frontend_app "https://github.com/sanket-singh-sameer/himadriallinoneplatform/blob/main/FRONTEND/src/App.jsx"
click node_frontend_pages "https://github.com/sanket-singh-sameer/himadriallinoneplatform/tree/main/FRONTEND/src/Pages"
click node_frontend_state "https://github.com/sanket-singh-sameer/himadriallinoneplatform/blob/main/FRONTEND/src/store/authStore.js"
click node_frontend_api "https://github.com/sanket-singh-sameer/himadriallinoneplatform/tree/main/FRONTEND/Utils"
click node_frontend_assets "https://github.com/sanket-singh-sameer/himadriallinoneplatform/tree/main/FRONTEND/public"

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_backend_server,node_backend_db,node_backend_routes,node_backend_middleware,node_backend_controllers,node_backend_models,node_backend_auth_utils,node_backend_upload_utils,node_backend_scheduler,node_backend_email_gmail,node_backend_email_resend toneBlue
class node_frontend_main,node_frontend_app,node_frontend_pages,node_frontend_state,node_frontend_api,node_frontend_assets toneAmber
class node_external_mongo,node_external_imagekit,node_external_email toneMint
```

## Components

### Backend

Express API, domain logic, persistence, and integrations

- [Server](https://github.com/sanket-singh-sameer/himadriallinoneplatform/blob/main/BACKEND/server.js): Express entry · Bootstraps the API server, middleware, routes, and startup flow · `BACKEND/server.js`
- [DB Connect](https://github.com/sanket-singh-sameer/himadriallinoneplatform/blob/main/BACKEND/config/connectDB.js): Mongo connector · Creates the MongoDB connection used by the backend · `BACKEND/config/connectDB.js`
- [API Routes](https://github.com/sanket-singh-sameer/himadriallinoneplatform/tree/main/BACKEND/routes): Route layer · Versioned resource routes for auth, admin, complaints, CGPI, equipment, ID, mess, menus, and notices · `BACKEND/routes`
- [Access Control](https://github.com/sanket-singh-sameer/himadriallinoneplatform/tree/main/BACKEND/middlewares): Auth middleware · Token verification plus admin and committee role checks · `BACKEND/middlewares`
- [Controllers](https://github.com/sanket-singh-sameer/himadriallinoneplatform/tree/main/BACKEND/controllers): Business logic · Feature controllers that translate HTTP requests into domain operations · `BACKEND/controllers`
- [Models](https://github.com/sanket-singh-sameer/himadriallinoneplatform/tree/main/BACKEND/models): Mongoose models · Persistence models for users, complaints, CGPI, notices, mess, equipment, outpasses, and rooms · `BACKEND/models`
- [Auth Utils](https://github.com/sanket-singh-sameer/himadriallinoneplatform/tree/main/BACKEND/utils): Session utilities · JWT, cookies, OTP, and user-id helpers for login and verification flows · `BACKEND/utils`
- [Upload Utils](https://github.com/sanket-singh-sameer/himadriallinoneplatform/tree/main/BACKEND/utils): File utilities · Multipart handling and image/file storage integration · `BACKEND/utils`
- [Outpass Job](https://github.com/sanket-singh-sameer/himadriallinoneplatform/blob/main/BACKEND/utils/outpassScheduler.js): Scheduler · Background task for time-based outpass processing · `BACKEND/utils/outpassScheduler.js`
- [Gmail Mailer](https://github.com/sanket-singh-sameer/himadriallinoneplatform/tree/main/BACKEND/gmail): Email provider · Gmail-based mail config and templates for OTP and notifications · `BACKEND/gmail`
- [Resend Mailer](https://github.com/sanket-singh-sameer/himadriallinoneplatform/tree/main/BACKEND/resend): Email provider · Resend-based mail config and templates for OTP and notifications · `BACKEND/resend`

### Frontend

React/Vite single-page client

- [Main App](https://github.com/sanket-singh-sameer/himadriallinoneplatform/blob/main/FRONTEND/src/main.jsx): React bootstrap · Bootstraps the SPA and application shell · `FRONTEND/src/main.jsx`
- [App Shell](https://github.com/sanket-singh-sameer/himadriallinoneplatform/blob/main/FRONTEND/src/App.jsx): Routing shell · Top-level client routing and layout coordination · `FRONTEND/src/App.jsx`
- [Pages](https://github.com/sanket-singh-sameer/himadriallinoneplatform/tree/main/FRONTEND/src/Pages): Screens · Home, auth, dashboard, admin, attendance, mess, and ID screens · `FRONTEND/src/Pages`
- [Auth Store](https://github.com/sanket-singh-sameer/himadriallinoneplatform/blob/main/FRONTEND/src/store/authStore.js): Client state · Shared frontend authentication/session state · `FRONTEND/src/store/authStore.js`
- [API Client](https://github.com/sanket-singh-sameer/himadriallinoneplatform/tree/main/FRONTEND/Utils): HTTP client · Shared axios instance and endpoint path map for backend calls · `FRONTEND/Utils`
- [Public Docs](https://github.com/sanket-singh-sameer/himadriallinoneplatform/tree/main/FRONTEND/public): Static assets · Hostel and mess PDFs served directly to the browser · `FRONTEND/public`

### External

Datastore and third-party services

- **MongoDB**: Datastore · Persistent store for users and hostel domain data
- **ImageKit**: Media storage · External storage for uploaded images and assets
- **Email Services**: SMTP/API · Outbound email delivery for OTP and password reset flows

## Connections

- Server → DB Connect: connects · Initializes the database connection at startup
- Server → API Routes: mounts · Registers versioned API routes
- Server → Access Control: uses · Applies request and role protection middleware
- Server → Auth Utils: uses · Configures auth/session helpers
- Server → Upload Utils: uses · Wires file upload and media handling
- API Routes → Controllers: delegates · Routes forward requests to feature controllers
- API Routes → Access Control: guards · Protects privileged endpoints with auth and role checks
- Controllers → Models: reads/writes · Controllers operate on Mongoose models
- Controllers → Auth Utils: uses · Auth, OTP, cookie, and token operations
- Controllers → Gmail Mailer: sends · Gmail-backed verification and notification mail
- Controllers → Resend Mailer: sends · Resend-backed verification and notification mail
- Controllers → Upload Utils: handles · Processes file uploads and media references
- Models → MongoDB: persists · Stores hostel domain records in MongoDB
- Upload Utils → ImageKit: uploads · Stores media assets externally
- Gmail Mailer → Email Services: delivers · Sends outbound email through Gmail
- Resend Mailer → Email Services: delivers · Sends outbound email through Resend
- Outpass Job → Models: jobs · Runs scheduled outpass maintenance against persisted data
- Main App → App Shell: boots · Starts the React application shell
- App Shell → Pages: renders · Composes the major screens and routes
- App Shell → Auth Store: uses · Reads and updates shared auth state
- App Shell → API Client: calls · Uses the shared API client for backend communication
- Pages → API Client: fetches · Pages consume backend endpoints through the shared client
- Pages → Auth Store: depends on · Pages react to authenticated user state
- API Client → API Routes: requests · Client talks to the Express API layer
- Public Docs → Pages: serves · Static PDFs support the UI and documentation
