The Reports API powers the Tradiciones y Sabores analytics dashboard. It exposes three endpoints: a KPI summary that compares the current 30-day window against the prior period, a flexible order-history query with period and status filters, and a lightweight health-check endpoint that confirms the backend’s connection to PostgreSQL. All timestamps are handled in UTC, and percentage-change calculations degrade gracefully when the prior period contains no data.Documentation Index
Fetch the complete documentation index at: https://mintlify.com/teofilobetancourt/Tradiciones-y-Sabores/llms.txt
Use this file to discover all available pages before exploring further.
GET /api/reportes/resumen
Returns a five-field KPI snapshot covering the rolling last 30 days compared against the immediately preceding 30-day period (days 31–60 in the past). Use this endpoint to populate dashboard cards showing revenue trends, order volume, and kitchen throughput.Response
Number of orders (
pedido rows) whose fecha_creacion falls within the last 30 days.Sum of
factura.total for all invoices linked to orders created in the last 30 days. Returns 0.0 if no invoices exist for the period.Average elapsed time in seconds from
fecha_creacion to the moment the report is generated, measured only across orders that have reached listo or entregado status within the last 30 days. Returns 0.0 if no completed orders exist in the window.Percentage change in order count between the current and prior 30-day periods, rounded to one decimal place. Positive values indicate growth; negative values indicate a decline.
Percentage change in gross revenue between the current and prior 30-day periods, rounded to one decimal place.
GET /api/reportes/pedidos
Returns an array of order objects filtered by time period and/or order status. This endpoint drives the filterable orders table in the analytics dashboard and accepts the same optional query parameters independently — you can filter by period alone, status alone, or both together. Orders are returned in descending ticket number order (most recent first). Each element in the array has the same shape as the responses fromGET /api/ordenes.
Query parameters
Time window to filter orders by
Defaults to
fecha_creacion. Accepted values:| Value | Window |
|---|---|
hoy | From midnight of the current day (UTC) to now |
semana | Last 7 days from now |
mes | Last 30 days from now (default) |
mes (last 30 days) when omitted or when an unrecognised value is provided.Filter by order status. Accepted values:
recibido, preparando, listo, entregado, or Todos. When set to Todos or omitted entirely, orders of all statuses are returned.Response
Returns a JSON array of order objects. Each element has the same flattened shape produced byformat_pedido_response() — the same format returned by GET /api/ordenes. Customer and line-item data are inlined directly into the order object rather than nested under separate cliente or detalles keys.
Ticket number, mirrored from
num_ticket for compatibility with older clients.Auto-incremented primary key and ticket number for the order.
ISO 8601 UTC timestamp of when the order was created, e.g.
"2025-01-14T19:32:05".Full name of the customer. Defaults to
"Cliente General" if the client record is missing.Venezuelan national ID of the customer, e.g.
"V-18340921".Phone number on file for the customer.
Order type string, same value as
tipo_pedido. Included for compatibility.Order fulfillment type:
mesa, pickup, or delivery.Table number assigned to the order, same value as
id_mesa.Table ID for dine-in orders.
null for pickup or delivery.Delivery address, same value as
direccion_envio. null for non-delivery orders.Full delivery address string. Only populated when
tipo_pedido is delivery.Line items attached to the order. Each element contains:
Dish ID, mirrored from
id_plato.Primary key of the
plato record.Dish name resolved from the
plato table. Falls back to "Plato #<id>" if the record is missing.Quantity ordered.
Unit price at the time of ordering, sourced from
plato.precio.Line total (
precio_unitario × cantidad), rounded to two decimal places.Sum of all line item subtotals before tax.
Value-added tax at 16% (
subtotal × 0.16), rounded to two decimal places.Final amount due (
subtotal + iva), rounded to two decimal places.Capitalized status string for display purposes, e.g.
"Preparando". Same state as estado_orden.Lowercase status string. One of
recibido, preparando, listo, or entregado.GET /api/debug
Health-check endpoint that verifies environment configuration and confirms whether the application can reach the PostgreSQL database. Returns the values of all four connection environment variables alongside a live connection test result.This endpoint performs a real query (
SELECT COUNT(*) FROM plato) on every call to confirm the database session is functional. In production environments, restrict access to this endpoint to internal network calls or authenticated admin users, as it exposes database host and credential metadata.Response
Object containing the four database connection environment variables read at request time.
Result of the live connectivity probe. Returns a string beginning with
"CONNECTED" (e.g. "CONNECTED (Platos count: 42)") on success, or "FAILED" if the connection or query raised an exception.Exception message including the exception type if
db_connection is "FAILED". null when the connection succeeds.