Skip to main content

Documentation Index

Fetch the complete documentation index at: https://mintlify.com/luisumit/LaPreviaRestobar/llms.txt

Use this file to discover all available pages before exploring further.

The inventory resource tracks real-time stock levels for products that have trackInventory: true. Each inventory record is keyed to a product and carries the current quantity, a minimum-stock threshold for low-stock alerts, the unit of measure, and the product’s category. Stock is decremented automatically when a tracked product appears in an order that moves to ACEPTADO. You can also adjust stock directly via PUT /inventory/{productId}/stock — useful for manual stocktakes or receiving deliveries. The backend exposes two sets of inventory endpoints: the typed REST routes consumed by Retrofit (/inventory, /inventory/{productId}/stock) and two raw Firebase pass-through routes (/inventario, POST /inventario) from the original server.js implementation. Both sets write to the same inventory node in Firebase Realtime Database.

Inventory Object

id
number
Internal numeric record ID (serialised as Long from Gson @SerializedName("id")).
productId
number
Numeric ID linking this inventory record to a product (@SerializedName("productId")).
productName
string
Display name of the product at the time the inventory record was created.
stockQuantity
integer
Current quantity in stock (@SerializedName("stockQuantity")). Maps to currentStock in the local Inventory model.
category
string
Category of the product, used for grouping in the inventory dashboard.
minimumStock
integer
Minimum acceptable stock level. When stockQuantity falls below this value the dashboard flags the item as low-stock. Defaults to 10.
Local model mapping: InventoryDto.toInventory() converts productId (Long) to a String, maps stockQuantity to currentStock: Double, and hard-codes unitOfMeasure to "unidades". The version field is tracked locally on the Inventory model but is not present in the DTO.

GET /inventory

Returns the full list of inventory records from the inventory node in Firebase.
curl -X GET http://localhost:3000/inventory \
  -H "Accept: application/json"
Response 200 OK
[
  {
    "id": 1,
    "productId": 101,
    "productName": "Choripán",
    "stockQuantity": 38,
    "category": "Entradas",
    "minimumStock": 5
  },
  {
    "id": 2,
    "productId": 102,
    "productName": "Coca-Cola 500ml",
    "stockQuantity": 3,
    "category": "Bebidas",
    "minimumStock": 10
  }
]
In the second record above, stockQuantity (3) is below minimumStock (10), so the inventory dashboard would display a low-stock alert for that item.

PUT /inventory/{productId}/stock

Updates the stock quantity for a single tracked product. Call this endpoint to reflect a manual stock adjustment (e.g., after a delivery) or to correct a discrepancy found during a stocktake. Path parameters
productId
string
required
The product ID whose stock should be updated. Corresponds to the productId field in the inventory record.
Request body (StockUpdateRequest)
stock
integer
required
The new absolute stock quantity. This is a full replacement of the current value, not a delta.
curl -X PUT http://localhost:3000/inventory/101/stock \
  -H "Content-Type: application/json" \
  -d '{"stock": 50}'
Response 200 OK — returns the updated InventoryDto.
{
  "id": 1,
  "productId": 101,
  "productName": "Choripán",
  "stockQuantity": 50,
  "category": "Entradas",
  "minimumStock": 5
}

Raw Firebase Endpoints

These two routes are part of the original server.js implementation and provide direct read/write access to the inventory node in Firebase Realtime Database. They do not enforce the typed InventoryDto schema — any JSON object can be pushed. They are retained for tooling and admin scripts that need to bulk-load inventory data.

GET /inventario

Reads all documents from the inventory Firebase node and returns them as a flat array.
curl -X GET http://localhost:3000/inventario \
  -H "Accept: application/json"
Response 200 OK — an array of raw inventory objects as stored in Firebase. Returns [] if the node is empty.
[
  {
    "productId": 101,
    "productName": "Choripán",
    "stockQuantity": 50,
    "category": "Entradas",
    "minimumStock": 5
  }
]

POST /inventario

Pushes a new document to the inventory Firebase node using db.ref('inventory').push(data). No schema validation is applied — the body is stored verbatim. Responds with a confirmation message. Request body Any valid JSON object representing an inventory record. The recommended shape matches the InventoryDto fields.
curl -X POST http://localhost:3000/inventario \
  -H "Content-Type: application/json" \
  -d '{
    "productId": 103,
    "productName": "Agua Mineral 500ml",
    "stockQuantity": 100,
    "category": "Bebidas",
    "minimumStock": 20
  }'
Response 200 OK
{
  "mensaje": "Producto agregado al inventario"
}

Build docs developers (and LLMs) love