Skip to content

Repository files navigation

WasteWise

WasteWise is a fullstack food-waste prediction and analytics platform for restaurants. It combines a React dashboard, NestJS API, MongoDB persistence, and a FastAPI ML microservice serving a Random Forest pipeline.

Stack

  • Frontend: React 18, TypeScript, Vite, Tailwind CSS, Recharts, Framer Motion, Zod
  • Backend: NestJS, TypeScript, MongoDB/Mongoose, JWT access and refresh tokens, WebSockets
  • ML service: FastAPI, scikit-learn, pandas, RandomForestClassifier pipeline
  • Infrastructure: Docker Compose with MongoDB, backend, frontend, ML service

Quick Start

  1. Copy environment files:
cp backend/.env.example backend/.env
cp frontend/.env.example frontend/.env
cp ml-service/.env.example ml-service/.env
  1. Train the model once. The script auto-detects ../food_wastage_data (1).csv from this workspace, or use DATASET_PATH.
cd ml-service
python -m venv .venv
.venv\Scripts\activate
pip install -r requirements.txt
python train.py
  1. Start services:
docker compose up --build
  1. Open http://localhost:5173.

Local Development Without Docker

cd ml-service && uvicorn main:app --reload --port 8000
cd backend && npm install && npm run start:dev
cd frontend && npm install && npm run dev

API Surface

  • POST /api/auth/register
  • POST /api/auth/login
  • POST /api/auth/refresh
  • GET /api/auth/me
  • POST /api/ml/predict
  • GET /api/predictions
  • GET /api/predictions/:id
  • DELETE /api/predictions/:id
  • GET /api/predictions/export/csv
  • GET /api/analytics/summary
  • GET /api/analytics/waste-trend
  • GET /api/analytics/by-event-type
  • GET /api/analytics/by-food-type
  • GET /api/analytics/top-factors
  • GET /api/analytics/seasonality-food-heatmap

Production Notes

  • Replace all JWT secrets before deployment.
  • Serve the frontend from a static host/CDN and restrict FRONTEND_ORIGIN.
  • Store refresh tokens as hashes only; this implementation never persists raw refresh tokens.
  • Train and version the ML pipeline before deployment. Keep models/rf_pipeline.pkl out of git.
  • Use MongoDB Atlas or a managed MongoDB instance for production.

About

WasteWise helps reduce food waste through data-driven predictions and recommendations. The platform combines a React frontend, a NestJS backend, MongoDB, and a Machine Learning service to track waste patterns, analyze trends, predict future losses, and support smarter decision-making for sustainable food management.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages