BawarchiAI is an end-to-end, production-grade AI platform designed to minimize food waste in canteens and institutional kitchens. By blending machine learning predictions with historical baseline telemetry, the platform optimizes preparation quantities, registers leftover surplus, and routes surplus food to local NGOs.
- Live Web App: https://bawarchi-ai-rust.vercel.app
- Go Backend Server API: https://bawarchiai-backend.onrender.com
- Python FastAPI ML Service: https://bawarchiai-ml.onrender.com
-
In-Sample Model Fit (
$R^2$ ):99.92%(MAE =1.17 kg| RMSE =1.53 kg) -
Out-of-Sample Generalization (5-Fold Cross-Validation
$R^2$ ):97.88%(MAE =5.70 kg| RMSE =7.65 kg) -
Inference Latency:
<350ms(hybrid forecast evaluation) -
Ecological & Operational Impact:
-
Food Saved:
5,698 kg(includes 15% AI-prevented waste + NGO redistribution) -
Meals Redistributed:
22,793 meals(standardized 250g portion size) -
$CO_2$ Emissions Prevented:13,106 kg(EPA/WRI conversion factor of 2.3x)
-
Food Saved:
graph TD
User[Web Client / Operator] -->|HTTPS| FE[Next.js Frontend: Vercel]
FE -->|JSON Requests| BE[Go Gin REST API: Render]
BE -->|SQL queries via PgBouncer Pooler| DB[(Supabase Postgres)]
BE -->|Predict / Train requests| ML[FastAPI ML Service: Render]
ML -->|Trains XGBoost Regressor| Models[(Models Directory)]
Models -.->|Reads metrics & models| ML
The ML service uses a blended forecasting algorithm to combine statistical averages with predictive regressor weights:
Recommendations are scaled using Confidence Multipliers based on historical sample support (
-
High Confidence (
$N \ge 20$ ,$CV < 0.15$ ):1.05xsafety buffer. -
Medium Confidence (
$N \ge 8$ ,$CV < 0.30$ ):1.10xsafety buffer. -
Low Confidence (Fallback):
1.18xsafety buffer (prevents student shortages).
| Component | Technology | Description |
|---|---|---|
| Frontend | TypeScript, Next.js 15, TailwindCSS, Recharts | Dynamic dashboards, Recharts feature importances, and NGO logs |
| Backend | Go (Golang), Gin Gonic, pgx/v5 | REST API, database connection pooler, middleware CORS routing |
| ML Service | Python 3.10+, FastAPI, XGBoost, Pandas, Scikit-Learn | Training pipeline, 5-Fold Cross-Validation, Feature Importances |
| Database | PostgreSQL (Supabase), PgBouncer | Serverless SQL hosting, transaction pooling using Simple Protocol |
| Infrastructure | Docker, Docker Compose, GitHub Actions | Multi-container local orchestration and CI/CD triggers |
├── backend/ # Go REST API Server
│ ├── cmd/server/ # Entry point (main.go)
│ ├── internal/ # Core modules (forecast, surplus, impact, donation)
│ └── Dockerfile
├── frontend/ # Next.js App Router Frontend
│ ├── app/ # React Page Views & Layouts
│ ├── components/ # Redesigned Green Zero-Waste Components
│ └── lib/api.ts # Non-cached API client fetching
├── ml-service/ # Python FastAPI Machine Learning service
│ ├── app/ # Models training, encoders, features preprocessing
│ └── Dockerfile
└── docker-compose.yml # Local orchestration stack
- Install Docker and Docker Compose.
Clone the repository and spin up the backend, database, and machine learning services:
git clone https://github.com/AkshajSonar/BAWARCHI.AI.git
cd BAWARCHI.AI
docker compose up --build -dIn a separate terminal, seed the database with canteens training data and trigger model retraining:
# Seed local Postgres
docker exec -i bawarchiai-postgres-1 psql -U plateai -d plateai < path/to/seed.sql
# Trigger retraining on local Go server
curl -X POST http://localhost:8080/forecast/retrainNavigate to the frontend directory, install dependencies, and run Next.js:
cd frontend
npm install
npm run devOpen http://localhost:3000 to view the application.