Skip to main content

Documentation Index

Fetch the complete documentation index at: https://mintlify.com/ytabeloved/ordervista/llms.txt

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

The Ordervista Admin Dashboard provides a real-time operational overview of restaurant performance. A single API call to GET /api/reports/dashboard resolves seven data sets in parallel — from headline sales figures and trend charts to the most recent orders — giving administrators a complete picture without multiple round-trips. All revenue-related metrics automatically exclude cancelled orders (id_estado = 5) to keep figures accurate. The dashboard is accessible at the /reportes frontend route and is restricted to the Admin role.

Dashboard Metrics

Endpoint: GET /api/reports/dashboard
Auth: Required — Admin role only (authorizeRoles(1))
Query params: startDate and endDate (optional, format YYYY-MM-DD)
The endpoint executes seven queries in parallel via Promise.all and returns all results in a single JSON envelope:
KeySource functionDescription
summarygetDashboardSummaryHeadline KPIs filtered by date range
metricsgetAdminMetricsAbsolute counts not tied to the date filter
salesByDaygetSalesByDayDaily revenue and order count for charting
topProductsgetTopProductsTop 8 products by units sold
ordersByStatusgetOrdersByStatusOrder count grouped by status
salesByCategorygetSalesByCategoryRevenue and units sold per category
recentOrdersgetRecentOrdersLatest 8 orders regardless of date filter

Available Metrics

The summary object contains the four headline KPIs shown at the top of the dashboard. All figures exclude cancelled orders and respect the active date filter:
  • ventas_estimadas — total estimated revenue (SUM(total)) in the period
  • total_pedidos — total number of non-cancelled orders placed
  • ticket_promedio — average order value (AVG(total))
  • clientes_atendidos — count of distinct customers who placed orders
The metrics object provides absolute operational counts that are always current and are not affected by the date filter:
  • orders_today — non-cancelled orders placed today
  • total_customers — total registered customer accounts (id_rol = 3)
  • active_products — products with activo = TRUE
  • active_orders — orders currently in status Pendiente, En preparación, or Listo (id_estado 1–3)

Charts

The dashboard exposes three data sets designed for visual rendering: Daily sales bar chartsalesByDay
Each entry contains fecha (date), total_pedidos (order count), and ventas (revenue). Ordered chronologically, this powers the daily sales trend bar chart on the dashboard.
Top products tabletopProducts
Returns up to 8 products ranked by cantidad_vendida (units sold), each with id_producto, nombre, categoria, cantidad_vendida, and total_vendido. Displayed as a ranked table to surface best-sellers.
Sales by categorysalesByCategory
Each entry contains id_categoria, categoria, total_vendido, and cantidad_vendida. Designed to power a pie or donut chart showing the revenue contribution of each menu category.

Date Filtering

All date-sensitive queries (summary, salesByDay, topProducts, ordersByStatus, salesByCategory) accept optional startDate and endDate query parameters. When omitted, the queries return data across all time.
curl "https://your-api.com/api/reports/dashboard?startDate=2025-01-01&endDate=2025-01-31" \
  -H "Authorization: Bearer <admin-token>"

Sample API Response

{
  "summary": {
    "total_pedidos": 18,
    "ventas_estimadas": 150000,
    "ticket_promedio": 8333.33,
    "clientes_atendidos": 12
  },
  "metrics": {
    "orders_today": 4,
    "total_customers": 35,
    "active_products": 22,
    "active_orders": 3
  },
  "salesByDay": [
    { "fecha": "2025-01-14", "total_pedidos": 7, "ventas": 58000 },
    { "fecha": "2025-01-15", "total_pedidos": 11, "ventas": 92000 }
  ],
  "topProducts": [
    {
      "id_producto": 3,
      "nombre": "Hamburguesa Clásica",
      "categoria": "Hamburguesas",
      "cantidad_vendida": 24,
      "total_vendido": 204000
    }
  ],
  "ordersByStatus": [
    { "id_estado": 1, "estado": "Pendiente", "total": 2 },
    { "id_estado": 4, "estado": "Entregado", "total": 16 }
  ],
  "salesByCategory": [
    {
      "id_categoria": 1,
      "categoria": "Hamburguesas",
      "total_vendido": 204000,
      "cantidad_vendida": 24
    }
  ],
  "recentOrders": [
    {
      "id_pedido": 48,
      "fecha_pedido": "2025-01-15T14:45:00.000Z",
      "total": "12000.00",
      "id_estado": 3,
      "id_tipo_pedido": 3,
      "cliente_nombre": "Carlos Pérez",
      "cliente_email": "carlos@example.com",
      "estado": "Listo",
      "total_items": 1
    }
  ]
}

Access Control

The reports endpoint is restricted to id_rol = 1 (Admin) via the authorizeRoles(1) middleware. Operators and Customers will receive a 403 Forbidden response if they attempt to call this endpoint.

Recent Orders

The recentOrders dataset always returns the 8 most recently created orders regardless of any date filter applied to the rest of the dashboard. Each entry includes the customer name and email, order status label (estado), order type, total value, and item count, making it suitable for a quick operational glance at current activity without leaving the dashboard view.

Build docs developers (and LLMs) love