Skip to main content

Documentation Index

Fetch the complete documentation index at: https://mintlify.com/elzackarias/Hackaton3B-Reto1/llms.txt

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

These endpoints let you query the engine’s past event log and inject test events without needing a physical camera or the computer-vision pipeline. Simulated events flow through the same InventoryEngine.process_event() path as real detections, triggering stock updates, alert evaluation, and all connected WebSocket broadcasts.

GET /api/events

Returns the recorded InventoryEvent log in reverse chronological order (most recent first). Supports pagination and filtering by SKU.
limit
integer
default:"50"
Maximum number of events to return. Minimum 1, maximum 500.
sku_id
string
Optional. When provided, only events whose sku_id matches this value are returned. Must be one of the 7 valid SKU IDs.
curl "http://localhost:8000/api/events?limit=10&sku_id=nachos_naturasol"

InventoryEvent Object

event_id
string
UUID v4 uniquely identifying this event.
event_type
string
Either "retiro" (product taken from shelf) or "devolucion" (product returned to shelf).
sku_id
string
Identifier of the affected product.
sku_name
string
Human-readable name of the affected product.
slot_id
integer
Physical shelf slot number where the event occurred.
stock_before
integer
Stock level immediately before this event was applied.
stock_after
integer
Stock level immediately after this event was applied.
confidence
float
Detection confidence score (0.0–1.0). Events below 0.15 are discarded by the engine before reaching this log.
timestamp
string
ISO 8601 datetime when the event was detected.
Example response:
[
  {
    "event_id": "a3f1c2d4-58e0-4b1a-9f3c-1234567890ab",
    "event_type": "retiro",
    "sku_id": "nachos_naturasol",
    "sku_name": "Nachos Con Sal Naturasol 200gr",
    "slot_id": 4,
    "stock_before": 6,
    "stock_after": 5,
    "confidence": 0.95,
    "timestamp": "2024-11-15T10:28:41.009123"
  }
]

POST /api/events

Injects a simulated detection event directly into the InventoryEngine without requiring the camera pipeline. The event is processed identically to a real camera detection.
sku_id
string
required
The SKU to apply the event to. Must be one of the 7 valid SKU IDs. Returns HTTP 404 if not found.
event_type
string
required
The type of event to simulate. Must be exactly "retiro" or "devolucion".
confidence
float
default:"0.95"
Simulated detection confidence. Range 0.01.0. Events below the engine’s internal threshold (0.15) will be rejected with HTTP 422.
curl -X POST http://localhost:8000/api/events \
  -H 'Content-Type: application/json' \
  -d '{"sku_id": "nachos_naturasol", "event_type": "retiro"}'
200 — Success (returns the created InventoryEvent):
{
  "event_id": "b7e2f501-1a3c-4d8e-bc90-abcdef012345",
  "event_type": "retiro",
  "sku_id": "nachos_naturasol",
  "sku_name": "Nachos Con Sal Naturasol 200gr",
  "slot_id": 4,
  "stock_before": 5,
  "stock_after": 4,
  "confidence": 0.95,
  "timestamp": "2024-11-15T10:35:12.774200"
}
404 — SKU not found:
{
  "detail": "SKU 'unknown_sku' no encontrado"
}
422 — Event ignored:
{
  "detail": "Evento ignorado (confianza baja o duplicado)"
}
This endpoint also broadcasts two Socket.IO events to all connected WebSocket clients: inventory_update (carrying both the event and updated stock) and detection_event (carrying the raw event). Use it to exercise WebSocket integrations without needing the camera pipeline active.

POST /api/mock/event

Fires a random RETIRO event against a randomly selected SKU. No request body is required. Designed for quick smoke-testing of WebSocket connections and dashboard integrations.
curl -X POST http://localhost:8000/api/mock/event
status
string
"ok" when the event was processed, or "ignored" when the randomly selected product has stock_current = 0.
event
object
The InventoryEvent that was created (only present when status is "ok").
message
string
Explanation string (only present when status is "ignored").
Success response:
{
  "status": "ok",
  "event": {
    "event_id": "c9d3e812-2b4f-4e1a-8c01-fedcba987654",
    "event_type": "retiro",
    "sku_id": "sisi_cola",
    "sku_name": "Refresco Cola Sin Azucar Sisi 355ml",
    "slot_id": 6,
    "stock_before": 7,
    "stock_after": 6,
    "confidence": 0.95,
    "timestamp": "2024-11-15T10:40:03.551800"
  }
}
Ignored response (stock already at 0):
{
  "status": "ignored",
  "message": "Evento ignorado (stock en 0 o duplicado)"
}
Call POST /api/mock/event in a loop (e.g., watch -n 2 curl -s -X POST http://localhost:8000/api/mock/event) to generate a continuous stream of events for live WebSocket or dashboard testing.

Build docs developers (and LLMs) love