AI-Based Sustainable Packaging Recommendation System built with Flask, Machine Learning, and PostgreSQL.
EcoPack-AI recommends the most suitable packaging material based on:
- Product category
- Fragility level
- Shipping type
- Sustainability priority
The system predicts and ranks materials using:
- Packaging cost
- CO₂ impact
- Material suitability score
Recommendations are stored in the database and visualized in a BI-style dashboard with analytics and export options.
- Intelligent recommendation engine with category + fragility filtering
- Dynamic weighted scoring logic based on sustainability priority and shipping type
- Interactive dashboard analytics (distribution, ranking, trends)
- Recommendation history tracking with clear-history endpoint
- Export support (PDF / Excel on frontend)
- Environment-based DB configuration (PostgreSQL + SQLite fallback)
The platform follows a layered architecture from UI → Flask API → ML models → PostgreSQL → BI dashboard.
- Backend: Python, Flask, Flask-CORS
- Data/ML: Pandas, NumPy, Scikit-learn, XGBoost, Joblib
- Database: PostgreSQL (production), SQLite (local fallback), SQLAlchemy
- Frontend: HTML, CSS, JavaScript, Chart.js, Plotly
- Deployment: Gunicorn, Render
EcoPackAI/
├── backend/
│ ├── app.py
│ ├── requirements.txt
│ ├── rf_cost_model.pkl
│ ├── xgb_co2_model.pkl
│ └── scaler.pkl
├── frontend/
│ ├── index.html
│ ├── style.css
│ ├── script.js
│ └── config.js
├── images/
│ ├── architecture_new.png
│ ├── dashboard-main.png
│ ├── material-distribution.png
│ ├── recommendation-trends.png
│ ├── model-metrics-cost.png
│ ├── model-metrics-co2.png
│ └── best-material-output.png
├── model_training.ipynb
├── CHANGELOG.md
├── CONTRIBUTING.md
├── LICENSE
├── Procfile
├── runtime.txt
└── README.md
GET /→ Health checkPOST /recommend→ Generate top material recommendationsGET /history→ Retrieve recommendation historyPOST /history/clear→ Clear stored historyGET /analytics→ Dashboard analytics aggregates
Create a .env file using .env.example:
API_KEY=change_me
DATABASE_URL=postgresql://username:password@localhost:5432/ecopackaiNote: Current code requires
DATABASE_URLfor PostgreSQL; if not provided, it automatically uses local SQLite (ecopackai.db) for development.
-
Open terminal in project root:
cd backend -
Create and activate virtual environment (Windows):
python -m venv venv venv\Scripts\activate
-
Install dependencies:
pip install -r requirements.txt
-
Start backend:
python app.py
-
Open frontend file
frontend/index.htmlin browser (or host via a simple static server).
-
Build Command
pip install -r backend/requirements.txt
-
Start Command
gunicorn backend.app:app
-
Required Environment Variables
DATABASE_URLAPI_KEY(reserved for secured endpoint enhancements)
Models are evaluated using:
- MAE
- RMSE
- R² Score
Two model roles:
- Random Forest → packaging cost prediction
- XGBoost → CO₂ prediction used in ranking
Random Forest (Cost Prediction):
XGBoost (CO₂ Prediction):
Place these exact files inside the images/ folder (same spelling and case):
architecture_new.pngdashboard-main.pngmaterial-distribution.pngrecommendation-trends.pngmodel-metrics-cost.pngmodel-metrics-co2.pngbest-material-output.png
Rajan Kumar
- GitHub: https://github.com/RajanKumar44
If you like this project, give it a ⭐ on GitHub.






