Skip to main content

Documentation Index

Fetch the complete documentation index at: https://mintlify.com/Imjuanisss/proyecto-melika/llms.txt

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

The administrator role is MELIKA’s highest-privilege role. Every request to an admin route is validated by both the verifyToken and isAdmin middleware guards, meaning a valid JWT and a rol: "admin" claim are required. From the /admin panel, administrators oversee the entire platform: they monitor real-time statistics, manage user accounts and doctor profiles, configure availability schedules in bulk, and maintain the catalogues of specialties and medications.
Admin JWT tokens grant unrestricted access to every management endpoint on the platform, including the ability to deactivate users and modify medical records catalogues. Store admin tokens securely and never expose them in client-side code or public repositories. A compromised admin token gives an attacker full platform access until it expires (8 hours) or the account is deactivated.

Dashboard Statistics

The admin dashboard home loads a summary snapshot of the entire platform from a single endpoint:
GET /admin/stats
Authorization: Bearer <admin-token>
Response shape:
{
  "totales": {
    "pacientes": 1024,
    "medicos": 38,
    "citas": 5870,
    "citasHoy": 43,
    "especialidades": 12,
    "medicamentos": 210
  },
  "citasPorEstado": [
    { "estado": "pendiente",  "total": "312" },
    { "estado": "completada", "total": "4991" },
    { "estado": "cancelada",  "total": "489" },
    { "estado": "no_asistio", "total": "78" }
  ],
  "ultimasCitas": [
    {
      "id": 5870,
      "fecha": "2025-08-14",
      "hora_inicio": "09:00",
      "estado": "completada",
      "tipo_consulta": "presencial",
      "paciente_nombre": "Laura",
      "paciente_apellido": "Gómez",
      "medico_nombre": "Carlos",
      "medico_apellido": "Pérez",
      "especialidad": "Cardiología"
    }
  ],
  "medicosMasSolicitados": [
    {
      "nombre": "Carlos",
      "primer_apellido": "Pérez",
      "especialidad": "Cardiología",
      "total_citas": "340"
    }
  ]
}
KeyDescription
totalesAggregate counts for all major entities (pacientes counts only active patients with rol = 'paciente')
citasPorEstadoAppointment breakdown by status; total is returned as a string from COUNT(*)
ultimasCitasThe 5 most recently created appointments across the platform
medicosMasSolicitadosTop 5 doctors ranked by total non-cancelled bookings

User Management

GET /admin/usuarios?rol=paciente&buscar=laura&activo=true
Authorization: Bearer <admin-token>
All three query parameters are optional and combinable:
ParameterTypeDescription
rolstringFilter by paciente, medico, or admin
buscarstringCase-insensitive search on nombre, primer_apellido, and email
activobooleantrue for active accounts, false for deactivated

Doctor Management

Creating a doctor simultaneously builds their usuarios record and sends an invitation email with a 72-hour activation token:
POST /medicos
Authorization: Bearer <admin-token>
Content-Type: application/json
{
  "nombre": "Ana",
  "primer_apellido": "Ramírez",
  "email": "ana.ramirez@hospital.co",
  "tipo_documento": "CC",
  "numero_documento": "1023456789",
  "id_especialidad": 2,
  "numero_registro": "RM-20483",
  "acepta_teleconsulta": true,
  "acepta_presencial": true,
  "biografia": "Cardiologist with 12 years of experience.",
  "anos_experiencia": 12
}
The fields nombre, primer_apellido, email, tipo_documento, numero_documento, numero_registro, and id_especialidad are required. The tipo_documento value must be CC, CE, or PASAPORTE. The initial consultation fee is set to 0 and can be updated later via PUT /medicos/:id. The doctor receives an email with a link to set their password and activate the account.

Schedule Management

Administrators can create availability slots individually or generate an entire day’s schedule in one request.
POST /admin/horarios
Authorization: Bearer <admin-token>
Content-Type: application/json
{
  "id_medico": 3,
  "fecha": "2025-08-18",
  "hora_inicio": "14:00",
  "hora_fin": "14:40"
}

Appointment Oversight

GET /admin/citas?estado=pendiente&fecha_desde=2025-08-01&fecha_hasta=2025-08-31&buscar=gomez
Authorization: Bearer <admin-token>
ParameterDescription
estadoFilter by pendiente, completada, cancelada, no_asistio
fecha_desdeLower bound of appointment date range
fecha_hastaUpper bound of appointment date range
buscarCase-insensitive search across patient and doctor names

Specialty Management

POST   /admin/especialidades              # Create a new specialty
PUT    /admin/especialidades/:id          # Update name / description / price / image
PATCH  /admin/especialidades/:id/estado  # Toggle active/inactive
Inactive specialties are hidden from the public browse page and cannot be selected when booking a new appointment.

Medication Management

POST   /admin/medicamentos              # Add a medication to the catalogue
PUT    /admin/medicamentos/:id          # Update medication details
PATCH  /admin/medicamentos/:id/estado  # Toggle active/inactive
The medication catalogue is used by doctors when composing treatment fields in clinical histories.

Admin Panel Navigation

The admin panel is served at /admin with nested routes for each management section:
PathSection
/adminDashboard (stats overview)
/admin/medicosDoctor management
/admin/horariosSchedule management
/admin/usuariosUser management
/admin/citasAppointment oversight
/admin/especialidadesSpecialty catalogue
/admin/medicamentosMedication catalogue
All nested routes are protected by the RutaAdmin guard in App.jsx. Any authenticated user without rol: "admin" is redirected to /dashboard.

API Reference

Admin API Reference

Full endpoint reference for all /admin/* routes — request schemas, response shapes, and error codes.

Doctors API Reference

Endpoint reference for doctor creation, profile management, and invitation flow endpoints.

Build docs developers (and LLMs) love