Skip to main content

Documentation Index

Fetch the complete documentation index at: https://mintlify.com/160906/Yakultt-App/llms.txt

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

The Products module is the foundation of Yakult App’s inventory system. It lets distributors maintain a live catalog of every Yakult SKU they carry — tracking prices, stock levels, and categories so that sales orders always reflect what is actually available on the shelf. Every change made here is immediately visible to all mobile app users, keeping the field sales team and the warehouse in sync without any manual reconciliation.

Product Fields

Each product record contains the following fields:
FieldTypeDescription
idintegerAuto-incremented primary key
nombrestringDisplay name of the product
skustringUnique stock-keeping unit code
preciodecimalUnit sale price
stockintegerCurrent units available
categoriastringProduct group (defaults to 'General')
creado_entimestampRecord creation timestamp
If categoria is submitted as an empty string or omitted entirely, the backend automatically coerces it to 'General' using COALESCE(NULLIF(categoria,''), 'General') on reads and categoria || 'General' on writes. You never need to guard against a blank category on the client side.

Sample Product Object

{
  "id": 7,
  "nombre": "Yakult Original 80ml × 5",
  "sku": "YK-ORI-5PK",
  "precio": 32.50,
  "stock": 240,
  "categoria": "Original",
  "creado_en": "2024-11-03T14:22:10.000Z"
}

API Endpoints

The products resource is mounted at /api/productos.
Retrieve every product ordered alphabetically by name.
curl https://your-api.example.com/api/productos
Response — array of product objects:
[
  {
    "id": 1,
    "nombre": "Yakult Light 65ml × 5",
    "sku": "YK-LGT-5PK",
    "precio": 29.00,
    "stock": 180,
    "categoria": "Light",
    "creado_en": "2024-10-01T09:00:00.000Z"
  },
  {
    "id": 7,
    "nombre": "Yakult Original 80ml × 5",
    "sku": "YK-ORI-5PK",
    "precio": 32.50,
    "stock": 240,
    "categoria": "Original",
    "creado_en": "2024-11-03T14:22:10.000Z"
  }
]

Automatic Stock Deduction

When a new order is created, the backend deducts stock for every line item inside a single database transaction. This guarantees that stock counts are always consistent — even if two orders are submitted at the same moment — because the deduction and the order insertion either both succeed or both roll back together. The deduction is executed for each item in the order with:
UPDATE productos SET stock = stock - ? WHERE id = ?
1

Order submitted

The mobile app POSTs to /api/ordenes with an items array containing productoId, cantidad, and precio for each line.
2

Transaction opens

The backend begins a MySQL transaction to ensure atomicity across all writes.
3

Order and items inserted

The order header and each orden_items row are inserted within the transaction.
4

Stock decremented

For each item, stock = stock - cantidad is applied to the matching product row — all inside the same transaction.
5

Transaction committed

Once every write succeeds, the transaction commits and the updated stock becomes visible catalog-wide.

Low-Stock Warning

The mobile app monitors stock levels and surfaces a visual alert when inventory runs low. Any product with fewer than 50 units in stock displays a ⚠️ warning indicator next to its name in the product list, prompting the distributor to reorder before a stockout occurs.
Restock products before processing large orders. Because stock is deducted transactionally at order creation time, an order will succeed even if it brings a product’s stock below 50 — the warning is informational, not a hard block.

Mobile UI Overview

Product List

Displays all catalog items alphabetically. Products with stock below 50 show a ⚠️ badge. Tap any row to open the edit form.

Add / Edit Form

A modal form collects name, SKU, price, stock, and category. Submits to POST or PUT depending on whether a product is being created or updated.

Delete Confirmation

Tapping delete opens a confirmation dialog before sending the DELETE request, preventing accidental removal of catalog items.

Real-Time Stock

Stock counts reflect all committed orders. The list refreshes whenever the screen is focused, ensuring field reps always see current availability.

Build docs developers (and LLMs) love