Skip to main content
The Dashboard endpoints provide comprehensive analytics and insights for lubrication services.

KPIs

Get executive-level key performance indicators.
GET /api/engrases/dashboard/kpis

Query Parameters

fecha_inicio
string
Start date (YYYY-MM-DD)
fecha_fin
string
End date (YYYY-MM-DD)

Response

{
  "total_gastos": 2450000,
  "total_servicios": 45,
  "promedio_por_servicio": 54444,
  "total_lavado": 850000,
  "total_engrase": 1200000,
  "total_otros": 400000,
  "comparacion_mes_anterior": {
    "total_gastos_anterior": 2100000,
    "variacion_porcentaje": 16.67
  }
}

Spending Over Time

Track spending trends over time.
GET /api/engrases/dashboard/spending-time

Response

{
  "periodos": [
    {
      "mes": "2024-01",
      "total": 850000,
      "lavado": 300000,
      "engrase": 450000,
      "otros": 100000,
      "cantidad_servicios": 15
    }
  ]
}

Service Comparison

Compare spending by service type.
GET /api/engrases/dashboard/service-comparison

Response

{
  "lavado": {
    "total": 850000,
    "cantidad": 32,
    "promedio": 26562,
    "porcentaje": 34.7
  },
  "engrase": {
    "total": 1200000,
    "cantidad": 28,
    "promedio": 42857,
    "porcentaje": 49.0
  },
  "otros": {
    "total": 400000,
    "cantidad": 12,
    "promedio": 33333,
    "porcentaje": 16.3
  }
}

By Vehicle Plate

Service expenses grouped by vehicle.
GET /api/engrases/dashboard/by-placa

Query Parameters

top
number
default:"10"
Number of top vehicles to return

Response

{
  "vehiculos": [
    {
      "placa": "ABC-123",
      "total_gastos": 450000,
      "cantidad_servicios": 8,
      "promedio": 56250,
      "ultimo_servicio": "2024-03-01"
    }
  ]
}

By Operational Area

Service expenses by area.
GET /api/engrases/dashboard/by-area

Response

{
  "areas": [
    {
      "area_operacion": "Zona Norte",
      "total_gastos": 1200000,
      "cantidad_servicios": 25,
      "vehiculos_atendidos": 12,
      "porcentaje_total": 49.0
    }
  ]
}

Alerts

Get intelligent alerts for unusual patterns.
GET /api/engrases/dashboard/alerts

Response

{
  "alerts": [
    {
      "tipo": "COSTO_ALTO",
      "severidad": "warning",
      "mensaje": "Vehículo ABC-123 tiene costos 50% por encima del promedio",
      "detalles": {
        "placa": "ABC-123",
        "costo_promedio": 45000,
        "ultimo_costo": 67500,
        "variacion": 50
      },
      "cantidad": 3
    },
    {
      "tipo": "SIN_SERVICIO",
      "severidad": "info",
      "mensaje": "5 vehículos sin servicio en más de 30 días",
      "cantidad": 5
    }
  ]
}

Alert Records

Get detailed records for a specific alert type.
GET /api/engrases/dashboard/alert-records/:alertType

Path Parameters

alertType
string
required
Alert type: COSTO_ALTO, SIN_SERVICIO, FRECUENCIA_ALTA, COSTO_BAJO

Detailed Table

Get complete service data with flags and indicators.
GET /api/engrases/dashboard/detailed-table
Supports same filters as the list endpoint plus:
incluir_flags
boolean
default:"true"
Include alert flags in response

Vehicle Monthly Matrix

Get service frequency matrix by vehicle and month.
GET /api/engrases/dashboard/placa-month-matrix

Query Parameters

anio
number
required
Year to analyze

Response

{
  "matriz": [
    {
      "placa": "ABC-123",
      "meses": {
        "01": 2,
        "02": 3,
        "03": 1
      },
      "total_anual": 6
    }
  ]
}
All dashboard endpoints respect Row Level Security (RLS) policies and return data based on user permissions.

Build docs developers (and LLMs) love