- HERENCIA-SIMCO.md actualizado con directivas v3.7 y v3.8 - Actualizaciones de configuracion Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
740 lines
28 KiB
Markdown
740 lines
28 KiB
Markdown
# ANALISIS MAESTRO - Template SaaS Multi-Tenant
|
|
|
|
**Proyecto:** template-saas
|
|
**Fecha:** 2026-01-10
|
|
**Version:** 1.0.0
|
|
**Autor:** Arquitecto de Soluciones / Tech Lead
|
|
**Estado:** Documento de Referencia
|
|
|
|
---
|
|
|
|
## TABLA DE CONTENIDOS
|
|
|
|
1. [Resumen Ejecutivo](#1-resumen-ejecutivo)
|
|
2. [Estado Actual del Proyecto](#2-estado-actual-del-proyecto)
|
|
3. [Requerimientos Consolidados](#3-requerimientos-consolidados)
|
|
4. [Analisis de Dependencias](#4-analisis-de-dependencias)
|
|
5. [Estandares DevEnv](#5-estandares-devenv)
|
|
6. [Patrones de Referencia (gamilit)](#6-patrones-de-referencia-gamilit)
|
|
7. [Plan de Desarrollo Estructurado](#7-plan-de-desarrollo-estructurado)
|
|
8. [Orquestacion de Subagentes](#8-orquestacion-de-subagentes)
|
|
9. [Validacion Plan vs Requerimientos](#9-validacion-plan-vs-requerimientos)
|
|
10. [Proximas Acciones](#10-proximas-acciones)
|
|
|
|
---
|
|
|
|
## 1. RESUMEN EJECUTIVO
|
|
|
|
### 1.1 Proposito del Documento
|
|
|
|
Este documento consolida el analisis completo del proyecto template-saas, incluyendo:
|
|
- Estado actual de implementacion
|
|
- Requerimientos funcionales y tecnicos completos
|
|
- Mapa de dependencias entre modulos
|
|
- Plan de desarrollo estructurado con metodologia agil
|
|
- Guia de orquestacion para subagentes de desarrollo
|
|
|
|
### 1.2 Vision del Proyecto
|
|
|
|
Template base para desarrollo de plataformas SaaS multi-tenant con:
|
|
- **Multi-tenancy completo** con Row-Level Security (RLS)
|
|
- **Sistema de billing integrado** con Stripe
|
|
- **Tres portales:** Usuario Final, Admin de Tenant, Superadmin
|
|
- **Integracion IA** agnostica al proveedor (Claude, OpenAI, Gemini)
|
|
- **RBAC** (Role-Based Access Control) completo
|
|
|
|
### 1.3 Metricas Actuales
|
|
|
|
| Metrica | Objetivo | Actual | Estado |
|
|
|---------|----------|--------|--------|
|
|
| Documentacion | 100% | 100% | COMPLETADO |
|
|
| DDL Schemas | 12 | 12 | COMPLETADO |
|
|
| Tablas BD | 35 | 35 | COMPLETADO |
|
|
| Backend Modulos | 15 | 15 | COMPLETADO |
|
|
| Frontend Paginas | 15 | 15 | COMPLETADO |
|
|
| Tests | 400 | 387 | 97% |
|
|
| Cobertura Tests | 80% | 62.56% | 78% del objetivo |
|
|
| Completitud General | 100% | 95% | EN PROGRESO |
|
|
|
|
---
|
|
|
|
## 2. ESTADO ACTUAL DEL PROYECTO
|
|
|
|
### 2.1 Progreso por Fase
|
|
|
|
| Fase | SP Estimados | SP Completados | Porcentaje |
|
|
|------|--------------|----------------|------------|
|
|
| Fase 0 - Preparacion | 5 | 5 | 100% |
|
|
| Fase 1 - Foundation (DDL) | 28 | 28 | 100% |
|
|
| Fase 1 - Foundation (Backend) | 32 | 32 | 100% |
|
|
| Fase 2 - Frontend | 35 | 35 | 100% |
|
|
| Fase 3 - Features | 21 | 21 | 100% |
|
|
| Fase 4 - Portales | 24 | 8 | 33% |
|
|
| Fase 5 - Integraciones | 34 | 18 | 53% |
|
|
| **TOTAL** | **179** | **147** | **82%** |
|
|
|
|
### 2.2 Estado por Capa
|
|
|
|
#### 2.2.1 Database (DDL) - 100% COMPLETADO
|
|
|
|
| Schema | Tablas | RLS | Seeds | Estado |
|
|
|--------|--------|-----|-------|--------|
|
|
| auth | sessions, tokens, refresh_tokens, oauth_connections | Si | - | COMPLETADO |
|
|
| tenants | tenants, tenant_settings | Parcial | - | COMPLETADO |
|
|
| users | users, roles, user_roles, permissions, invitations | Si | 21 permisos | COMPLETADO |
|
|
| plans | plans, plan_features | No | 4 planes | COMPLETADO |
|
|
| billing | subscriptions, items, invoices, payments, methods | Si | - | COMPLETADO |
|
|
| audit | audit_logs, activity_logs | Si | - | COMPLETADO |
|
|
| notifications | templates, notifications, preferences, devices, queue, logs | Si | 6 templates | COMPLETADO |
|
|
| feature_flags | flags, tenant_flags, user_flags, evaluations | Si | 8 flags | COMPLETADO |
|
|
| ai | configs, usage | Si | - | COMPLETADO |
|
|
| storage | files, pending_uploads, usage | Si | - | COMPLETADO |
|
|
| webhooks | webhooks, deliveries | Si | - | COMPLETADO |
|
|
|
|
**Total:** 12 schemas, 35 tablas, 20+ RLS policies, 22 funciones
|
|
|
|
#### 2.2.2 Backend - 100% COMPLETADO
|
|
|
|
| Modulo | Endpoints | Tests | Estado |
|
|
|--------|-----------|-------|--------|
|
|
| auth | 15 | 45 | COMPLETADO |
|
|
| tenants | 8 | 12 | COMPLETADO |
|
|
| users | 10 | 18 | COMPLETADO |
|
|
| rbac | 12 | 15 | COMPLETADO |
|
|
| billing | 15 | 35 | COMPLETADO |
|
|
| notifications | 25 | 28 | COMPLETADO |
|
|
| health | 3 | 5 | COMPLETADO |
|
|
| audit | 8 | 22 | COMPLETADO |
|
|
| feature-flags | 10 | 25 | COMPLETADO |
|
|
| ai | 12 | 35 | COMPLETADO |
|
|
| storage | 15 | 30 | COMPLETADO |
|
|
| webhooks | 10 | 42 | COMPLETADO |
|
|
| email | 5 | 25 | COMPLETADO |
|
|
| superadmin | 12 | 20 | COMPLETADO |
|
|
| onboarding | 5 | 10 | COMPLETADO |
|
|
|
|
**Total:** 15 modulos, 165+ endpoints, 387 tests (62.56% cobertura)
|
|
|
|
#### 2.2.3 Frontend - 100% COMPLETADO
|
|
|
|
| Portal | Paginas | Componentes | Hooks | Estado |
|
|
|--------|---------|-------------|-------|--------|
|
|
| User | 5 | 25 | 15 | COMPLETADO |
|
|
| Admin | 6 | 30 | 20 | COMPLETADO |
|
|
| Superadmin | 4 | 20 | 15 | COMPLETADO |
|
|
| Shared | - | 80 | 25 | COMPLETADO |
|
|
|
|
**Total:** 15 paginas, 155+ componentes, 75+ hooks
|
|
|
|
#### 2.2.4 Integraciones - 100% COMPLETADO
|
|
|
|
| Integracion | Estado | Notas |
|
|
|-------------|--------|-------|
|
|
| Stripe | COMPLETADO | Suscripciones, webhooks, billing portal |
|
|
| PostgreSQL RLS | COMPLETADO | Multi-tenancy |
|
|
| Redis/BullMQ | COMPLETADO | Webhooks queue processing |
|
|
| OpenRouter/LLM | COMPLETADO | AI Integration via OpenRouter |
|
|
| SendGrid/SES | COMPLETADO | Email multi-provider |
|
|
| S3/Storage | COMPLETADO | AWS S3, R2, MinIO support |
|
|
| WebSocket | COMPLETADO | Real-time notifications |
|
|
| Web Push API | COMPLETADO | Push notifications (VAPID) |
|
|
|
|
### 2.3 Gaps Identificados
|
|
|
|
| Gap | Prioridad | SP Estimados | Descripcion |
|
|
|-----|-----------|--------------|-------------|
|
|
| Test Coverage | P0 | 8 | Subir cobertura de 62.56% a 80% |
|
|
| Portal Onboarding Wizard | P1 | 8 | Wizard multi-step para nuevos tenants |
|
|
| WhatsApp Business | P2 | 13 | Integracion con WhatsApp Business API |
|
|
| Documentacion ADRs | P2 | 3 | Completar ADRs pendientes |
|
|
| E2E Tests | P1 | 8 | Tests end-to-end con Playwright |
|
|
| Performance Monitoring | P2 | 5 | APM (New Relic/Datadog) |
|
|
|
|
---
|
|
|
|
## 3. REQUERIMIENTOS CONSOLIDADOS
|
|
|
|
### 3.1 Requerimientos Funcionales
|
|
|
|
#### RF-001: Arquitectura Multi-Tenant
|
|
|
|
| ID | Requerimiento | Estado | Implementacion |
|
|
|----|---------------|--------|----------------|
|
|
| RF-001.1 | Aislamiento de datos por tenant_id | COMPLETADO | RLS policies en todas las tablas |
|
|
| RF-001.2 | Tenant context via JWT claims | COMPLETADO | Middleware TenantContext |
|
|
| RF-001.3 | Tenant identificacion por subdominio/header | COMPLETADO | TenantMiddleware |
|
|
| RF-001.4 | Onboarding self-service de tenants | COMPLETADO | OnboardingController |
|
|
| RF-001.5 | Configuracion personalizada por tenant | COMPLETADO | tenant_settings table |
|
|
|
|
#### RF-002: Autenticacion y Seguridad
|
|
|
|
| ID | Requerimiento | Estado | Implementacion |
|
|
|----|---------------|--------|----------------|
|
|
| RF-002.1 | Login/registro con JWT | COMPLETADO | AuthService + JwtStrategy |
|
|
| RF-002.2 | Refresh tokens | COMPLETADO | refresh_tokens table |
|
|
| RF-002.3 | OAuth 2.0 (Google, GitHub, Microsoft) | COMPLETADO | OAuthService |
|
|
| RF-002.4 | MFA opcional | COMPLETADO | MfaService |
|
|
| RF-002.5 | Password policies | COMPLETADO | PasswordPolicy validator |
|
|
| RF-002.6 | Session management | COMPLETADO | sessions table + Redis |
|
|
| RF-002.7 | Rate limiting | COMPLETADO | ThrottlerGuard global |
|
|
|
|
#### RF-003: Gestion de Usuarios y RBAC
|
|
|
|
| ID | Requerimiento | Estado | Implementacion |
|
|
|----|---------------|--------|----------------|
|
|
| RF-003.1 | CRUD usuarios por tenant | COMPLETADO | UsersController |
|
|
| RF-003.2 | Roles predefinidos | COMPLETADO | roles table + seeds |
|
|
| RF-003.3 | Permisos granulares | COMPLETADO | permissions + role_permissions |
|
|
| RF-003.4 | Invitaciones por email | COMPLETADO | invitations table + EmailService |
|
|
| RF-003.5 | Impersonacion de usuarios | COMPLETADO | ImpersonateGuard |
|
|
| RF-003.6 | Guards por rol/permiso | COMPLETADO | RolesGuard, PermissionsGuard |
|
|
|
|
#### RF-004: Billing y Suscripciones
|
|
|
|
| ID | Requerimiento | Estado | Implementacion |
|
|
|----|---------------|--------|----------------|
|
|
| RF-004.1 | Integracion Stripe | COMPLETADO | StripeService |
|
|
| RF-004.2 | Planes (Free, Basic, Pro, Enterprise) | COMPLETADO | plans table + seeds |
|
|
| RF-004.3 | Suscripciones recurrentes | COMPLETADO | subscriptions table |
|
|
| RF-004.4 | Webhooks Stripe | COMPLETADO | StripeWebhookController |
|
|
| RF-004.5 | Portal de billing (upgrade/downgrade) | COMPLETADO | BillingController |
|
|
| RF-004.6 | Facturas y pagos | COMPLETADO | invoices, payments tables |
|
|
| RF-004.7 | Trial period (14 dias) | COMPLETADO | trial_ends_at field |
|
|
| RF-004.8 | Metered billing opcional | PARCIAL | usage_records table |
|
|
|
|
#### RF-005: Notificaciones
|
|
|
|
| ID | Requerimiento | Estado | Implementacion |
|
|
|----|---------------|--------|----------------|
|
|
| RF-005.1 | Email (templates) | COMPLETADO | EmailService + templates |
|
|
| RF-005.2 | In-app notifications | COMPLETADO | NotificationsGateway |
|
|
| RF-005.3 | Push notifications (Web Push) | COMPLETADO | PushNotificationService |
|
|
| RF-005.4 | Preferencias por usuario | COMPLETADO | user_preferences table |
|
|
| RF-005.5 | Cola asincrona | COMPLETADO | notification_queue + BullMQ |
|
|
| RF-005.6 | Real-time via WebSocket | COMPLETADO | Socket.IO gateway |
|
|
|
|
#### RF-006: AI Integration
|
|
|
|
| ID | Requerimiento | Estado | Implementacion |
|
|
|----|---------------|--------|----------------|
|
|
| RF-006.1 | Wrapper agnostico multi-proveedor | COMPLETADO | AiService |
|
|
| RF-006.2 | Soporte Claude, GPT-4, Gemini | COMPLETADO | Provider adapters |
|
|
| RF-006.3 | Token counting y cost tracking | COMPLETADO | ai.usage table |
|
|
| RF-006.4 | Rate limiting por tenant | COMPLETADO | AiRateLimitGuard |
|
|
| RF-006.5 | Configuracion por tenant | COMPLETADO | ai.configs table |
|
|
| RF-006.6 | Chat UI integrado | COMPLETADO | AiChatComponent |
|
|
|
|
#### RF-007: Portales
|
|
|
|
| ID | Requerimiento | Estado | Implementacion |
|
|
|----|---------------|--------|----------------|
|
|
| RF-007.1 | Portal Usuario Final | COMPLETADO | /dashboard, /profile, etc. |
|
|
| RF-007.2 | Portal Admin Tenant | COMPLETADO | /admin/* routes |
|
|
| RF-007.3 | Portal Superadmin | COMPLETADO | /superadmin/* routes |
|
|
| RF-007.4 | Onboarding Wizard | PENDIENTE | OnboardingPage + steps |
|
|
|
|
#### RF-008: Auditoria y Compliance
|
|
|
|
| ID | Requerimiento | Estado | Implementacion |
|
|
|----|---------------|--------|----------------|
|
|
| RF-008.1 | Audit logs de acciones | COMPLETADO | AuditInterceptor global |
|
|
| RF-008.2 | Activity logs por usuario | COMPLETADO | activity_logs table |
|
|
| RF-008.3 | Retencion configurable | COMPLETADO | cleanup functions |
|
|
| RF-008.4 | Exportacion de logs | COMPLETADO | AuditController export |
|
|
|
|
#### RF-009: Feature Flags
|
|
|
|
| ID | Requerimiento | Estado | Implementacion |
|
|
|----|---------------|--------|----------------|
|
|
| RF-009.1 | Flags por tenant | COMPLETADO | tenant_flags table |
|
|
| RF-009.2 | Flags por usuario | COMPLETADO | user_flags table |
|
|
| RF-009.3 | Rollout gradual (porcentaje) | COMPLETADO | evaluate_flag function |
|
|
| RF-009.4 | A/B testing | COMPLETADO | evaluations table |
|
|
| RF-009.5 | UI de administracion | COMPLETADO | FeatureFlagsPage |
|
|
|
|
#### RF-010: Storage y Archivos
|
|
|
|
| ID | Requerimiento | Estado | Implementacion |
|
|
|----|---------------|--------|----------------|
|
|
| RF-010.1 | Abstraccion multi-provider | COMPLETADO | StorageService |
|
|
| RF-010.2 | Soporte S3, R2, MinIO | COMPLETADO | Provider adapters |
|
|
| RF-010.3 | Limites por tenant | COMPLETADO | storage.usage table |
|
|
| RF-010.4 | Upload seguro (presigned URLs) | COMPLETADO | pending_uploads table |
|
|
| RF-010.5 | File management UI | COMPLETADO | StoragePage |
|
|
|
|
### 3.2 Requerimientos No Funcionales
|
|
|
|
| ID | Requerimiento | Estado | Notas |
|
|
|----|---------------|--------|-------|
|
|
| RNF-001 | Tiempo respuesta API < 200ms | COMPLETADO | Optimizado con indices |
|
|
| RNF-002 | Disponibilidad 99.9% | PARCIAL | Requiere infra prod |
|
|
| RNF-003 | Escalabilidad horizontal | COMPLETADO | Stateless backend |
|
|
| RNF-004 | GDPR compliance | COMPLETADO | Data export/delete |
|
|
| RNF-005 | Security headers (OWASP) | COMPLETADO | Helmet middleware |
|
|
| RNF-006 | Rate limiting | COMPLETADO | ThrottlerGuard |
|
|
| RNF-007 | Test coverage > 80% | PARCIAL | Actual: 62.56% |
|
|
|
|
---
|
|
|
|
## 4. ANALISIS DE DEPENDENCIAS
|
|
|
|
### 4.1 Mapa de Dependencias entre Modulos
|
|
|
|
```
|
|
┌─────────────────┐
|
|
│ plans │
|
|
│ (sin deps) │
|
|
└────────┬────────┘
|
|
│
|
|
┌──────────────────┼──────────────────┐
|
|
│ │ │
|
|
▼ ▼ ▼
|
|
┌───────────┐ ┌───────────┐ ┌───────────┐
|
|
│ auth │ │ tenants │ │ feature │
|
|
│(sin deps) │ │(sin deps) │ │ flags │
|
|
└─────┬─────┘ └─────┬─────┘ └─────┬─────┘
|
|
│ │ │
|
|
└────────┬────────┘ │
|
|
│ │
|
|
▼ │
|
|
┌───────────┐ │
|
|
│ users │◄────────────────────┘
|
|
│ (rbac) │
|
|
└─────┬─────┘
|
|
│
|
|
┌─────────────┼─────────────┐
|
|
│ │ │
|
|
▼ ▼ ▼
|
|
┌────────┐ ┌──────────┐ ┌───────────┐
|
|
│billing │ │ audit │ │notifications│
|
|
└────────┘ └──────────┘ └───────────┘
|
|
│
|
|
▼
|
|
┌───────────┐
|
|
│ onboarding│
|
|
└───────────┘
|
|
```
|
|
|
|
### 4.2 Orden de Ejecucion Recomendado
|
|
|
|
#### Fase 1: Base (Sin Dependencias)
|
|
|
|
| Orden | Modulo | Dependencias | SP |
|
|
|-------|--------|--------------|-----|
|
|
| 1.1 | plans | Ninguna | 5 |
|
|
| 1.2 | auth | Ninguna | 13 |
|
|
| 1.3 | tenants | Ninguna | 8 |
|
|
|
|
#### Fase 2: Core (Dependencias Nivel 1)
|
|
|
|
| Orden | Modulo | Dependencias | SP |
|
|
|-------|--------|--------------|-----|
|
|
| 2.1 | users | auth, tenants | 8 |
|
|
| 2.2 | rbac | users | 5 |
|
|
| 2.3 | feature-flags | plans, tenants | 5 |
|
|
|
|
#### Fase 3: Features (Dependencias Nivel 2)
|
|
|
|
| Orden | Modulo | Dependencias | SP |
|
|
|-------|--------|--------------|-----|
|
|
| 3.1 | billing | tenants, plans | 21 |
|
|
| 3.2 | notifications | users, tenants | 8 |
|
|
| 3.3 | audit | users, tenants | 5 |
|
|
| 3.4 | storage | users, tenants | 5 |
|
|
| 3.5 | webhooks | tenants, billing | 5 |
|
|
| 3.6 | ai-integration | users, tenants, plans | 8 |
|
|
|
|
#### Fase 4: Portales (Dependencias Nivel 3)
|
|
|
|
| Orden | Modulo | Dependencias | SP |
|
|
|-------|--------|--------------|-----|
|
|
| 4.1 | portal-user | auth, users | 13 |
|
|
| 4.2 | portal-admin | auth, users, billing | 13 |
|
|
| 4.3 | portal-superadmin | auth (role=superadmin) | 8 |
|
|
| 4.4 | onboarding | auth, tenants, billing, plans | 13 |
|
|
|
|
### 4.3 Dependencias Externas
|
|
|
|
| Servicio | Tipo | Requerido | Alternativas |
|
|
|----------|------|-----------|--------------|
|
|
| PostgreSQL 16+ | Database | SI | - |
|
|
| Redis 7+ | Cache/Queue | SI | - |
|
|
| Stripe | Payments | SI | PayPal, Mercado Pago |
|
|
| SendGrid | Email | RECOMENDADO | AWS SES, SMTP |
|
|
| S3 | Storage | RECOMENDADO | R2, MinIO |
|
|
| OpenRouter | AI | OPCIONAL | OpenAI, Anthropic direct |
|
|
|
|
---
|
|
|
|
## 5. ESTANDARES DEVENV
|
|
|
|
### 5.1 Asignacion de Puertos
|
|
|
|
Segun `DEVENV-PORTS-INVENTORY.yml`, el proyecto template-saas debe usar:
|
|
|
|
| Servicio | Puerto Asignado | Notas |
|
|
|----------|-----------------|-------|
|
|
| Frontend | 3150 | Base disponible |
|
|
| Backend | 3151 | Base + 1 |
|
|
| Storybook | 3152 | Opcional |
|
|
|
|
**Rango disponible:** 3150-3159 (gap disponible: 3144-3199)
|
|
|
|
### 5.2 Configuracion de Base de Datos
|
|
|
|
Segun `DEVENV-MASTER-INVENTORY.yml`:
|
|
|
|
```yaml
|
|
base_de_datos:
|
|
nombre: "template_saas_platform"
|
|
usuario: "template_saas_dev"
|
|
puerto: 5432 # Instancia unica compartida
|
|
redis_db: 9 # Siguiente disponible
|
|
schemas:
|
|
- auth
|
|
- tenants
|
|
- users
|
|
- plans
|
|
- billing
|
|
- notifications
|
|
- feature_flags
|
|
- audit
|
|
- ai
|
|
- storage
|
|
- webhooks
|
|
```
|
|
|
|
### 5.3 Estandares de Codigo
|
|
|
|
Alineados con gamilit:
|
|
|
|
| Aspecto | Estandar |
|
|
|---------|----------|
|
|
| Path Aliases | @modules/*, @shared/*, @config/* |
|
|
| Modulos Backend | controller + service + module + dto/ + entities/ |
|
|
| Componentes Frontend | Feature-Sliced Design (FSD) |
|
|
| State Management | Zustand |
|
|
| Forms | React Hook Form + Zod |
|
|
| Styling | Tailwind CSS 4.x |
|
|
| Testing Backend | Jest |
|
|
| Testing Frontend | Vitest + RTL |
|
|
|
|
---
|
|
|
|
## 6. PATRONES DE REFERENCIA (GAMILIT)
|
|
|
|
### 6.1 Patrones a Reutilizar
|
|
|
|
| Patron | Ubicacion Gamilit | Aplicabilidad |
|
|
|--------|-------------------|---------------|
|
|
| Constants SSOT | apps/backend/src/shared/constants/ | ALTA - Copiar estructura |
|
|
| Module Structure | apps/backend/src/modules/[name]/ | ALTA - Ya implementado |
|
|
| Feature-Sliced Design | apps/frontend/src/ | ALTA - Ya implementado |
|
|
| Sync ENUMs Script | apps/devops/scripts/sync-enums.ts | MEDIA - Implementar |
|
|
| Validate Constants | apps/devops/scripts/validate-constants-usage.ts | MEDIA - Implementar |
|
|
| Batch Triggers DDL | apps/database/ddl/ | ALTA - Ya implementado |
|
|
| RLS Policies Template | apps/database/ddl/rls/ | ALTA - Ya implementado |
|
|
|
|
### 6.2 Mejoras sobre Gamilit
|
|
|
|
| Aspecto | Gamilit | Template-SaaS |
|
|
|---------|---------|---------------|
|
|
| ORM | Raw SQL | TypeORM (recomendado) |
|
|
| Test Coverage | 14% | 62.56% (objetivo 80%) |
|
|
| Billing | No tiene | Stripe completo |
|
|
| Multi-tenant | Parcial | RLS completo |
|
|
| AI Integration | No tiene | Multi-proveedor |
|
|
| WebSocket | Basico | Avanzado (notifications v2) |
|
|
|
|
---
|
|
|
|
## 7. PLAN DE DESARROLLO ESTRUCTURADO
|
|
|
|
### 7.1 Metodologia
|
|
|
|
- **Framework:** Scrum adaptado para desarrollo con agentes
|
|
- **Sprint Duration:** 1 semana (equivalente a 5 SP ejecutables por agente)
|
|
- **Velocity Target:** 8-13 SP por sprint (dependiendo de complejidad)
|
|
- **Definition of Done:**
|
|
- Codigo implementado
|
|
- Tests unitarios (coverage > 80%)
|
|
- Documentacion actualizada
|
|
- Inventarios actualizados
|
|
- Code review (validacion)
|
|
|
|
### 7.2 Sprints Pendientes
|
|
|
|
#### Sprint 1: Cobertura de Tests (P0)
|
|
|
|
**Objetivo:** Subir cobertura de 62.56% a 80%
|
|
|
|
| ID | Tarea | Agente | SP | Dependencia |
|
|
|----|-------|--------|-----|-------------|
|
|
| TST-001 | Tests auth module adicionales | Backend-Agent | 2 | - |
|
|
| TST-002 | Tests billing edge cases | Backend-Agent | 2 | - |
|
|
| TST-003 | Tests notifications queue | Backend-Agent | 2 | - |
|
|
| TST-004 | Tests storage upload/download | Backend-Agent | 2 | - |
|
|
| **Total** | | | **8** | |
|
|
|
|
#### Sprint 2: Onboarding Wizard (P1)
|
|
|
|
**Objetivo:** Wizard multi-step para nuevos tenants
|
|
|
|
| ID | Tarea | Agente | SP | Dependencia |
|
|
|----|-------|--------|-----|-------------|
|
|
| ONB-001 | CompanyStep component | Frontend-Agent | 2 | - |
|
|
| ONB-002 | PlanStep component | Frontend-Agent | 2 | ONB-001 |
|
|
| ONB-003 | InviteStep component | Frontend-Agent | 2 | ONB-002 |
|
|
| ONB-004 | CompleteStep + routing | Frontend-Agent | 2 | ONB-003 |
|
|
| **Total** | | | **8** | |
|
|
|
|
#### Sprint 3: E2E Tests (P1)
|
|
|
|
**Objetivo:** Tests end-to-end con Playwright
|
|
|
|
| ID | Tarea | Agente | SP | Dependencia |
|
|
|----|-------|--------|-----|-------------|
|
|
| E2E-001 | Setup Playwright | Backend-Agent | 2 | - |
|
|
| E2E-002 | Auth flow tests | QA-Agent | 2 | E2E-001 |
|
|
| E2E-003 | Billing flow tests | QA-Agent | 2 | E2E-001 |
|
|
| E2E-004 | Admin portal tests | QA-Agent | 2 | E2E-001 |
|
|
| **Total** | | | **8** | |
|
|
|
|
#### Sprint 4: Documentacion y ADRs (P2)
|
|
|
|
**Objetivo:** Completar documentacion arquitectonica
|
|
|
|
| ID | Tarea | Agente | SP | Dependencia |
|
|
|----|-------|--------|-----|-------------|
|
|
| DOC-001 | ADR-001 Multi-tenancy | Docs-Agent | 1 | - |
|
|
| DOC-002 | ADR-002 Billing Model | Docs-Agent | 1 | - |
|
|
| DOC-003 | ADR-003 Portal Architecture | Docs-Agent | 1 | - |
|
|
| DOC-004 | Guia de Deployment | Docs-Agent | 2 | - |
|
|
| **Total** | | | **5** | |
|
|
|
|
#### Sprint 5: WhatsApp Integration (P2)
|
|
|
|
**Objetivo:** Integracion con WhatsApp Business API
|
|
|
|
| ID | Tarea | Agente | SP | Dependencia |
|
|
|----|-------|--------|-----|-------------|
|
|
| WA-001 | DDL schema whatsapp | Database-Agent | 2 | - |
|
|
| WA-002 | WhatsApp service backend | Backend-Agent | 5 | WA-001 |
|
|
| WA-003 | WhatsApp config UI | Frontend-Agent | 3 | WA-002 |
|
|
| WA-004 | Webhook handler | Backend-Agent | 3 | WA-002 |
|
|
| **Total** | | | **13** | |
|
|
|
|
### 7.3 Backlog Priorizado
|
|
|
|
| Prioridad | ID | Feature | SP | Sprint |
|
|
|-----------|-----|---------|-----|--------|
|
|
| P0 | TST-* | Test Coverage 80% | 8 | Sprint 1 |
|
|
| P1 | ONB-* | Onboarding Wizard | 8 | Sprint 2 |
|
|
| P1 | E2E-* | E2E Tests | 8 | Sprint 3 |
|
|
| P2 | DOC-* | Documentacion ADRs | 5 | Sprint 4 |
|
|
| P2 | WA-* | WhatsApp Business | 13 | Sprint 5 |
|
|
| P3 | MON-* | Performance Monitoring | 5 | Backlog |
|
|
| P3 | PWA-* | PWA Configuration | 3 | Backlog |
|
|
|
|
**Total SP Pendientes:** 50 SP (~5 sprints)
|
|
|
|
---
|
|
|
|
## 8. ORQUESTACION DE SUBAGENTES
|
|
|
|
### 8.1 Perfiles de Agentes
|
|
|
|
| Perfil | Responsabilidades | Herramientas |
|
|
|--------|-------------------|--------------|
|
|
| **Database-Agent** | DDL, migraciones, RLS, seeds | psql, SQL |
|
|
| **Backend-Agent** | NestJS modules, services, tests | npm, jest |
|
|
| **Frontend-Agent** | React components, hooks, pages | npm, vitest |
|
|
| **QA-Agent** | E2E tests, validaciones | playwright |
|
|
| **Docs-Agent** | Documentacion, ADRs | markdown |
|
|
| **DevOps-Agent** | CI/CD, Docker, deploys | docker, gh |
|
|
|
|
### 8.2 Flujo de Orquestacion
|
|
|
|
```
|
|
┌─────────────────────────────────────────────────────────────────┐
|
|
│ ORQUESTADOR (Tech Lead) │
|
|
├─────────────────────────────────────────────────────────────────┤
|
|
│ 1. Lee ANALISIS-MAESTRO │
|
|
│ 2. Selecciona Sprint/Tareas │
|
|
│ 3. Asigna a Agente segun perfil │
|
|
│ 4. Proporciona contexto (archivos, dependencias) │
|
|
│ 5. Valida entregables │
|
|
│ 6. Actualiza inventarios y status │
|
|
└──────────────────────────┬──────────────────────────────────────┘
|
|
│
|
|
┌───────────────┼───────────────┐
|
|
│ │ │
|
|
▼ ▼ ▼
|
|
┌──────────┐ ┌──────────┐ ┌──────────┐
|
|
│ Database │ │ Backend │ │ Frontend │
|
|
│ Agent │ │ Agent │ │ Agent │
|
|
└────┬─────┘ └────┬─────┘ └────┬─────┘
|
|
│ │ │
|
|
│ ┌────────┴────────┐ │
|
|
│ │ │ │
|
|
▼ ▼ ▼ ▼
|
|
┌─────────────────────────────────────────┐
|
|
│ VALIDACION (QA-Agent) │
|
|
└─────────────────────────────────────────┘
|
|
│
|
|
▼
|
|
┌─────────────────────────────────────────┐
|
|
│ DOCUMENTACION (Docs-Agent) │
|
|
└─────────────────────────────────────────┘
|
|
```
|
|
|
|
### 8.3 Template de Asignacion de Tarea
|
|
|
|
```yaml
|
|
# TAREA: {ID}
|
|
# Fecha: YYYY-MM-DD
|
|
|
|
agente: "{Perfil-Agent}"
|
|
tarea_id: "{ID}"
|
|
tarea_nombre: "{Nombre}"
|
|
sprint: "{Sprint N}"
|
|
sp: {N}
|
|
|
|
contexto:
|
|
archivos_leer:
|
|
- "ruta/archivo1.ts"
|
|
- "ruta/archivo2.ts"
|
|
dependencias:
|
|
- "modulo_x completado"
|
|
inventarios:
|
|
- "@INV_BE"
|
|
- "@INV_FE"
|
|
|
|
entregables:
|
|
- "ruta/nuevo_archivo1.ts"
|
|
- "ruta/nuevo_archivo2.ts"
|
|
- "tests correspondientes"
|
|
|
|
criterios_aceptacion:
|
|
- "Criterio 1"
|
|
- "Criterio 2"
|
|
- "Tests pasan (coverage > 80%)"
|
|
|
|
validacion:
|
|
comandos:
|
|
- "npm run test"
|
|
- "npm run lint"
|
|
archivos_actualizar:
|
|
- "@INVENTORY"
|
|
- "@TRAZA"
|
|
```
|
|
|
|
### 8.4 Ejecucion Paralela
|
|
|
|
Tareas que pueden ejecutarse en paralelo:
|
|
|
|
| Sprint 1 | Paralelo |
|
|
|----------|----------|
|
|
| TST-001 (auth) | TST-002 (billing) |
|
|
| TST-003 (notifications) | TST-004 (storage) |
|
|
|
|
| Sprint 2 | Secuencial |
|
|
|----------|------------|
|
|
| ONB-001 -> ONB-002 -> ONB-003 -> ONB-004 |
|
|
|
|
| Sprint 3 | Paralelo despues de setup |
|
|
|----------|---------------------------|
|
|
| E2E-001 (setup) |
|
|
| E2E-002, E2E-003, E2E-004 (paralelo) |
|
|
|
|
---
|
|
|
|
## 9. VALIDACION PLAN VS REQUERIMIENTOS
|
|
|
|
### 9.1 Matriz de Cobertura
|
|
|
|
| Requerimiento | Estado Actual | Sprint Pendiente |
|
|
|---------------|---------------|------------------|
|
|
| RF-001 Multi-Tenant | COMPLETADO | - |
|
|
| RF-002 Auth/Security | COMPLETADO | - |
|
|
| RF-003 Users/RBAC | COMPLETADO | - |
|
|
| RF-004 Billing | COMPLETADO | - |
|
|
| RF-005 Notifications | COMPLETADO | - |
|
|
| RF-006 AI Integration | COMPLETADO | - |
|
|
| RF-007.1-3 Portales | COMPLETADO | - |
|
|
| RF-007.4 Onboarding Wizard | PENDIENTE | Sprint 2 |
|
|
| RF-008 Audit | COMPLETADO | - |
|
|
| RF-009 Feature Flags | COMPLETADO | - |
|
|
| RF-010 Storage | COMPLETADO | - |
|
|
| RNF-007 Test Coverage 80% | PARCIAL (62.56%) | Sprint 1 |
|
|
|
|
### 9.2 Gaps de Requerimientos
|
|
|
|
| Gap | Tipo | Impacto | Resolucion |
|
|
|-----|------|---------|------------|
|
|
| Onboarding Wizard | Funcional | MEDIO | Sprint 2 |
|
|
| Test Coverage | Calidad | ALTO | Sprint 1 |
|
|
| E2E Tests | Calidad | MEDIO | Sprint 3 |
|
|
| WhatsApp Business | Funcional | BAJO | Sprint 5 |
|
|
|
|
### 9.3 Validacion de Dependencias
|
|
|
|
Todas las dependencias identificadas en Seccion 4 estan resueltas:
|
|
- [x] plans: Sin dependencias
|
|
- [x] auth: Sin dependencias
|
|
- [x] tenants: Sin dependencias
|
|
- [x] users: Depende de auth, tenants (completados)
|
|
- [x] billing: Depende de tenants, plans (completados)
|
|
- [x] notifications: Depende de users, tenants (completados)
|
|
|
|
---
|
|
|
|
## 10. PROXIMAS ACCIONES
|
|
|
|
### 10.1 Inmediatas (Esta Sesion)
|
|
|
|
1. [x] Crear ANALISIS-MAESTRO-TEMPLATE-SAAS.md
|
|
2. [ ] Crear PLAN-SPRINT-1-TESTS.md
|
|
3. [ ] Actualizar PROJECT-STATUS.md con gaps
|
|
4. [ ] Actualizar PROXIMA-ACCION.md
|
|
|
|
### 10.2 Sprint 1 (Siguiente)
|
|
|
|
1. Ejecutar TST-001 a TST-004 con Backend-Agent
|
|
2. Validar cobertura alcanzada
|
|
3. Actualizar inventarios
|
|
|
|
### 10.3 Entregables de Documentacion
|
|
|
|
| Documento | Estado | Prioridad |
|
|
|-----------|--------|-----------|
|
|
| ANALISIS-MAESTRO-TEMPLATE-SAAS.md | CREADO | P0 |
|
|
| PLAN-SPRINT-1-TESTS.md | PENDIENTE | P0 |
|
|
| PLAN-SPRINT-2-ONBOARDING.md | PENDIENTE | P1 |
|
|
| PLAN-SPRINT-3-E2E.md | PENDIENTE | P1 |
|
|
|
|
---
|
|
|
|
## CONTROL DE VERSIONES
|
|
|
|
| Version | Fecha | Autor | Cambios |
|
|
|---------|-------|-------|---------|
|
|
| 1.0.0 | 2026-01-10 | Tech Lead | Documento inicial completo |
|
|
|
|
---
|
|
|
|
## REFERENCIAS
|
|
|
|
- `orchestration/PROJECT-STATUS.md` - Estado actual
|
|
- `orchestration/PROXIMA-ACCION.md` - Siguiente tarea
|
|
- `orchestration/inventarios/MASTER_INVENTORY.yml` - Inventario principal
|
|
- `docs/_MAP.md` - Mapa de documentacion
|
|
- `docs/00-vision-general/ESPECIFICACION-PLATAFORMA-SAAS.md` - Requerimientos completos
|
|
- `../../orchestration/inventarios/DEVENV-PORTS-INVENTORY.yml` - Puertos asignados
|
|
- `../../orchestration/inventarios/DEVENV-MASTER-INVENTORY.yml` - Estandares DevEnv
|
|
|
|
---
|
|
|
|
**Creado:** 2026-01-10
|
|
**Sistema:** NEXUS v4.0 | SIMCO
|