How sshgurkiratsingh/istc_major_project works
1. This repository is a multi-part campus project, not a single app. It contains three main runtime surfaces: a Next.js frontend, a Node/Express backend, and an ESP32 firmware project for the physical drink dispenser.
2. The frontend is the primary user interface and is organized by route groups. The important boundaries are /user/[tableID] for table-specific customer ordering, /admin for staff operations, /customMusic for Spotify search, /mqttDashboard for broker message inspection, and /marks for the exam/marks module. Shared UI lives under app/component.
3. The customer flow starts from a table QR code that opens /user/{tableID}. That page renders the ordering experience, cart, checkout, mobile input, RFID login, and the AI chat panel. It uses APIconfig.ts to talk to the backend rather than embedding business logic locally.
4. The admin side is a separate operational console. It consumes the same backend data but focuses on table occupancy, order lifecycle, user CRUD, RFID assignment, and order history/reporting. This is a staff-only control plane, distinct from the customer ordering path.
5. The backend is an Express API server and is the system’s main orchestration layer. Its route modules split responsibilities cleanly: itemListRoute.js handles menu, cart, orders, tables, and reports; userRoute.js handles phone/RFID users and cart sync; llmRoute.js wraps the AI assistant; mqttData.js bridges MQTT publish/logging; and spotifyRoutes.js handles Spotify search and playback control.
6. Persistence is centralized through Prisma with MongoDB. The schema is small and domain-focused: FoodItem and AddOn represent the menu, UserCart stores user identity plus saved cart state, and Order stores table orders, payment status, lifecycle state, and history. That means both customer and admin UI are reading/writing the same operational database.
7. The real-time hardware boundary is MQTT. The backend publishes drink dispense commands to the ESP32, and the ESP32 subscribes to the dispenser topic to drive relays. The firmware also publishes status/buzzer-related feedback, so MQTT is the integration bus between software orders and the physical machine.
8. The ESP32 project is a separate embedded application built with PlatformIO. Its main.cpp is responsible for Wi‑Fi connection, MQTT client behavior, relay control for drink pumps/valves, button inputs for manual dispensing, and LED/status signaling. It is a hardware endpoint, not a web client.
9. Two external service integrations are first-class architecture concerns: OpenAI for the chat assistant and Spotify Web API for music search/playback. The assistant route uses current menu/cart/order context so it can answer transaction-aware questions, while Spotify routes and frontend music pages provide playback and queue management.
10. The repository also contains two secondary frontend modules that are independent of the café order path. The marks area loads PDFs and JSON from public/ to support exam/question-paper viewing and mark-sheet generation, while customMusic provides a focused Spotify search UI. These appear to be co-located modules within the same frontend app rather than separate deployments.
11. A small cacheManager.js module suggests the backend uses local file-based caching for some data, likely to reduce repeated fetches or expensive recomputation. This is a supporting utility, not a core domain boundary.
12. backend/jumbleWord.cpp is a standalone C++ program and is not part of the café system runtime. It should be treated as an unrelated utility/demo file when drawing the architecture diagram.
13. For a diagram, the key top-level boundaries are: browser/tablet frontend, admin frontend, backend API, MongoDB persistence, MQTT broker, ESP32 hardware, and external APIs (OpenAI, Spotify). The main data path is customer order → backend validation/persistence → MQTT command dispatch → dispenser execution, with admin and chat/music features reading from the same backend state.
Main entry points: index.js API server · layout.tsx App shell · [tableID]/page.tsx Customer order · admin/page.tsx Admin console
Components 24
Frontend
Next.js app with customer, admin, music, MQTT, and marks surfaces.
- App shell · Root layout, providers, and shared UI building blocks.
frontend/app/layout.tsx - Customer order · Table-scoped ordering flow with cart, checkout, login, and chat.
frontend/app/user/[tableID]/page.tsx - Checkout · Order finalization and payment-oriented interaction.
frontend/app/user/[tableID]/CheckoutPage.tsx - AI chat · Chat panel for transaction-aware menu and order help.
frontend/app/user/[tableID]/LlmChat.tsx - Admin console · Operational entry point for staff workflows.
frontend/app/admin/page.tsx - Table status · Occupancy and table lifecycle monitoring.
frontend/app/admin/tableStatus/page.tsx - User admin · User CRUD and RFID assignment management.
frontend/app/admin/users/page.tsx - Order history · Order reporting and lifecycle inspection.
frontend/app/admin/orderHistory/page.tsx - Music search · Spotify search and playback control UI.
frontend/app/customMusic/page.tsx - MQTT dashboard · Message inspection and broker connectivity tools.
frontend/app/mqttDashboard/page.tsx - Marks module · Exam PDF and JSON-based marks/question-paper workflows.
frontend/app/marks/page.tsx
Backend
Express API, Prisma persistence layer, and integration routes.
- API server · Main orchestration layer for orders, users, chat, MQTT, and Spotify.
backend/index.js - Menu & orders · Menu, cart, table, order, and report operations.
backend/routes/itemListRoute.js - Users & carts · Phone/RFID users and cart synchronization.
backend/routes/userRoute.js - LLM assistant · OpenAI-backed chat orchestration with context from menu and orders.
backend/routes/llmRoute.js - MQTT bridge · Publish and log drink dispenser commands and broker data.
backend/routes/mqttData.js - Spotify API · Search and playback control for music features.
backend/routes/spotifyRoutes.js - Cache manager · Local file-based caching for repeated or expensive backend data.
backend/customModule/cacheManager.js - Prisma data · MongoDB-backed schema for food items, add-ons, carts, and orders.
backend/prisma/schema.prisma
ESP32 Firmware
PlatformIO embedded controller for the physical dispenser.
- ESP32 firmware · PlatformIO firmware for Wi-Fi, MQTT, relay, button, and status control.
ESP32 Code/Drink_Dis_V0.1/src/main.cpp
External Systems
Third-party APIs, broker, and database boundary.
- MQTT broker · Integration bus between backend commands and dispenser hardware.
- MongoDB · Operational persistence for shared frontend and backend state.
- OpenAI · Generative assistant provider.
- Spotify Web API · Music search and playback provider.
Connections 30
- App shell → Customer order: renders · Application shell hosts the main customer route group.
- App shell → Admin console: renders · Application shell hosts the staff console.
- App shell → Music search: renders · Shell also serves the music module.
- App shell → MQTT dashboard: renders · Shell also serves the MQTT dashboard.
- App shell → Marks module: renders · Shell also serves the marks module.
- Customer order → Checkout: includes · Ordering flow hands off to checkout.
- Customer order → AI chat: includes · Ordering flow embeds AI assistance.
- Customer order → API server: calls · Customer UI uses backend APIs through APIconfig.
- Admin console → Table status: navigates · Staff console links to table monitoring.
- Admin console → User admin: navigates · Staff console links to user management.
- Admin console → Order history: navigates · Staff console links to order history.
- Table status → API server: calls · Admin views consume the same operational backend.
- User admin → API server: calls · User CRUD and RFID assignment go through the API.
- Order history → API server: calls · Reporting reads backend order state.
- API server → Menu & orders: routes · Order, menu, table, and report orchestration.
- API server → Users & carts: routes · User and cart operations.
- API server → LLM assistant: routes · Chat assistant orchestration.
- API server → MQTT bridge: routes · MQTT publish and broker logging.
- API server → Spotify API: routes · Music search and playback control.
- API server → Cache manager: uses · Shared cache support for backend data.
- Menu & orders → Prisma data: persists · Menu and order data are stored through Prisma.
- Users & carts → Prisma data: persists · User and cart state are stored through Prisma.
- LLM assistant → OpenAI: invokes · Assistant calls the generative model provider.
- LLM assistant → Prisma data: reads · Assistant uses menu, cart, and order context.
- Spotify API → Spotify Web API: invokes · Backend proxies Spotify search and playback requests.
- MQTT bridge → MQTT broker: publishes · Backend publishes dispenser commands and logs.
- ESP32 firmware → MQTT broker: subscribes · Firmware listens for dispense commands over MQTT.
- MQTT broker → ESP32 firmware: delivers · Broker carries command and status messages to hardware.
- ESP32 firmware → MQTT broker: publishes · Firmware sends status and buzzer feedback.
- Prisma data → MongoDB: stores · Prisma schema is backed by MongoDB.