CoolFace
Apppublic

cold-change/snacc

sourceHugging Faceupdated 4mo agoView on Hugging Face
0likes
App README

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

MethodPathDescription
GET/Liveness probe (always 200 once the server is up)
GET/healthReadiness probe — returns 200 only after the model is loaded
GET/recommendGet recipe recommendations

GET /recommend

ParameterRequiredDescription
ingredientsYesComma-separated list of ingredients (max 10 items, ≤50 chars each, ≤500 chars total)
preferenceNoDietary filter: vegan, vegetarian, gluten_free, or dairy_free
top_nNoNumber of recipes to return, 1–50 (default 5)

Invalid input returns HTTP 422 with a detail field explaining what failed.

Example

bash
curl "https://cold-change-snacc.hf.space/recommend?ingredients=chicken,garlic,butter&top_n=3"

Returns:

json
{
  "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.