-
Clone the Repository:
-
Create a Virtual Environment and Activate It:
python -m venv venv source venv/bin/activate # On Windows use `venv\Scripts\activate`
-
Install Dependencies:
pip install -r requirements.txt
Required Dependencies:
- fastapi
- uvicorn
- pymongo
- pandas
- numpy
- fuzzywuzzy
- jellyfish
- scipy
-
Set Up MongoDB:
Ensure you have a running MongoDB instance. The default connection URI is
mongodb://localhost:27017/. Adjust the URI in the code if needed.
This script uses the FoodDataProcessor class to load data from the CSV files and store them into respective collections (nutrition, recipes, carbon_footprint, and interactions).
The API is built using FastAPI. Key endpoints include:
-
Health Check:
GET /healthReturns a simple status check.
-
Score Calculation:
POST /scoreRequest Body:
{ "dish_name": "Paneer Butter Masala", "user_context": { "medications": ["Warfarin"], "conditions": ["Hypertension"] } }Response:
{ "dish_name": "Paneer Butter Masala", "unified_score": 85.0, "score_components": { "health": 90.0, "carbon": 65.0, "interactions": 70.0 }, "confidence_interval": 87.5, "explanation": { "health_breakdown": "ICMR-aligned nutrient balance", "carbon_factors": "MP-adjusted CO2e values", "interaction_risks": "Drug-food interaction hierarchy" }, "alternatives": [{"name": "Suggested Alternative", "score": 85}] }
-
Start the API Server:
uvicorn api:app --host 0.0.0.0 --port 8000
-
Access the Documentation:
Open your browser and navigate to
http://localhost:8000/docsto view the interactive API documentation provided by Swagger UI. -
Testing:
Use any API client (like Postman) or the built-in Swagger UI to test the endpoints.
- ML Ensemble Integration: Enhance scoring by training ensemble models (Random Forest and XGBoost) on aggregated ingredient features.
- Improved Confidence Metrics: Develop more robust measures for data completeness and reliability.
- Interactive Dashboard: Build a frontend UI for visualizing scores and recommendations.
- Expanded Dataset Support: Integrate additional regional datasets for broader coverage.
This project is licensed under the MIT License. See the LICENSE file for details.