SmartCanteen: AI-Powered School Canteen Optimisation

1. What SmartCanteen Does

SmartCanteen is an end-to-end, role-based school canteen management web application designed to address four interconnected challenges in school dining:

  1. Long Recess Queues: Students typically have only 30–45 minutes for recess, much of which can be spent waiting at popular stalls.
  2. Unpredictable Food Demand: Vendors must estimate how many portions to prepare, risking sold-out dishes or excess food waste.
  3. Manual Inventory Tracking: Tracking raw ingredient consumption across hundreds of portions can lead to unexpected shortages and inefficient stock management.
  4. Fragmented Order Handling: Concentrated demand during short recess periods makes it difficult to coordinate pre-orders, kitchen preparation, and collection times.

SmartCanteen connects two user groups through a unified platform:

Students, Teachers and Customers

  • View current estimates and forecasts of stall waiting times.
  • Receive recommendations for stalls with shorter predicted queues.
  • Browse menus and filter dishes by price, dietary preferences, and availability.
  • View predicted dish popularity.
  • Place pre-orders for designated 15-minute pickup slots.
  • Track order progress from Pending to Ready for Pickup.

Canteen Staff

  • Forecast demand for individual dishes and adjust preparation targets.
  • Group incoming orders by stall and pickup time.
  • Automate recipe-based ingredient calculations and stock deductions.
  • Receive low-stock alerts and replenishment recommendations.
  • Record unsold portions and analyse food waste.
  • Compare predicted demand with actual sales to evaluate forecast accuracy.

By connecting customer ordering with kitchen operations and inventory planning, SmartCanteen aims to make school canteens more efficient, convenient, and resource-conscious.


2. How It Works

SmartCanteen is built with React, TypeScript, Tailwind CSS, Lucide Icons, and Recharts. Its prototype uses a shared reactive data store (CanteenContext.tsx), persisted through localStorage, and a modular prediction engine (src/utils/predictionEngine.ts).

The system connects customer and staff workflows so that actions in one interface can update related information elsewhere within the same browser.

End-to-End Workflow

1. Pre-order placement and capacity checks

When a customer places an order, the system checks whether the selected 15-minute pickup slot has sufficient preparation capacity (prepCapacityPer15Min) and whether enough portions remain available.

2. Queue and demand recalculation

A confirmed order contributes to the stall's active workload and confirmed pre-order count. Queue estimates and staff demand forecasts update accordingly.

3. Kitchen preparation batching

Orders from the same stall and pickup slot are grouped into kitchen preparation batches. For example, the system can aggregate the number of chicken rice portions required for the 09:45 pickup slot while preserving each customer's individual order number (#SC-XXXX) and collection status.

4. Post-recess feedback

Staff record actual portions sold and unsold. The system calculates forecast error and estimates the financial cost of unsold food, providing data for future preparation decisions.


3. Predictive Analytics and Automation

SmartCanteen currently uses transparent heuristic models based on sample historical canteen data, rather than claiming to use a fully trained machine-learning model. Its modular architecture allows more advanced forecasting models to be integrated in the future.

A. Queue Waiting-Time Prediction

The calculateQueuePredictions function estimates current and upcoming waiting times, classifying queues as Short, Moderate, or Long.

The model considers:

  • Stall preparation capacity: Maximum estimated output per 15-minute window.
  • Active queue backlog: Portions associated with orders that have not yet been completed.
  • Temporal patterns: Historical demand across weekdays and recess periods.
  • Contextual factors: Configured weather conditions and school events.
  • Pickup-slot congestion: Confirmed orders scheduled for upcoming collection windows.

The system ranks stalls by predicted waiting time and generates actionable recommendations. For example, if one stall is expected to have a 20-minute wait while another is estimated at 5 minutes, customers can consider the faster alternative.

Goal: Help students make informed food choices and potentially distribute demand more evenly across stalls.

Waiting times are estimates, not guarantees, and would need to be validated against observed queue data.

B. Food Demand Forecasting

The calculateDemandForecasts function estimates the number of portions required for each dish and generates a suggested preparation range.

Inputs include:

  • Historical sales by dish and time period.
  • Confirmed pre-orders.
  • Day-of-week demand patterns.
  • School events and configurable contextual adjustments.
  • Available ingredient inventory.
  • Previous forecast performance, where sufficient data is available.

For example, if predicted chicken rice demand is 250 portions, the system might recommend preparing 240–260 portions, depending on the configured buffer.

Stock Constraint Warnings

The system cross-checks predicted preparation quantities against ingredient availability using each dish's recipe.

For example, preparing 250 portions of chicken rice at 0.11 kg of rice per portion requires:

250 × 0.11 kg = 27.5 kg of rice

If only 2 kg is available, SmartCanteen flags the shortfall directly in the demand forecast.

Human-in-the-Loop Control

Staff retain control over preparation decisions. They can override suggested quantities, account for operational considerations, and compare their final preparation targets with actual sales after recess.

Goal: Support more informed preparation planning while helping vendors identify potential shortages and overproduction.

C. Recipe-Based Inventory Management

The analyzeInventoryStock function automates ingredient calculations through configurable recipe mappings.

For example, one portion of chicken rice may require:

  • 0.14 kg of chicken.
  • 0.11 kg of rice.
  • 0.03 kg of lettuce.
  • 0.01 L of cooking oil.

The system uses these recipe quantities to calculate ingredient requirements for planned portions.

Key capabilities include:

  • Editable recipe-to-ingredient mappings.
  • Configurable minimum stock thresholds.
  • Inventory adjustments and delivery records.
  • Automatic stock deductions based on the configured policy: Deduct on Accepted or Deduct on Completed.
  • Inventory transaction records linked to orders.
  • Estimated daily ingredient requirements.
  • Estimated days until stockout.
  • Recommended replenishment quantities when stock falls below its threshold.

The system should prevent duplicate deductions and handle cancellations or order modifications through appropriate stock adjustments. Forecast requirements should also account for ingredients already committed to confirmed orders.

Goal: Reduce manual inventory calculations, improve stock visibility, and identify potential shortages earlier.

D. Food Waste Monitoring

After each recess, staff can record portions prepared, sold, and left unsold.

SmartCanteen can then compare predicted demand with actual sales, calculate forecast error, and estimate the cost of unsold food.

Useful metrics include:

  • Mean Absolute Error (MAE) for forecast accuracy.
  • Mean Absolute Percentage Error (MAPE), where actual values permit meaningful calculation.
  • Unsold portions as a percentage of portions prepared.
  • Estimated cost of unsold food.
  • Repeated patterns of overproduction or underproduction.

Over time, these records can be used to refine heuristic parameters or train and evaluate a future forecasting model against a historical-average baseline.

Goal: Give vendors measurable feedback to support better preparation decisions and reduce avoidable food waste.


4. Technical Architecture

SmartCanteen is organised into four logical components:

  • Presentation layer: Separate customer and staff dashboards, menus, queue forecasts, order tracking, inventory management, and analytics.
  • Shared application state: Centralised order, menu, stock, and forecast data.
  • Business logic: Order validation, pickup-slot capacity checks, batch grouping, inventory updates, and cancellation handling.
  • Prediction engine: Modular queue estimation, demand forecasting, inventory analysis, and forecast evaluation.

The current localStorage implementation supports a functional prototype but does not provide real-time synchronisation between different users' devices. A production version would require a shared backend database, authenticated role permissions, server-side validation, and real-time updates.

The system distinguishes between observed data, simulated inputs, and predicted values so users can understand the basis of its recommendations.


5. Expected Impact and Evaluation

SmartCanteen aims to improve canteen operations through more informed decisions and coordinated workflows. Its effectiveness should be evaluated using measurable indicators rather than assumed improvements.

Objective Evaluation metric
Improve queue efficiency Median observed waiting time
Improve forecast accuracy MAE compared with a historical-average baseline
Reduce food waste Unsold portions as a percentage of portions prepared
Improve collection reliability Percentage of orders ready within their pickup slots
Improve inventory management Stockout frequency and inventory discrepancies
Improve preparation efficiency Time spent processing and preparing grouped orders

These metrics can initially be tested using simulated data and subsequently evaluated through a real-world pilot. Any simulated improvements should be clearly distinguished from measured outcomes.


6. Future Development

Potential extensions include:

  • Training forecasting models using actual historical sales and queue observations.
  • Integrating live weather data and school event calendars.
  • Supporting multi-device synchronisation through a shared backend.
  • Improving preparation scheduling using more advanced optimisation algorithms.
  • Evaluating whether stall recommendations improve queue distribution.
  • Measuring the impact of demand forecasting on food waste across multiple recess periods.

Conclusion

SmartCanteen goes beyond conventional food ordering by connecting demand prediction, queue estimation, order batching, and recipe-based inventory management in one system.

By combining transparent predictive analytics with automated workflows and human oversight, SmartCanteen aims to help students spend less time waiting while enabling canteen vendors to make better-informed preparation and inventory decisions.

Built With

Share this project:

Updates

Submission history