How harilakshman25/kgp-mess-hub works
Project type and purpose
• This is a full-stack web application called “KGP MessHub” for managing hostel mess operations at IIT Kharagpur.
• Frontend: React (Vite), Tailwind CSS, React Router, React Query, Context API.
• Backend: Node.js + Express, MongoDB (Mongoose ORM), JWT auth, Multer file uploads, Nodemailer email workflows.
• Purpose: Provide role-based access for admins, mess managers, and students to manage menus, orders, complaints, analytics, and student data.
File structure
• Top-level dirs:
• client/ — React app with src/components, src/context, src/hooks, src/services (API wrappers), src/utils, src/pages
• server/ — Express app with config (DB, keys), controllers (business logic), routes (REST endpoints), models (MongoDB schemas), middleware (auth, validation, file uploads), utils (CSV parser, email, helpers)
• Supporting files: .gitignore, start.sh (launcher), assets/ for screenshots.
• Build/config scripts: client/vite.config.js, tailwind.config.js, server/server.js, npm scripts in package.json.
README for additional insights
• Multi-role authentication flow requiring admin approval for managers.
• Data flows: CSV uploads → student records; client API calls → controllers; controllers → models → MongoDB.
• External integrations: Nodemailer for emails, CSV parser for batch uploads, potential QR code library.
• Future features hint at QR code generation, real-time updates, analytics, inventory tracking.
a. Main components to include:
• Client (React SPA)
• Server (Express API)
• Database (MongoDB)
• File Storage (uploads folder for CSVs and images)
• External Services: Email service (SMTP via Nodemailer), CSV parsing utility
• Authentication (JWT token store)
b. Relationships & interactions:
1. User browsers → React SPA → React Router navigates pages.
2. SPA makes HTTP(S) calls (via axios/fetch in services) to Express REST API endpoints (/api/auth, /api/students, /api/orders, etc.).
3. Express middleware layer: JWT validation → dispatch to controllers.
4. Controllers invoke Mongoose models → read/write to MongoDB.
5. File-upload endpoints use Multer middleware → store CSVs in server/uploads → CSV parser utility populates Student model.
6. Nodemailer utility sends confirmation or approval emails.
7. React Context Providers (AuthContext, CartContext, ThemeContext) manage client-side state.
c. Architectural patterns & design principles:
• Layered architecture on the server:
– Routes → Middleware → Controllers → Models → Database
• Component-based design on the client with separation of presentational and container components.
• Context API for cross-cutting concerns (auth, theme, cart).
• Hooks for reusable logic (useApi, useAuth, useLocalStorage).
• Single Page Application communicating over RESTful API.
• Role-based access control enforced both client-side (ProtectedRoute) and server-side (auth middleware).
d. Key technologies/frameworks:
• Frontend: React, Vite, Tailwind CSS, React Query, React Hook Form, React Router
• Backend: Node.js, Express.js, Mongoose, Multer, JSON Web Tokens, Nodemailer
• Database: MongoDB
• Utilities: csv-parse, email service helper, custom helpers
Detail without overthinking
• Server modules by domain: auth, student management, order processing, complaint handling, admin stats, item catalog.
• Client modules: Auth components, Dashboard components (Admin, Manager, Student), common UI elements, context providers, and hooks.
• Both synchronous (HTTP) and asynchronous (email, CSV processing) interactions.
• Notes for future extensions (QR code service, real-time updates) to indicate system extensibility.