trading-platform/orchestration/tareas/TASK-2026-01-25-NOTIFICACIONES-COMPLETAS/03-PLANEACION.md
Adrian Flores Cortes 9c2fce0083 docs: Complete documentation for notifications system implementation
- Create TASK-2026-01-25-NOTIFICACIONES-COMPLETAS with full CAPVED docs
- Update DATABASE_INVENTORY with auth.notifications, auth.user_push_tokens,
  investment.distribution_history, investment.distribution_runs tables
- Update BACKEND_INVENTORY with push-token endpoints, firebase.client,
  and unit tests
- Update FRONTEND_INVENTORY with notification components, store, service
- Update MASTER_INVENTORY with updated totals
- Update _INDEX.yml with new task entry

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-25 04:10:09 -06:00

57 lines
1.7 KiB
Markdown

# 03-PLANEACION - Sistema de Notificaciones Completo
## Orden de Implementacion
### Fase 1: DDL (4 archivos)
1. `auth/tables/11-notifications.sql`
- Tabla principal de notificaciones
- Constraints para type, priority, icon_type
- Indices para user_id, created_at, unread
2. `auth/tables/12-user_push_tokens.sql`
- Tokens FCM/APNs por usuario
- Constraint platform (web, ios, android)
- Indice partial para tokens activos
3. `investment/tables/08-distribution_history.sql`
- Historial de distribuciones por cuenta
- Constraint unique (account_id, distribution_date)
- Constraint valid_balance_change
4. `investment/tables/09-distribution_runs.sql`
- Logs de ejecucion del job
- Constraint valid_counts
- Indice por run_date DESC
### Fase 2: Backend Push Notifications
1. Instalar dependencias: `firebase-admin`, `web-push`
2. Actualizar config/index.ts con firebase y webPush
3. Crear firebase.client.ts con:
- sendToDevice()
- sendToMultiple()
- deactivateInvalidTokens()
4. Actualizar notification.service.ts para usar firebaseClient
5. Agregar endpoints push-token en controller y routes
### Fase 3: Tests Unitarios
1. notification.service.spec.ts (~450 lineas)
- Mocks de db, wsManager, nodemailer, firebase
- Tests para cada metodo publico
2. distribution.job.spec.ts (~380 lineas)
- Mocks de db, notification service
- Tests para logica de distribucion
### Fase 4: Frontend
1. notification.service.ts - API client
2. notificationStore.ts - Zustand con WebSocket
3. NotificationBell.tsx - Icono con badge
4. NotificationDropdown.tsx - Lista reciente
5. NotificationItem.tsx - Item individual
6. NotificationsPage.tsx - Pagina completa
7. Actualizar MainLayout.tsx y App.tsx