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.
- 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
- Copy environment files:
cp backend/.env.example backend/.env
cp frontend/.env.example frontend/.env
cp ml-service/.env.example ml-service/.env- Train the model once. The script auto-detects
../food_wastage_data (1).csvfrom this workspace, or useDATASET_PATH.
cd ml-service
python -m venv .venv
.venv\Scripts\activate
pip install -r requirements.txt
python train.py- Start services:
docker compose up --build- Open
http://localhost:5173.
cd ml-service && uvicorn main:app --reload --port 8000
cd backend && npm install && npm run start:dev
cd frontend && npm install && npm run devPOST /api/auth/registerPOST /api/auth/loginPOST /api/auth/refreshGET /api/auth/mePOST /api/ml/predictGET /api/predictionsGET /api/predictions/:idDELETE /api/predictions/:idGET /api/predictions/export/csvGET /api/analytics/summaryGET /api/analytics/waste-trendGET /api/analytics/by-event-typeGET /api/analytics/by-food-typeGET /api/analytics/top-factorsGET /api/analytics/seasonality-food-heatmap
- 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.pklout of git. - Use MongoDB Atlas or a managed MongoDB instance for production.