# sathvikpd7/smart-hostel-food-management architecture

> Architecture diagram of the GitHub repository sathvikpd7/smart-hostel-food-management, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-11-30). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/sathvikpd7/smart-hostel-food-management
- Repository: https://github.com/sathvikpd7/smart-hostel-food-management

## Overview

This is a student meal-booking and cafeteria administration application. Students authenticate, browse menus, book meals, view booking history and QR information, and submit ratings or feedback; administrators manage menus and users, verify bookings, and review analytics and sentiment. The backend owns API workflows and persists application records in PostgreSQL, with recommendation and sentiment services supporting meal discovery and feedback analysis. The README is empty, and many frontend modules were not excerpted, so some feature connections are left unverified rather than inferred.

Main entry points: [`frontend/src/App.tsx`](https://github.com/sathvikpd7/smart-hostel-food-management/blob/main/frontend/src/App.tsx) (Student portal), [`frontend/src/AdminApp.tsx`](https://github.com/sathvikpd7/smart-hostel-food-management/blob/main/frontend/src/AdminApp.tsx) (Admin portal), [`backend/server.ts`](https://github.com/sathvikpd7/smart-hostel-food-management/blob/main/backend/server.ts) (API workflows), [`frontend/src/contexts/MealContext.tsx`](https://github.com/sathvikpd7/smart-hostel-food-management/blob/main/frontend/src/contexts/MealContext.tsx) (Meal and booking state)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_client["Student application"]
  node_student["Student portal<br/>[App.tsx]"]
  node_student_dash["Student dashboard"]
  node_meal_state["Meal and booking state<br/>[MealContext.tsx]"]
  node_student_meals["Meal browsing<br/>[WeeklyMenuPage.tsx]"]
  node_booking_history["Booking history"]
  node_feedback["Meal feedback<br/>[FeedbackPage.tsx]"]
  node_recommendations["Meal recommendations"]
  node_qr_display["QR display<br/>[QRCodeDisplay.tsx]"]
  node_auth["Authentication state<br/>[AuthContext.tsx]"]
  node_sse["Live event client<br/>[sseClient.ts]"]
end

subgraph group_admin["Administration"]
  node_admin_portal["Admin portal<br/>[AdminApp.tsx]"]
  node_menu_admin["Menu management"]
  node_ai_planner["AI menu planner<br/>[AIMenuPlanner.tsx]"]
  node_qr_verify["QR verification"]
  node_analytics["Analytics and reports"]
  node_user_admin["User management"]
  node_sentiment_ui["Sentiment dashboard"]
end

subgraph group_api["Backend API"]
  node_server["API workflows<br/>[server.ts]"]
  node_validation["Request validation<br/>[validate.ts]"]
end

subgraph group_data["Persistence and services"]
  node_database[("PostgreSQL database<br/>[database.ts]")]
  node_cache[("TTL cache<br/>[cache.service.ts]")]
  node_meal_reco["Recommendation engine"]
  node_sentiment["Sentiment analysis"]
end

node_student_actor(("Student"))
node_admin_actor(("Administrator"))

node_student_actor -.->|"uses"| node_student
node_student -.->|"presents"| node_student_dash
node_student_dash -->|"reads state"| node_meal_state
node_student_dash -->|"reads identity"| node_auth
node_meal_state -->|"reads identity"| node_auth
node_meal_state -->|"subscribes"| node_sse
node_student -.->|"routes to"| node_student_meals
node_student -.->|"routes to"| node_booking_history
node_student -.->|"routes to"| node_feedback
node_student -.->|"offers"| node_recommendations
node_student -.->|"offers"| node_qr_display
node_admin_actor -.->|"uses"| node_admin_portal
node_admin_portal -.->|"routes to"| node_menu_admin
node_admin_portal -.->|"offers"| node_ai_planner
node_admin_portal -.->|"routes to"| node_qr_verify
node_admin_portal -.->|"routes to"| node_analytics
node_admin_portal -.->|"routes to"| node_user_admin
node_admin_portal -.->|"offers"| node_sentiment_ui
node_server -->|"initializes and queries"| node_database
node_server -->|"validates requests"| node_validation
node_server -->|"uses cache"| node_cache
node_server -->|"generates recommendations"| node_meal_reco
node_server -->|"analyzes feedback"| node_sentiment
node_meal_state -.->|"requests API data"| node_server
node_sse -.->|"opens event stream"| node_server

click node_student "https://github.com/sathvikpd7/smart-hostel-food-management/blob/main/frontend/src/App.tsx"
click node_student_dash "https://github.com/sathvikpd7/smart-hostel-food-management/blob/main/frontend/src/pages/student/StudentDashboard.tsx"
click node_meal_state "https://github.com/sathvikpd7/smart-hostel-food-management/blob/main/frontend/src/contexts/MealContext.tsx"
click node_student_meals "https://github.com/sathvikpd7/smart-hostel-food-management/blob/main/frontend/src/pages/student/WeeklyMenuPage.tsx"
click node_booking_history "https://github.com/sathvikpd7/smart-hostel-food-management/blob/main/frontend/src/pages/student/BookingHistoryPage.tsx"
click node_feedback "https://github.com/sathvikpd7/smart-hostel-food-management/blob/main/frontend/src/pages/student/FeedbackPage.tsx"
click node_recommendations "https://github.com/sathvikpd7/smart-hostel-food-management/blob/main/frontend/src/services/mealRecommendation.ts"
click node_qr_display "https://github.com/sathvikpd7/smart-hostel-food-management/blob/main/frontend/src/components/student/QRCodeDisplay.tsx"
click node_auth "https://github.com/sathvikpd7/smart-hostel-food-management/blob/main/frontend/src/contexts/AuthContext.tsx"
click node_sse "https://github.com/sathvikpd7/smart-hostel-food-management/blob/main/frontend/src/services/sseClient.ts"
click node_admin_portal "https://github.com/sathvikpd7/smart-hostel-food-management/blob/main/frontend/src/AdminApp.tsx"
click node_menu_admin "https://github.com/sathvikpd7/smart-hostel-food-management/blob/main/frontend/src/pages/admin/MenuManagementPage.tsx"
click node_ai_planner "https://github.com/sathvikpd7/smart-hostel-food-management/blob/main/frontend/src/components/admin/AIMenuPlanner.tsx"
click node_qr_verify "https://github.com/sathvikpd7/smart-hostel-food-management/blob/main/frontend/src/pages/admin/QrVerificationPage.tsx"
click node_analytics "https://github.com/sathvikpd7/smart-hostel-food-management/blob/main/frontend/src/pages/admin/AnalyticsDashboardPage.tsx"
click node_user_admin "https://github.com/sathvikpd7/smart-hostel-food-management/blob/main/frontend/src/pages/admin/UserManagementPage.tsx"
click node_sentiment_ui "https://github.com/sathvikpd7/smart-hostel-food-management/blob/main/frontend/src/components/admin/SentimentDashboard.tsx"
click node_server "https://github.com/sathvikpd7/smart-hostel-food-management/blob/main/backend/server.ts"
click node_validation "https://github.com/sathvikpd7/smart-hostel-food-management/blob/main/backend/src/middleware/validate.ts"
click node_database "https://github.com/sathvikpd7/smart-hostel-food-management/blob/main/backend/src/config/database.ts"
click node_cache "https://github.com/sathvikpd7/smart-hostel-food-management/blob/main/backend/src/services/cache.service.ts"
click node_meal_reco "https://github.com/sathvikpd7/smart-hostel-food-management/blob/main/backend/src/services/mealRecommendation.ts"
click node_sentiment "https://github.com/sathvikpd7/smart-hostel-food-management/blob/main/backend/src/services/sentimentAnalysis.ts"

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_student,node_student_dash,node_meal_state,node_student_meals,node_booking_history,node_feedback,node_recommendations,node_qr_display,node_auth,node_sse toneBlue
class node_admin_portal,node_menu_admin,node_ai_planner,node_qr_verify,node_analytics,node_user_admin,node_sentiment_ui toneAmber
class node_server,node_validation toneMint
class node_database,node_cache,node_meal_reco,node_sentiment toneRose
class node_student_actor,node_admin_actor toneIndigo
```

## Components

### Student application

- [Student portal](https://github.com/sathvikpd7/smart-hostel-food-management/blob/main/frontend/src/App.tsx): `frontend/src/App.tsx`
- [Student dashboard](https://github.com/sathvikpd7/smart-hostel-food-management/blob/main/frontend/src/pages/student/StudentDashboard.tsx): `frontend/src/pages/student/StudentDashboard.tsx`
- [Meal and booking state](https://github.com/sathvikpd7/smart-hostel-food-management/blob/main/frontend/src/contexts/MealContext.tsx): `frontend/src/contexts/MealContext.tsx`
- [Meal browsing](https://github.com/sathvikpd7/smart-hostel-food-management/blob/main/frontend/src/pages/student/WeeklyMenuPage.tsx): `frontend/src/pages/student/WeeklyMenuPage.tsx`
- [Booking history](https://github.com/sathvikpd7/smart-hostel-food-management/blob/main/frontend/src/pages/student/BookingHistoryPage.tsx): `frontend/src/pages/student/BookingHistoryPage.tsx`
- [Meal feedback](https://github.com/sathvikpd7/smart-hostel-food-management/blob/main/frontend/src/pages/student/FeedbackPage.tsx): `frontend/src/pages/student/FeedbackPage.tsx`
- [Meal recommendations](https://github.com/sathvikpd7/smart-hostel-food-management/blob/main/frontend/src/services/mealRecommendation.ts): `frontend/src/services/mealRecommendation.ts`
- [QR display](https://github.com/sathvikpd7/smart-hostel-food-management/blob/main/frontend/src/components/student/QRCodeDisplay.tsx): `frontend/src/components/student/QRCodeDisplay.tsx`
- [Authentication state](https://github.com/sathvikpd7/smart-hostel-food-management/blob/main/frontend/src/contexts/AuthContext.tsx): `frontend/src/contexts/AuthContext.tsx`
- [Live event client](https://github.com/sathvikpd7/smart-hostel-food-management/blob/main/frontend/src/services/sseClient.ts): `frontend/src/services/sseClient.ts`

### Administration

- [Admin portal](https://github.com/sathvikpd7/smart-hostel-food-management/blob/main/frontend/src/AdminApp.tsx): `frontend/src/AdminApp.tsx`
- [Menu management](https://github.com/sathvikpd7/smart-hostel-food-management/blob/main/frontend/src/pages/admin/MenuManagementPage.tsx): `frontend/src/pages/admin/MenuManagementPage.tsx`
- [AI menu planner](https://github.com/sathvikpd7/smart-hostel-food-management/blob/main/frontend/src/components/admin/AIMenuPlanner.tsx): `frontend/src/components/admin/AIMenuPlanner.tsx`
- [QR verification](https://github.com/sathvikpd7/smart-hostel-food-management/blob/main/frontend/src/pages/admin/QrVerificationPage.tsx): `frontend/src/pages/admin/QrVerificationPage.tsx`
- [Analytics and reports](https://github.com/sathvikpd7/smart-hostel-food-management/blob/main/frontend/src/pages/admin/AnalyticsDashboardPage.tsx): `frontend/src/pages/admin/AnalyticsDashboardPage.tsx`
- [User management](https://github.com/sathvikpd7/smart-hostel-food-management/blob/main/frontend/src/pages/admin/UserManagementPage.tsx): `frontend/src/pages/admin/UserManagementPage.tsx`
- [Sentiment dashboard](https://github.com/sathvikpd7/smart-hostel-food-management/blob/main/frontend/src/components/admin/SentimentDashboard.tsx): `frontend/src/components/admin/SentimentDashboard.tsx`

### Backend API

- [API workflows](https://github.com/sathvikpd7/smart-hostel-food-management/blob/main/backend/server.ts): `backend/server.ts`
- [Request validation](https://github.com/sathvikpd7/smart-hostel-food-management/blob/main/backend/src/middleware/validate.ts): `backend/src/middleware/validate.ts`

### Persistence and services

- [PostgreSQL database](https://github.com/sathvikpd7/smart-hostel-food-management/blob/main/backend/src/config/database.ts): `backend/src/config/database.ts`
- [TTL cache](https://github.com/sathvikpd7/smart-hostel-food-management/blob/main/backend/src/services/cache.service.ts): `backend/src/services/cache.service.ts`
- [Recommendation engine](https://github.com/sathvikpd7/smart-hostel-food-management/blob/main/backend/src/services/mealRecommendation.ts): `backend/src/services/mealRecommendation.ts`
- [Sentiment analysis](https://github.com/sathvikpd7/smart-hostel-food-management/blob/main/backend/src/services/sentimentAnalysis.ts): `backend/src/services/sentimentAnalysis.ts`

### Other components

- **Student**
- **Administrator**

## Connections

- Student → Student portal: uses
- Student portal → Student dashboard: presents
- Student dashboard → Meal and booking state: reads state (evidence: `frontend/src/pages/student/StudentDashboard.tsx`)
- Student dashboard → Authentication state: reads identity (evidence: `frontend/src/pages/student/StudentDashboard.tsx`)
- Meal and booking state → Authentication state: reads identity (evidence: `frontend/src/contexts/MealContext.tsx`)
- Meal and booking state → Live event client: subscribes (evidence: `frontend/src/contexts/MealContext.tsx`)
- Student portal → Meal browsing: routes to
- Student portal → Booking history: routes to
- Student portal → Meal feedback: routes to
- Student portal → Meal recommendations: offers
- Student portal → QR display: offers
- Administrator → Admin portal: uses
- Admin portal → Menu management: routes to
- Admin portal → AI menu planner: offers
- Admin portal → QR verification: routes to
- Admin portal → Analytics and reports: routes to
- Admin portal → User management: routes to
- Admin portal → Sentiment dashboard: offers
- API workflows → PostgreSQL database: initializes and queries (evidence: `backend/server.ts`)
- API workflows → Request validation: validates requests (evidence: `backend/server.ts`)
- API workflows → TTL cache: uses cache (evidence: `backend/server.ts`)
- API workflows → Recommendation engine: generates recommendations (evidence: `backend/server.ts`)
- API workflows → Sentiment analysis: analyzes feedback (evidence: `backend/server.ts`)
- Meal and booking state → API workflows: requests API data
- Live event client → API workflows: opens event stream
