cold-change/snacc
SNACC API
Smart Nutrition Assistant Companion & Curator — a recipe recommendation API. Give it a list of ingredients you have on hand and it returns recipes that use them, optionally filtered by dietary preference.
Powered by a TF-IDF vectorizer + Nearest Neighbors model trained on a large recipe dataset.
This Space hosts the backend only. The PWA frontend that consumes it is a separate project (in progress). The full source, including data preprocessing and model training code, is on GitHub: <https://github.com/Cold-Change/SNACC>.
API
GET /recommend
Invalid input returns HTTP 422 with a detail field explaining what failed.
Example
curl "https://cold-change-snacc.hf.space/recommend?ingredients=chicken,garlic,butter&top_n=3"Returns:
{
"recipes": [
{
"recipe_title": "Garlic Butter Chicken",
"ingredients": "['chicken', 'garlic', 'butter', '...']",
"directions": "['Heat butter...', 'Add chicken...']"
}
]
}Cold-start behavior
The free CPU tier sleeps the Space after ~48 hours of inactivity. The first request after a sleep takes ~30–60 seconds while HF wakes the container and pulls the image; subsequent requests respond in tens of milliseconds. There's no way to disable sleep on the free tier.
If you're building a client, surface a "waking up" state if a request hasn't returned within 5 seconds.
Tech
- Python 3.11 on
python:3.11-slim - FastAPI + Uvicorn
- scikit-learn (TF-IDF, NearestNeighbors)
- pandas
- Model artifacts (~45 MB) baked into the image; no runtime HF Hub download
License
See the GitHub repository for license details.
