Documentation Index
Fetch the complete documentation index at: https://mintlify.com/NicolasMPP/restorante-springboot/llms.txt
Use this file to discover all available pages before exploring further.
The Despensa (pantry) is Restorante’s ingredient inventory system. It gives managers a real-time view of what is in stock, what is running low, and what has been fully depleted — all through a clean REST API backed by a ManyToMany relationship between the pantry and individual Ingrediente records. Each pantry belongs exclusively to one Gerente, ensuring that stock information stays scoped to the correct manager’s context.
Pantry Structure
A Despensa entity has the following fields:
| Field | Type | Description |
|---|
id | Integer | Auto-generated primary key |
gerente | Gerente | The manager who owns this pantry (ManyToOne, eager-loaded) |
ingredientes | List<Ingrediente> | All ingredients tracked in this pantry, linked via the despensa_ingredientes join table (ManyToMany) |
Each Ingrediente in the list carries two key fields:
| Field | Type | Description |
|---|
descripcion | String | Human-readable ingredient name (e.g. "Tomate") |
cantidadStock | Integer | Current stock quantity |
Key Operations
Get Pantry Details
Retrieve the full Despensa entity including its Gerente and the complete ingredient list.
Returns 200 OK with the serialised Despensa object, or 404 Not Found if the pantry does not exist.
List Ingredients
Fetch a lightweight projection of every ingredient in the pantry.
GET /api/despensa/{id}/ingredientes
Returns a list of IngredienteDetalleDTO objects:
| Field | Type | Description |
|---|
ingredienteId | Integer | Primary key of the ingredient |
descripcion | String | Ingredient name |
cantidadStock | Integer | Current stock level |
Low-Stock Alert
Retrieve only the ingredients whose stock is at or below a custom threshold.
GET /api/despensa/{id}/stock-bajo?umbral={n}
The umbral query parameter is required and must be a positive integer. Any ingredient with cantidadStock ≤ umbral is included in the response. Returns a list of Ingrediente entities.
The stock-bajo endpoint uses a configurable umbral you supply at call time. The statistics endpoint (below) uses a separate hardcoded threshold of 10 for its stockBajo counter — ingredients with cantidadStock < 10 are counted there regardless of any umbral value.
Pantry Statistics
Get an aggregated summary of stock health across all ingredients in the pantry.
GET /api/despensa/{id}/estadisticas
Returns a DespensaEstadisticas object:
{
"totalIngredientes": 16,
"conStock": 15,
"stockBajo": 3,
"sinStock": 1
}
| Field | Description |
|---|
totalIngredientes | Total number of ingredients tracked in this pantry |
conStock | Ingredients with at least 1 unit in stock (includes stockBajo items) |
stockBajo | Ingredients with cantidadStock < 10 and cantidadStock > 0 |
sinStock | Ingredients with cantidadStock == 0 |
Add Ingredient to Pantry
Link an existing Ingrediente record to this pantry by inserting a row into despensa_ingredientes.
POST /api/despensa/{despensaId}/ingredientes/{ingredienteId}
Returns 200 OK with "Ingrediente agregado" on success, or 400 Bad Request if either ID is not found.
Remove Ingredient from Pantry
Unlink an ingredient from the pantry. The Ingrediente record itself is not deleted.
DELETE /api/despensa/{despensaId}/ingredientes/{ingredienteId}
Returns 200 OK with "Ingrediente eliminado" on success, or 400 Bad Request if either ID is not found.
Updating Stock Levels
Individual ingredient stock quantities are managed through the ingredient endpoint, not the pantry endpoint:
PUT /api/ingredientes/{id}/stock?stock={n}
Set stock to the new absolute quantity. This updates cantidadStock on the Ingrediente record directly and is immediately reflected in all pantry views and statistics.
Seed Data Reference
The following ingredients are included in the application’s seed data, along with their default stock quantities:
| Ingredient | Stock |
|---|
| Tomate | 100 |
| Cebolla | 80 |
| Ajo | 50 |
| Pasta | 120 |
| Queso Parmesano | 40 |
| Aceite de Oliva | 60 |
| Sal | 200 |
| Pimienta | 150 |
| Carne de Res | 45 |
| Pollo | 70 |
| Huevos | 60 |
| Tocino | 30 |
| Albahaca | 25 |
| Mozzarella | 35 |
| Mantequilla | 50 |
| Carne Vacuna | 55 |
With the default data, stockBajo (items with cantidadStock < 10) starts at 0 since all seed quantities exceed 10. As stock is consumed and updated via the PUT /api/ingredientes/{id}/stock endpoint, this counter will rise accordingly.
Web Interface
A visual pantry management interface is available at http://localhost:8080/despensa. It renders the ingredient list and statistics using the same API endpoints described above, providing a Thymeleaf-rendered dashboard for day-to-day stock monitoring.
Further Reading