# Matriz de Integración: Template-SaaS → Trading-Platform **Subtarea:** 1.2 **Fecha:** 2026-01-30 **Agente:** Claude Code (Opus 4.5) --- ## 1. RESUMEN EJECUTIVO | Categoría | Módulos | Integrados | Parcialmente | No Integrados | |-----------|---------|------------|--------------|---------------| | Core (SAAS-001 a 005) | 5 | 2 | 2 | 1 | | Platform (SAAS-006 a 014) | 9 | 3 | 2 | 4 | | Extended (SAAS-015 a 022) | 5 | 1 | 1 | 3 | | **TOTAL** | **19** | **6 (32%)** | **5 (26%)** | **8 (42%)** | **Nota:** Trading-platform es STANDALONE. Los módulos se "copian/adaptan", no se heredan. --- ## 2. MATRIZ DETALLADA ### 2.1 Core SaaS (SAAS-001 a SAAS-005) | ID | Template-SaaS | Trading Equiv. | Estado | Acción | |----|---------------|----------------|--------|--------| | SAAS-001 | Auth (JWT, OAuth, MFA) | OQI-001 (85%) | **PARCIAL** | Evaluar MFA y OAuth de template | | SAAS-002 | Tenants (Multi-tenancy) | N/A | **NO APLICA** | Trading es single-tenant por diseño | | SAAS-003 | Users (RBAC) | users module (backend) | **INTEGRADO** | Ya tiene RBAC básico | | SAAS-004 | Billing (Stripe) | OQI-005 (65%) | **PARCIAL** | Adoptar webhooks y refunds | | SAAS-005 | Plans (Límites) | subscription.service | **INTEGRADO** | Ya maneja planes | ### 2.2 Platform Features (SAAS-006 a SAAS-014) | ID | Template-SaaS | Trading Equiv. | Estado | Acción | |----|---------------|----------------|--------|--------| | SAAS-006 | AI Integration | OQI-007 (45%) | **PARCIAL** | Diferente enfoque (trading vs chat) | | SAAS-007 | Notifications | notifications module | **INTEGRADO** | Multi-canal implementado | | SAAS-008 | Audit Logs | audit schema (DDL) | **PARCIAL** | Solo DDL, falta backend service | | SAAS-009 | Feature Flags | N/A | **NO INTEGRADO** | Evaluar adopción | | SAAS-010 | Webhooks | N/A | **NO INTEGRADO** | Útil para trading events | | SAAS-011 | Storage | storage.service | **INTEGRADO** | S3/R2 ya implementado | | SAAS-012 | CRUD Base | N/A | **NO APLICA** | Solo documentación | | SAAS-013 | Email | email.service (auth) | **INTEGRADO** | Básico implementado | | SAAS-014 | WhatsApp | N/A | **NO INTEGRADO** | Baja prioridad para trading | ### 2.3 Extended Features (SAAS-015 a SAAS-022) | ID | Template-SaaS | Trading Equiv. | Estado | Acción | |----|---------------|----------------|--------|--------| | SAAS-015 | OAuth 2.0 | oauth.service | **INTEGRADO** | Google, Facebook, GitHub, Apple | | SAAS-018 | Sales | N/A | **NO INTEGRADO** | No aplica a trading | | SAAS-019 | Portfolio (Catálogo) | OQI-008 (45%) | **PARCIAL** | Adaptar para Trading Pairs | | SAAS-020 | Commissions | N/A | **NO INTEGRADO** | Adaptar para Trading Fees | | SAAS-021 | MLM | N/A | **NO INTEGRADO** | Adaptar para Affiliate Program | | SAAS-022 | Goals | N/A | **NO INTEGRADO** | Adaptar para Trading Targets | --- ## 3. ANÁLISIS POR REUTILIZABILIDAD ### 3.1 Alta Reutilizabilidad (>80%) | Módulo | Razón | Esfuerzo Estimado | |--------|-------|-------------------| | SAAS-007 Notifications | Ya implementado, solo mejorar | Bajo | | SAAS-008 Audit Logs | Patrón estándar, útil para compliance | Medio | | SAAS-009 Feature Flags | Toggle de features en trading | Medio | | SAAS-010 Webhooks | Eventos de trading hacia externos | Medio | ### 3.2 Media Reutilizabilidad (50-80%) | Módulo | Razón | Esfuerzo Estimado | |--------|-------|-------------------| | SAAS-001 Auth | MFA y OAuth más robusto | Medio | | SAAS-004 Billing | Refunds, invoices, subscription lifecycle | Medio | | SAAS-019 Portfolio | Adaptar catálogo → Trading Pairs | Alto | | SAAS-022 Goals | Adaptar metas → Trading Targets | Medio | ### 3.3 Baja Reutilizabilidad (<50%) | Módulo | Razón | Recomendación | |--------|-------|---------------| | SAAS-002 Tenants | Trading es single-tenant | NO ADOPTAR | | SAAS-006 AI | Diferente enfoque (chat vs trading) | MANTENER PROPIO | | SAAS-014 WhatsApp | No prioritario | POSPONER | | SAAS-018 Sales | No aplica a trading | NO ADOPTAR | | SAAS-020 Commissions | Muy diferente (ventas vs trading) | EVALUAR | | SAAS-021 MLM | Complejo, baja prioridad | POSPONER | --- ## 4. GAPS IDENTIFICADOS ### 4.1 Gaps de Alta Prioridad (P0-P1) | Gap | Módulo Template | Impacto Trading | Prioridad | |-----|-----------------|-----------------|-----------| | G-TS-001 | SAAS-008 Audit Logs | Compliance, debugging | P1 | | G-TS-002 | SAAS-009 Feature Flags | Feature rollout controlado | P1 | | G-TS-003 | SAAS-001 MFA | Seguridad de cuentas | P1 | ### 4.2 Gaps de Media Prioridad (P2) | Gap | Módulo Template | Impacto Trading | Prioridad | |-----|-----------------|-----------------|-----------| | G-TS-004 | SAAS-010 Webhooks | Integración con externos | P2 | | G-TS-005 | SAAS-004 Refunds | Gestión de devoluciones | P2 | | G-TS-006 | SAAS-022 Goals | Trading targets | P2 | ### 4.3 Gaps de Baja Prioridad (P3) | Gap | Módulo Template | Impacto Trading | Prioridad | |-----|-----------------|-----------------|-----------| | G-TS-007 | SAAS-019 Portfolio | Trading pairs catalog | P3 | | G-TS-008 | SAAS-021 MLM | Affiliate program | P3 | --- ## 5. RECOMENDACIONES DE ADOPCIÓN ### 5.1 Adoptar Inmediatamente (Copiar código) 1. **SAAS-008 Audit Logs** - Copiar patrón completo - DDL ya existe en trading, falta backend service - Copiar de template-saas: audit.service.ts, audit.module.ts 2. **SAAS-009 Feature Flags** - Adoptar módulo completo - Útil para rollout de features ML - Copiar módulo completo de template-saas ### 5.2 Evaluar y Adaptar 3. **SAAS-001 MFA** - Evaluar implementación - Trading requiere alta seguridad - Adaptar de template-saas: mfa.service.ts, twofa.controller.ts 4. **SAAS-010 Webhooks** - Adaptar para eventos de trading - Copiar infraestructura BullMQ - Adaptar eventos: trade_executed, signal_generated, etc. ### 5.3 No Adoptar / Posponer 5. **SAAS-002 Tenants** - No aplica (single-tenant) 6. **SAAS-014 WhatsApp** - Baja prioridad 7. **SAAS-018 Sales** - No aplica 8. **SAAS-021 MLM** - Complejidad alta, evaluar después --- ## 6. ARQUITECTURA COMPARADA ### Template-SaaS (NestJS) ``` backend/src/modules/ ├── auth/ │ ├── auth.module.ts │ ├── auth.service.ts │ ├── auth.controller.ts │ ├── strategies/ │ └── guards/ ├── notifications/ │ ├── notifications.module.ts │ ├── notifications.service.ts │ └── gateway/ │ └── notifications.gateway.ts (WebSocket) └── webhooks/ ├── webhooks.module.ts ├── webhooks.service.ts └── processors/ └── webhook.processor.ts (BullMQ) ``` ### Trading-Platform (Express.js) ``` apps/backend/src/modules/ ├── auth/ │ ├── token.service.ts │ ├── oauth.service.ts │ ├── twofa.service.ts │ └── auth.routes.ts ├── notifications/ │ ├── notification.service.ts │ ├── notification.controller.ts │ └── notification.routes.ts └── [webhooks no existe] ``` **Diferencia arquitectónica:** Template usa NestJS (decorators, DI), Trading usa Express (functional). **Implicación:** Adaptar código, no copiar directamente. --- ## 7. CONCLUSIÓN | Métrica | Valor | |---------|-------| | Módulos template-saas | 19 (sin contar SAAS-012 y tenants) | | Ya integrados | 6 (32%) | | Parcialmente integrados | 5 (26%) | | No integrados (candidatos) | 8 (42%) | | Recomendados para adopción | 4 (SAAS-008, 009, MFA, 010) | **Próxima acción:** Crear tareas específicas para adopción de: 1. SAAS-008 Audit Logs (P1) 2. SAAS-009 Feature Flags (P1) 3. MFA de SAAS-001 (P1) 4. SAAS-010 Webhooks (P2) --- **Subtarea completada:** 1.2 Auditar integración template-saas → trading-platform **Estado:** COMPLETADA **Siguiente:** 1.3 Auditar documentación workspace vs proyecto