Skip to main content
Trazea’s notification system keeps users informed of important events, alerts, and updates through targeted in-app notifications with priority-based organization.

Overview

Notifications are delivered in real-time to users based on their role, location, or individual assignment. The system supports rich notification data and flexible targeting.

Targeted Delivery

Send to specific users or locations

Priority Levels

High, medium, or low urgency

Rich Content

Include structured data

Notification Structure

interface Notification {
  // Identification
  id_notificacion: string;
  fecha_creacion: string;
  
  // Targeting
  id_usuario: string | null;        // Specific user (null = broadcast)
  id_localizacion: string | null;   // Location-based (null = all)
  
  // Content
  titulo: string;                   // Notification title
  mensaje: string;                  // Detailed message
  tipo: string;                     // Notification category
  prioridad: string;                // 'alta' | 'media' | 'baja'
  
  // State
  leida: boolean;                   // Has user read it?
  
  // Additional data
  data: Record<string, unknown> | null;  // Flexible JSON payload
}

Notification Types

The tipo field categorizes notifications:
TypeDescriptionCommon Use
stock_bajoLow stock alertItem below minimum threshold
solicitudRequest updateRequest state changed
garantiaWarranty updateClaim status changed
movimientoTechnician movementParts loaded/returned
conteoCount completeAudit finished
sistemaSystem messageMaintenance, updates
aprobacionApproval neededUser registration pending
Types are flexible and can be extended as needed. They help users filter notifications and the UI can style them differently.

Priority Levels

Alta (High)

Critical Alerts

Issues requiring immediate attention

Examples

  • System down
  • Critical stock shortage
  • Urgent approval needed
  • Security alerts
Display: Red badge, top of list, possibly with sound/badge

Media (Medium)

Important Updates

Significant events needing timely response

Examples

  • Request state change
  • Low stock warning
  • Warranty claim update
  • Count discrepancies
Display: Yellow badge, sorted by date

Baja (Low)

Informational

General updates and information

Examples

  • New user registered
  • System update completed
  • Report generated
  • Tips and suggestions
Display: Gray badge, may be grouped or collapsed

Targeting Strategies

Individual User Notifications

{
  id_usuario: "user-uuid",
  id_localizacion: null,
  titulo: "Your request was approved",
  mensaje: "Request #1234 has been approved and dispatched."
}
Sent to a specific user regardless of their location.

Location-Based Notifications

{
  id_usuario: null,
  id_localizacion: "location-uuid",
  titulo: "Low stock alert",
  mensaje: "Brake pads (BP-2001) below minimum stock."
}
Sent to all users assigned to that location.

Broadcast Notifications

{
  id_usuario: null,
  id_localizacion: null,
  titulo: "System maintenance tonight",
  mensaje: "System will be unavailable from 10pm-12am for updates."
}
Sent to all users system-wide.

Hybrid Targeting

{
  id_usuario: "user-uuid",
  id_localizacion: "location-uuid",
  titulo: "Order ready for pickup",
  mensaje: "Your order is ready at Main Warehouse."
}
Sent to a specific user about a specific location.

Additional Data Field

The data JSON field allows rich notifications:
// Low stock notification
{
  data: {
    id_repuesto: "uuid",
    referencia: "BP-2001",
    stock_actual: 2,
    cantidad_minima: 10,
    action_url: "/inventario?item=uuid"
  }
}

// Request notification
{
  data: {
    id_solicitud: "uuid",
    numero: "REQ-1234",
    estado_anterior: "Creada",
    estado_nuevo: "Despachada",
    action_url: "/solicitudes/uuid"
  }
}

// Warranty notification
{
  data: {
    id_garantia: "uuid",
    referencia_repuesto: "BAT-100",
    resolucion: "Aprobada",
    action_url: "/garantias/uuid"
  }
}
The data field enables:Actionable Notifications:
  • Include URLs to relevant pages
  • Pre-populate form fields
  • Deep link to specific records
Rich Display:
  • Show thumbnails or icons
  • Format data in tables
  • Display progress indicators
Smart Filtering:
  • Filter by included data fields
  • Group related notifications
  • Auto-dismiss when action taken
Analytics:
  • Track which notifications are acted on
  • Measure response times
  • Identify notification effectiveness

Reading Notifications

Mark as Read

When user views a notification:
markAsRead(id_notificacion: string) {
  UPDATE notificaciones 
  SET leida = true 
  WHERE id_notificacion = id_notificacion;
}

Unread Count

Display badge with unread count:
getUnreadCount(id_usuario: string, id_localizacion: string) {
  SELECT COUNT(*) 
  FROM notificaciones 
  WHERE leida = false 
  AND (
    id_usuario = id_usuario OR 
    id_localizacion = id_localizacion OR
    (id_usuario IS NULL AND id_localizacion IS NULL)
  );
}

Mark All Read

Bulk action:
markAllAsRead(id_usuario: string) {
  UPDATE notificaciones 
  SET leida = true 
  WHERE (id_usuario = id_usuario OR id_usuario IS NULL)
  AND leida = false;
}

Notification Center UI

Display Components

Notification Bell:
  • Icon in navigation bar
  • Badge showing unread count
  • Animates when new notification arrives
Notification Panel:
  • Dropdown or sidebar
  • Grouped by priority
  • Sorted by date (recent first)
  • Filter by type or priority
  • Mark all read button
Notification Item:
<NotificationItem>
  <Priority badge />
  <Title>{titulo}</Title>
  <Message>{mensaje}</Message>
  <Timestamp>{fecha_creacion}</Timestamp>
  <Action button if data.action_url />
</NotificationItem>

Interaction Patterns

1

User Sees Badge

Bell icon shows unread count
2

Opens Panel

Click bell to view notifications
3

Scans List

High priority items at top
4

Clicks Notification

Marks as read, navigates if action URL present
5

Takes Action

Performs required task

Admin Notifications

Administrators can subscribe to specific events:
interface AdminNotificationSubscription {
  id_admin: string;
  notify_new_users: boolean;        // New user registrations
  notify_stock_alerts: boolean;     // Low stock warnings
  notify_warranties: boolean;       // Warranty claims
  notify_large_requests: boolean;   // Requests over threshold
}
When subscribed events occur, system auto-generates notifications for admins.
In Admin Settings:
  1. Navigate to Notification Preferences
  2. Toggle subscriptions:
    • New user registrations
    • Critical stock alerts
    • High-value warranty claims
    • Large requests (>20 items)
    • Count discrepancies (>10%)
  3. Set quiet hours (optional)
  4. Choose notification channels
  5. Save preferences
Admins receive high-priority notifications for subscribed events automatically.

Automatic Notifications

System generates notifications automatically for:

Low Stock

if (stock_actual < cantidad_minima) {
  createNotification({
    id_localizacion: item.id_localizacion,
    tipo: 'stock_bajo',
    prioridad: stock_actual === 0 ? 'alta' : 'media',
    titulo: `Stock bajo: ${item.nombre}`,
    mensaje: `${item.referencia} tiene solo ${stock_actual} unidades (mínimo: ${cantidad_minima})`,
    data: { id_repuesto, referencia, stock_actual, cantidad_minima }
  });
}

Request State Changes

onRequestStateChange(request) {
  createNotification({
    id_usuario: request.id_usuario_solicitante,
    tipo: 'solicitud',
    prioridad: 'media',
    titulo: `Solicitud ${request.numero} actualizada`,
    mensaje: `Estado: ${request.estado_nuevo}`,
    data: { id_solicitud, numero, estado_anterior, estado_nuevo }
  });
}

Warranty Resolution

onWarrantyResolved(warranty) {
  createNotification({
    id_usuario: warranty.reportado_por,
    tipo: 'garantia',
    prioridad: 'media',
    titulo: `Garantía resuelta: ${warranty.referencia_repuesto}`,
    mensaje: `Estado: ${warranty.estado}. ${warranty.comentarios_resolucion}`,
    data: { id_garantia, estado, referencia_repuesto }
  });
}

New User Registration

onNewUserRegistration(user) {
  // Notify subscribed admins
  createNotification({
    id_usuario: null, // Will target subscribed admins
    tipo: 'aprobacion',
    prioridad: 'media',
    titulo: 'Nuevo usuario requiere aprobación',
    mensaje: `${user.nombre} (${user.email}) ha solicitado acceso`,
    data: { id_usuario: user.id, nombre, email, rol_solicitado }
  });
}

Notification Lifecycle

1

Creation

Event triggers notification creation
2

Delivery

System determines recipients based on targeting
3

Display

Users see notification in their panel
4

Read

User views notification (leida = true)
5

Action

User takes action if required
6

Retention

Notifications kept for audit trail
Notifications are never deleted - they’re retained for audit purposes. Old read notifications can be archived from the UI but remain in the database.

Best Practices

For System Developers

1

Be Specific

Use clear titles and detailed messages
2

Set Appropriate Priority

Don’t overuse ‘alta’ - reserve for true emergencies
3

Include Actions

Add action URLs in data field when possible
4

Target Precisely

Send only to users who need to know
5

Avoid Spam

Batch similar notifications when appropriate

For Users

1

Check Regularly

Review notifications at least daily
2

Act Promptly

Respond to high-priority items immediately
3

Mark as Read

Keep notification center organized
4

Use Actions

Click action buttons to go directly to relevant pages

Permissions

ActionRequired Permission
View notificationsview_notifications
Mark as read(any authenticated user)
Create manualcreate_notification
Send broadcastbroadcast_notification
Delete notificationsdelete_notification
Configure admin alertsadmin_notifications

Future Enhancements

Push Notifications

Browser push for real-time alerts

Email Digest

Daily summary of notifications

SMS Alerts

Critical alerts via text message

Notification Preferences

User-configurable notification types

Build docs developers (and LLMs) love