- 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>
80 lines
2.3 KiB
Markdown
80 lines
2.3 KiB
Markdown
# 03-PLANEACION - Phase 1 MVP Implementation
|
|
|
|
## Plan de Implementación
|
|
|
|
### Task 10: Servicio de Notificaciones
|
|
|
|
#### Archivos a Crear
|
|
|
|
1. **notification.service.ts** (~500 líneas)
|
|
- Clase `NotificationService`
|
|
- Métodos: sendNotification, sendBulkNotification, broadcastNotification
|
|
- Canales: in_app (WebSocket), email, push
|
|
- Preferencias de usuario (quiet hours, disabled types)
|
|
- Templates de email por tipo
|
|
|
|
2. **notification.controller.ts** (~180 líneas)
|
|
- getNotifications, getUnreadCount
|
|
- markAsRead, markAllAsRead
|
|
- deleteNotification
|
|
- getPreferences, updatePreferences
|
|
|
|
3. **notification.routes.ts** (~50 líneas)
|
|
- GET /notifications
|
|
- GET /notifications/unread-count
|
|
- GET /notifications/preferences
|
|
- PATCH /notifications/preferences
|
|
- POST /notifications/read-all
|
|
- PATCH /notifications/:id/read
|
|
- DELETE /notifications/:id
|
|
|
|
4. **index.ts** (exports)
|
|
|
|
#### Modificaciones
|
|
|
|
1. **alerts.service.ts**: Integrar con notificationService en triggerAlert()
|
|
2. **index.ts**: Agregar notificationRouter a API routes
|
|
|
|
### Task 11: Distribution Job
|
|
|
|
#### Archivos a Crear
|
|
|
|
1. **distribution.job.ts** (~300 líneas)
|
|
- Clase `DistributionJob`
|
|
- Scheduler: setInterval para 00:00 UTC
|
|
- Métodos: run, getActiveAccounts, distributeReturns
|
|
- Cálculo de retornos diarios basado en producto
|
|
- Aplicación de performance fees
|
|
- Registro en distribution_history
|
|
- Notificación a usuarios
|
|
|
|
2. **index.ts** (exports)
|
|
|
|
#### Modificaciones
|
|
|
|
1. **index.ts**: Inicializar distributionJob.start() al arrancar servidor
|
|
|
|
## Orden de Implementación
|
|
|
|
```
|
|
1. notification.service.ts [Core]
|
|
2. notification.controller.ts [API]
|
|
3. notification.routes.ts [Routing]
|
|
4. notifications/index.ts [Exports]
|
|
5. Modificar alerts.service.ts [Integración]
|
|
6. distribution.job.ts [Core]
|
|
7. investment/jobs/index.ts [Exports]
|
|
8. Modificar main index.ts [Startup]
|
|
```
|
|
|
|
## Criterios de Aceptación
|
|
|
|
- [ ] Notificaciones en tiempo real via WebSocket
|
|
- [ ] Emails enviados con templates correctos
|
|
- [ ] API REST funcional para gestión de notificaciones
|
|
- [ ] Alertas de precio envían notificaciones automáticamente
|
|
- [ ] Distribution job programado para 00:00 UTC
|
|
- [ ] Cálculo correcto de rendimientos por producto
|
|
- [ ] Historial de distribuciones registrado
|
|
- [ ] TypeScript compila sin errores
|