How nithin4747/hostel-food-management works
Purpose and Runtime
Hostel Food Management System is a React/Vite client for student, kitchen-supervisor, and admin meal operations: meal intent and physical attendance, leave handling, dashboards, profiles, and user management. A Node/Express server also exists, while Firebase Auth and Firestore are the stated identity/data backbone. Key entry points: client/src/main.tsx, client/src/App.tsx, server/index.ts.
Client Application Shell and Routing
App.tsx is the likely composition root for page routing, global providers, and role-specific navigation. The authenticated application shell is separated into layout primitives, allowing pages to share sidebar/top-bar structure. Public authentication pages are distinct from operational routes.
Paths: client/src/App.tsx, client/src/components/layout/Layout.tsx, client/src/components/auth/PrivateRoute.tsx.
Identity, Authorization, and User Roles
Firebase authentication is encapsulated through an auth context and supporting Firebase modules. PrivateRoute forms the client-side access boundary; role-based dashboards and administration pages indicate at least student, kitchen, and admin experiences. Firestore rules provide the server-enforced authorization boundary.
Paths: client/src/contexts/AuthContext.tsx, client/src/firebase/auth.ts, firestore.rules.
Role-Specific Operations and Dashboards
Dashboard pages split views by operating role: admins oversee users and system-level status, kitchen users manage food-facing workflow, and students manage their own participation. Reusable cards present attendance trends, meal status, risk/activity, and AI-verification-oriented indicators.
Paths: client/src/pages/dashboard/AdminDashboard.tsx, client/src/pages/dashboard/KitchenDashboard.tsx, client/src/pages/dashboard/StudentDashboard.tsx.
Dual Meal Attendance Flow
The central business flow is two-stage meal participation: students submit a meal preference/intention in advance, then attendance is recorded at the meal. Attendance tracking and meal tracking pages orchestrate these workflows; dedicated hooks mediate their data access. This is the principal boundary between planning demand and confirming food service.
Paths: client/src/components/attendance/MealPreferenceForm.tsx, client/src/components/attendance/MealAttendanceMarker.tsx, client/src/hooks/useAttendance.js.
Leave and Student Profile Flow
Students can submit leave requests, while management users review them. Student records/profile views supply an adjacent identity and operational context, likely used for attendance, leave, and administration.
Paths: client/src/pages/leave/LeaveRequestPage.tsx, client/src/pages/leave/LeaveManagement.tsx, client/src/pages/profile/ProfilePage.tsx.
Data and Backend Boundaries
Firebase configuration modules connect the browser to Firebase Auth/Firestore, with Firestore indexes supporting query patterns. The repository additionally has an Express server with route, storage, and database abstractions, plus a shared schema—suggesting a parallel or transitional server-backed API/data path. Engineers should establish which path is authoritative before extending domain features.
Paths: client/src/firebase/config.ts, server/routes.ts, shared/schema.ts.
Infrastructure
The main runtime is TypeScript React on Vite, styled with Tailwind. Firebase deployment/configuration and Firestore policy/index definitions are committed at the root. Node/Express is available for backend execution; Drizzle configuration and server database modules indicate potential relational persistence integration.
Paths: vite.config.ts, firebase.json, server/db.ts.
Main entry points: App.tsx App shell & routing · config.ts Firestore · routes.ts API routes · useAttendance.js Attendance data hook
Components 18
React/Vite Client
- Vite runtime
vite.config.ts - App shell & routing
client/src/App.tsx - Authenticated layout
client/src/components/layout/Layout.tsx - Private route
client/src/components/auth/PrivateRoute.tsx - Auth context
client/src/contexts/AuthContext.tsx - Role dashboards · Admin, kitchen, and student operating views.
client/src/pages/dashboard/AdminDashboard.tsx - Meal intent · Students state meal preference in advance.
client/src/components/attendance/MealPreferenceForm.tsx - Meal attendance · Physical meal attendance is recorded.
client/src/components/attendance/MealAttendanceMarker.tsx - Attendance data hook
client/src/hooks/useAttendance.js - Leave workflow · Student requests are reviewed by management.
client/src/pages/leave/LeaveRequestPage.tsx - Student profile
client/src/pages/profile/ProfilePage.tsx
Firebase Backbone
- Firebase Auth
client/src/firebase/auth.ts - Firestore
client/src/firebase/config.ts - Firestore rules · Enforces data authorization rules.
firestore.rules
Express Data Path
A parallel or transitional backend path.
- Express server
server/index.ts - API routes
server/routes.ts - Shared schema
shared/schema.ts - Relational database access · Potential relational persistence path.
server/db.ts
Connections 20
- Vite runtime → App shell & routing: boots
- App shell & routing → Authenticated layout: composes
- App shell & routing → Private route: guards routes with
- App shell & routing → Role dashboards: routes to
- App shell & routing → Leave workflow: routes to
- App shell & routing → Student profile: routes to
- Private route → Auth context: uses
- Auth context → Firebase Auth: authenticates through
- Role dashboards → Attendance data hook: reads operational data
- Meal intent → Attendance data hook: submits intent through
- Meal attendance → Attendance data hook: records attendance through
- Meal intent → Meal attendance: intent precedes
- Attendance data hook → Firestore: accesses
- Leave workflow → Firestore: stores requests
- Student profile → Firestore: reads student record
- Firestore rules → Firestore: authorizes access to
- Express server → API routes: serves
- API routes → Shared schema: uses
- API routes → Relational database access: persists through
- Firestore → API routes: authority unresolved · Confirm whether Firebase or the server path is authoritative.