Documentation Index
Fetch the complete documentation index at: https://mintlify.com/JuanSebasSV/healtyhelp/llms.txt
Use this file to discover all available pages before exploring further.
Favorites
HealtyHelp lets users bookmark up to 100 recipes as favorites. Favorites are stored as an array ofObjectId references directly on the User document, making reads extremely fast. The toggle mechanic means a single endpoint both adds and removes a recipe — no separate “unfavorite” endpoint needed.
How Favorites Are Stored
Favorites live inuser.favoritos: [ObjectId] on the MongoDB User model. The array is queried and mutated directly — no separate collection is involved.
The Toggle Mechanic
POST /api/favoritos/:recetaId is an idempotent toggle:
- If
recetaIdis not inuser.favoritos, it is appended (add). - If
recetaIdis already inuser.favoritos, it is removed withsplice(remove). - If the user already has 100 favorites, attempting to add a new one returns
400.
API Endpoints
Get All Favorites
Toggle a Favorite
:recetaId path parameter is the MongoDB ObjectId of the recipe.
Success response (recipe added):
cURL Examples
The 100-Item Hard Limit
The server enforces a maximum of 100 favorites per user. When the limit is hit and the user tries to add a new recipe, the server returns HTTP400 with { "error": "Límite de favoritos alcanzado" }.
The front-end heart button should check this error code and show an appropriate toast or inline message rather than treating it as a generic failure.
Optimistic UI Update
TheVistaInicio home view manages a favoritos state array client-side. When the user clicks the heart button on a TarjetaReceta card, the toggleFav handler is called:
favoritos[] array immediately (optimistic), then syncs with the server in the background. The esFav prop passed to each card re-renders the heart icon in filled or outline state without waiting for the round-trip.
The Favorites View (VistaFavoritos)
The dedicated /favoritos page shows all saved recipes organised in a category-first navigation:
Category Selection Screen
When no category is selected, the view shows four category cards — Desayuno, Almuerzo, Cena, Postres & Snacks — each displaying the number of favorited recipes in that category. Cards with zero recipes are rendered as disabled.Recipe Grid (Within a Category)
After selecting a category, the view switches to a recipe grid with:- Back button — returns to the category selection screen
- Search bar — live text search over
nombreanddesc, using the same accent-stripping normalisation as the home view - Time filter — filter by preparation time:
Menos de 15 min/15 – 30 min/Más de 30 min - Recipe count badge — shows total recipes in the selected category
- Full
TarjetaRecetacards — each card includes the favorite toggle, so users can remove a recipe from favorites directly from this view
Empty States
| Situation | Message shown |
|---|---|
| No favorites at all | ”Aún no tienes favoritos” + link to explore recipes |
| Category has no favorites | ”Sin favoritos en [Categoría]” + link to explore |
| Search/filter returns nothing | ”Sin resultados — Intenta con otro término o filtro.” |
Filtering Logic
recetasFavoritas by intersecting it with the favoritos ID array.