Skip to main content

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:
FieldTypeDescription
idIntegerAuto-generated primary key
gerenteGerenteThe manager who owns this pantry (ManyToOne, eager-loaded)
ingredientesList<Ingrediente>All ingredients tracked in this pantry, linked via the despensa_ingredientes join table (ManyToMany)
Each Ingrediente in the list carries two key fields:
FieldTypeDescription
descripcionStringHuman-readable ingredient name (e.g. "Tomate")
cantidadStockIntegerCurrent stock quantity

Key Operations

Get Pantry Details

Retrieve the full Despensa entity including its Gerente and the complete ingredient list.
GET /api/despensa/{id}
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:
FieldTypeDescription
ingredienteIdIntegerPrimary key of the ingredient
descripcionStringIngredient name
cantidadStockIntegerCurrent 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
}
FieldDescription
totalIngredientesTotal number of ingredients tracked in this pantry
conStockIngredients with at least 1 unit in stock (includes stockBajo items)
stockBajoIngredients with cantidadStock < 10 and cantidadStock > 0
sinStockIngredients 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:
IngredientStock
Tomate100
Cebolla80
Ajo50
Pasta120
Queso Parmesano40
Aceite de Oliva60
Sal200
Pimienta150
Carne de Res45
Pollo70
Huevos60
Tocino30
Albahaca25
Mozzarella35
Mantequilla50
Carne Vacuna55
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

Build docs developers (and LLMs) love