- HERENCIA-SIMCO.md actualizado con directivas v3.7 y v3.8 - Actualizaciones de configuracion Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
993 lines
22 KiB
Markdown
993 lines
22 KiB
Markdown
# FASE 2: ANALISIS DETALLADO - DOCUMENTACION TEMPLATE-SAAS
|
|
|
|
**Fecha:** 2026-01-10
|
|
**Proyecto:** template-saas
|
|
**Estado:** COMPLETADO
|
|
**Perfil:** ORQUESTADOR (TECH-LEADER)
|
|
**Referencia:** FASE-1-ANALISIS-INICIAL-DOCUMENTACION-2026-01-10.md
|
|
|
|
---
|
|
|
|
## 1. RESUMEN EJECUTIVO
|
|
|
|
La FASE 2 analizo en detalle los gaps identificados en FASE 1, generando contenido especifico para cada archivo que requiere modificacion o creacion.
|
|
|
|
### Alcance del Analisis
|
|
|
|
| Area | Archivos | Contenido Generado |
|
|
|------|----------|-------------------|
|
|
| Frontmatter YAML | 26 | YAML exacto para cada archivo |
|
|
| Integraciones INT | 7 | Secciones faltantes (Fallbacks, Endpoints, etc.) |
|
|
| Especificaciones Tecnicas | 13 | Estructura completa ET-SAAS-* |
|
|
| ADRs Nuevos | 6 | Contexto, decision, alternativas |
|
|
|
|
---
|
|
|
|
## 2. ANALISIS G1: FRONTMATTER YAML (26 archivos)
|
|
|
|
### 2.1 Grupo 1: docs/00-vision-general/ (4 archivos)
|
|
|
|
#### README.md
|
|
```yaml
|
|
---
|
|
id: "VIS-001"
|
|
title: "Vision General Template SaaS"
|
|
type: "Overview"
|
|
status: "Published"
|
|
priority: "P0"
|
|
version: "1.0.0"
|
|
created_date: "2026-01-07"
|
|
updated_date: "2026-01-10"
|
|
---
|
|
```
|
|
|
|
#### VISION-TEMPLATE-SAAS.md
|
|
```yaml
|
|
---
|
|
id: "VIS-002"
|
|
title: "Vision Template SaaS Multi-Tenant"
|
|
type: "Vision"
|
|
status: "Published"
|
|
priority: "P0"
|
|
version: "1.0.0"
|
|
created_date: "2026-01-07"
|
|
updated_date: "2026-01-10"
|
|
---
|
|
```
|
|
|
|
#### ESPECIFICACION-PLATAFORMA-SAAS.md
|
|
```yaml
|
|
---
|
|
id: "VIS-003"
|
|
title: "Especificacion Plataforma SaaS"
|
|
type: "Specification"
|
|
status: "Published"
|
|
priority: "P0"
|
|
version: "1.0.0"
|
|
created_date: "2026-01-07"
|
|
updated_date: "2026-01-10"
|
|
---
|
|
```
|
|
|
|
#### ARQUITECTURA-MULTI-TENANT.md
|
|
```yaml
|
|
---
|
|
id: "VIS-004"
|
|
title: "Arquitectura Multi-Tenant"
|
|
type: "Architecture"
|
|
status: "Published"
|
|
priority: "P0"
|
|
version: "1.0.0"
|
|
created_date: "2026-01-07"
|
|
updated_date: "2026-01-10"
|
|
---
|
|
```
|
|
|
|
### 2.2 Grupo 2: docs/02-especificaciones/ (2 archivos)
|
|
|
|
#### ET-SAAS-007-notifications-v2.md
|
|
```yaml
|
|
---
|
|
id: "ET-SAAS-007"
|
|
title: "Especificacion Tecnica Notifications v2"
|
|
type: "TechnicalSpec"
|
|
status: "Published"
|
|
priority: "P0"
|
|
module: "notifications"
|
|
version: "2.0.0"
|
|
created_date: "2026-01-08"
|
|
updated_date: "2026-01-10"
|
|
---
|
|
```
|
|
|
|
#### PLAN-IMPLEMENTACION-NOTIFICATIONS-V2.md
|
|
```yaml
|
|
---
|
|
id: "PLAN-SAAS-007"
|
|
title: "Plan Implementacion Notifications v2"
|
|
type: "ImplementationPlan"
|
|
status: "Completed"
|
|
priority: "P1"
|
|
module: "notifications"
|
|
version: "1.0.0"
|
|
created_date: "2026-01-08"
|
|
updated_date: "2026-01-10"
|
|
---
|
|
```
|
|
|
|
### 2.3 Grupo 3: docs/02-integraciones/ (7 archivos)
|
|
|
|
#### INT-001-stripe.md
|
|
```yaml
|
|
---
|
|
id: "INT-001"
|
|
title: "Integracion Stripe Billing"
|
|
type: "Integration"
|
|
status: "Implemented"
|
|
priority: "P0"
|
|
provider: "Stripe"
|
|
category: "Payments"
|
|
multi_tenant: true
|
|
version: "1.0.0"
|
|
created_date: "2026-01-07"
|
|
updated_date: "2026-01-10"
|
|
---
|
|
```
|
|
|
|
#### INT-002-oauth.md
|
|
```yaml
|
|
---
|
|
id: "INT-002"
|
|
title: "Integracion OAuth Providers"
|
|
type: "Integration"
|
|
status: "Roadmap"
|
|
priority: "P1"
|
|
provider: "Multiple"
|
|
category: "Authentication"
|
|
multi_tenant: true
|
|
version: "1.0.0"
|
|
created_date: "2026-01-07"
|
|
updated_date: "2026-01-10"
|
|
---
|
|
```
|
|
|
|
#### INT-003-email.md
|
|
```yaml
|
|
---
|
|
id: "INT-003"
|
|
title: "Integracion Email Providers"
|
|
type: "Integration"
|
|
status: "Implemented"
|
|
priority: "P0"
|
|
provider: "SendGrid/SES/SMTP"
|
|
category: "Notifications"
|
|
multi_tenant: true
|
|
version: "1.0.0"
|
|
created_date: "2026-01-07"
|
|
updated_date: "2026-01-10"
|
|
---
|
|
```
|
|
|
|
#### INT-004-push.md
|
|
```yaml
|
|
---
|
|
id: "INT-004"
|
|
title: "Integracion Push Notifications"
|
|
type: "Integration"
|
|
status: "Implemented"
|
|
priority: "P1"
|
|
provider: "FCM/APNs"
|
|
category: "Notifications"
|
|
multi_tenant: true
|
|
version: "1.0.0"
|
|
created_date: "2026-01-07"
|
|
updated_date: "2026-01-10"
|
|
---
|
|
```
|
|
|
|
#### INT-005-storage.md
|
|
```yaml
|
|
---
|
|
id: "INT-005"
|
|
title: "Integracion Storage Providers"
|
|
type: "Integration"
|
|
status: "Implemented"
|
|
priority: "P1"
|
|
provider: "S3/R2/MinIO"
|
|
category: "Storage"
|
|
multi_tenant: true
|
|
version: "1.0.0"
|
|
created_date: "2026-01-07"
|
|
updated_date: "2026-01-10"
|
|
---
|
|
```
|
|
|
|
#### INT-006-webhooks.md
|
|
```yaml
|
|
---
|
|
id: "INT-006"
|
|
title: "Integracion Webhooks Outbound"
|
|
type: "Integration"
|
|
status: "Implemented"
|
|
priority: "P1"
|
|
provider: "Internal"
|
|
category: "Messaging"
|
|
multi_tenant: true
|
|
version: "1.0.0"
|
|
created_date: "2026-01-07"
|
|
updated_date: "2026-01-10"
|
|
---
|
|
```
|
|
|
|
#### INT-007-redis.md
|
|
```yaml
|
|
---
|
|
id: "INT-007"
|
|
title: "Integracion Redis Cache/Queue"
|
|
type: "Integration"
|
|
status: "Implemented"
|
|
priority: "P0"
|
|
provider: "Redis/Upstash"
|
|
category: "Infrastructure"
|
|
multi_tenant: false
|
|
version: "1.0.0"
|
|
created_date: "2026-01-07"
|
|
updated_date: "2026-01-10"
|
|
---
|
|
```
|
|
|
|
### 2.4 Grupo 4: docs/02-devops/ (2 archivos)
|
|
|
|
#### CICD-GUIDE.md
|
|
```yaml
|
|
---
|
|
id: "DEVOPS-001"
|
|
title: "Guia CI/CD"
|
|
type: "Guide"
|
|
status: "Published"
|
|
priority: "P1"
|
|
version: "1.0.0"
|
|
created_date: "2026-01-07"
|
|
updated_date: "2026-01-10"
|
|
---
|
|
```
|
|
|
|
#### _MAP.md (devops)
|
|
```yaml
|
|
---
|
|
id: "MAP-DEVOPS"
|
|
title: "Mapa DevOps"
|
|
type: "Index"
|
|
status: "Published"
|
|
priority: "P2"
|
|
version: "1.0.0"
|
|
created_date: "2026-01-10"
|
|
updated_date: "2026-01-10"
|
|
---
|
|
```
|
|
|
|
### 2.5 Grupo 5: docs/architecture/adr/ (6 archivos)
|
|
|
|
#### ADR-001 a ADR-005 (formato comun)
|
|
```yaml
|
|
---
|
|
id: "ADR-00X"
|
|
title: "[Titulo del ADR]"
|
|
type: "ADR"
|
|
status: "Accepted"
|
|
priority: "P0"
|
|
supersedes: "N/A"
|
|
superseded_by: "N/A"
|
|
version: "1.0.0"
|
|
created_date: "2026-01-07"
|
|
updated_date: "2026-01-10"
|
|
---
|
|
```
|
|
|
|
#### _INDEX.md (adr)
|
|
```yaml
|
|
---
|
|
id: "INDEX-ADR"
|
|
title: "Indice ADRs"
|
|
type: "Index"
|
|
status: "Published"
|
|
priority: "P2"
|
|
version: "1.0.0"
|
|
created_date: "2026-01-07"
|
|
updated_date: "2026-01-10"
|
|
---
|
|
```
|
|
|
|
### 2.6 Grupo 6: docs/ raiz (2 archivos)
|
|
|
|
#### docs/README.md
|
|
```yaml
|
|
---
|
|
id: "DOCS-ROOT"
|
|
title: "Documentacion Template SaaS"
|
|
type: "Overview"
|
|
status: "Published"
|
|
priority: "P0"
|
|
version: "1.0.0"
|
|
created_date: "2026-01-07"
|
|
updated_date: "2026-01-10"
|
|
---
|
|
```
|
|
|
|
#### docs/_MAP.md
|
|
```yaml
|
|
---
|
|
id: "MAP-DOCS"
|
|
title: "Mapa de Documentacion"
|
|
type: "Index"
|
|
status: "Published"
|
|
priority: "P1"
|
|
version: "1.0.0"
|
|
created_date: "2026-01-07"
|
|
updated_date: "2026-01-10"
|
|
---
|
|
```
|
|
|
|
---
|
|
|
|
## 3. ANALISIS G2: INTEGRACIONES - CONTENIDO FALTANTE
|
|
|
|
### 3.1 INT-001-stripe: Contenido a Agregar
|
|
|
|
#### Seccion Endpoints/SDK (17 endpoints)
|
|
|
|
```markdown
|
|
## Endpoints/SDK Utilizados
|
|
|
|
| Operacion | Endpoint/Metodo | Descripcion |
|
|
|-----------|-----------------|-------------|
|
|
| Crear cliente | `stripe.customers.create()` | Crea customer en Stripe |
|
|
| Obtener cliente | `stripe.customers.retrieve()` | Obtiene datos de customer |
|
|
| Actualizar cliente | `stripe.customers.update()` | Actualiza datos de customer |
|
|
| Crear suscripcion | `stripe.subscriptions.create()` | Inicia nueva suscripcion |
|
|
| Cancelar suscripcion | `stripe.subscriptions.cancel()` | Cancela suscripcion activa |
|
|
| Pausar suscripcion | `stripe.subscriptions.update()` | Pausa cobros |
|
|
| Reanudar suscripcion | `stripe.subscriptions.resume()` | Reanuda suscripcion pausada |
|
|
| Crear checkout | `stripe.checkout.sessions.create()` | Crea sesion de checkout |
|
|
| Crear portal | `stripe.billingPortal.sessions.create()` | Acceso a portal de billing |
|
|
| Crear precio | `stripe.prices.create()` | Crea nuevo precio |
|
|
| Listar precios | `stripe.prices.list()` | Lista precios disponibles |
|
|
| Crear invoice | `stripe.invoices.create()` | Crea factura manual |
|
|
| Obtener invoice | `stripe.invoices.retrieve()` | Obtiene factura |
|
|
| Pagar invoice | `stripe.invoices.pay()` | Marca invoice como pagada |
|
|
| Crear payment intent | `stripe.paymentIntents.create()` | Inicia intent de pago |
|
|
| Confirmar payment | `stripe.paymentIntents.confirm()` | Confirma pago |
|
|
| Webhook handler | `stripe.webhooks.constructEvent()` | Valida webhooks |
|
|
```
|
|
|
|
#### Seccion Fallbacks
|
|
|
|
```markdown
|
|
## Fallbacks
|
|
|
|
### Estrategia si Stripe no disponible
|
|
|
|
| Escenario | Estrategia | Accion |
|
|
|-----------|------------|--------|
|
|
| API timeout | Reintentar con backoff | 3 reintentos, 1s, 2s, 4s |
|
|
| Webhook perdido | Verificacion periodica | Cron cada 5 min verifica estado |
|
|
| Pago fallido | Dunning automatico | 3 reintentos en 7 dias |
|
|
| Suscripcion cancelada | Gracia | 7 dias de gracia antes de suspender |
|
|
|
|
### Circuit Breaker
|
|
|
|
- Umbral apertura: 5 fallos consecutivos
|
|
- Timeout semi-abierto: 30 segundos
|
|
- Fallback: Cola BullMQ para retry posterior
|
|
```
|
|
|
|
#### Seccion Credenciales
|
|
|
|
```markdown
|
|
## Credenciales Requeridas
|
|
|
|
| Variable de Entorno | Descripcion | Obligatorio | Scope |
|
|
|---------------------|-------------|-------------|-------|
|
|
| STRIPE_SECRET_KEY | API Key secreta | SI | Global |
|
|
| STRIPE_PUBLISHABLE_KEY | API Key publica | SI | Frontend |
|
|
| STRIPE_WEBHOOK_SECRET | Secret para webhooks | SI | Backend |
|
|
| STRIPE_TEST_SECRET_KEY | API Key test | NO | Dev/Staging |
|
|
```
|
|
|
|
### 3.2 INT-002-oauth: Contenido a Agregar
|
|
|
|
```markdown
|
|
## Fallbacks
|
|
|
|
### Estrategia OAuth Fallback
|
|
|
|
| Escenario | Estrategia |
|
|
|-----------|------------|
|
|
| Provider no disponible | Mostrar login local |
|
|
| Token expirado | Refresh automatico |
|
|
| Refresh falla | Redirigir a login |
|
|
| Nuevo usuario OAuth | Crear cuenta automatica |
|
|
|
|
### Degradacion Graceful
|
|
|
|
- Si Google OAuth falla: Ofrecer GitHub o Email
|
|
- Si todos OAuth fallan: Solo login local
|
|
- Timeout: 10 segundos max por provider
|
|
```
|
|
|
|
### 3.3 INT-004-push: Contenido a Agregar
|
|
|
|
```markdown
|
|
## Fallbacks
|
|
|
|
### Estrategia Push Fallback
|
|
|
|
| Escenario | Estrategia |
|
|
|-----------|------------|
|
|
| FCM no disponible | Encolar y reintentar |
|
|
| APNs rechazo | Marcar device como invalido |
|
|
| Token expirado | Solicitar nuevo token |
|
|
| Rate limit | Backoff exponencial |
|
|
|
|
### Fallback a otros canales
|
|
|
|
- Si push falla 3 veces: Enviar por email
|
|
- Si notificacion critica: SMS como ultimo recurso
|
|
```
|
|
|
|
### 3.4 INT-005-storage: Contenido a Agregar
|
|
|
|
```markdown
|
|
## Fallbacks
|
|
|
|
### Estrategia Storage Fallback
|
|
|
|
| Escenario | Estrategia |
|
|
|-----------|------------|
|
|
| S3 no disponible | Fallback a R2 |
|
|
| R2 no disponible | Fallback a MinIO local |
|
|
| Upload falla | Retry 3 veces |
|
|
| Download timeout | CDN cache |
|
|
|
|
### Multi-region
|
|
|
|
- Primary: us-east-1
|
|
- Failover: eu-west-1
|
|
- Replicacion: Asincrona cada 5 min
|
|
```
|
|
|
|
### 3.5 INT-006-webhooks: Contenido a Agregar
|
|
|
|
```markdown
|
|
## Dead Letter Queue (DLQ)
|
|
|
|
### Estrategia de Reintentos
|
|
|
|
| Intento | Delay | Accion si falla |
|
|
|---------|-------|-----------------|
|
|
| 1 | Inmediato | Encolar retry |
|
|
| 2 | 1 minuto | Encolar retry |
|
|
| 3 | 5 minutos | Encolar retry |
|
|
| 4 | 15 minutos | Encolar retry |
|
|
| 5 | 1 hora | Mover a DLQ |
|
|
|
|
### Procesamiento DLQ
|
|
|
|
- Revision manual requerida
|
|
- Alerta a Slack si DLQ > 10 items
|
|
- Expiracion: 7 dias
|
|
```
|
|
|
|
### 3.6 INT-007-redis: Contenido a Agregar
|
|
|
|
#### Seccion Comandos (18 comandos)
|
|
|
|
```markdown
|
|
## Endpoints/SDK Utilizados
|
|
|
|
| Operacion | Comando | Descripcion |
|
|
|-----------|---------|-------------|
|
|
| Set cache | `SET key value EX ttl` | Guardar con expiracion |
|
|
| Get cache | `GET key` | Obtener valor |
|
|
| Delete | `DEL key` | Eliminar clave |
|
|
| Exists | `EXISTS key` | Verificar existencia |
|
|
| TTL | `TTL key` | Tiempo restante |
|
|
| Increment | `INCR key` | Incrementar contador |
|
|
| Hash set | `HSET hash field value` | Guardar en hash |
|
|
| Hash get | `HGET hash field` | Obtener de hash |
|
|
| List push | `LPUSH list value` | Agregar a lista |
|
|
| List pop | `RPOP list` | Obtener de lista |
|
|
| Set add | `SADD set member` | Agregar a set |
|
|
| Set members | `SMEMBERS set` | Obtener miembros |
|
|
| Sorted add | `ZADD zset score member` | Agregar a sorted set |
|
|
| Sorted range | `ZRANGE zset start stop` | Rango de sorted set |
|
|
| Publish | `PUBLISH channel message` | Publicar mensaje |
|
|
| Subscribe | `SUBSCRIBE channel` | Suscribirse |
|
|
| Expire | `EXPIRE key seconds` | Establecer TTL |
|
|
| Scan | `SCAN cursor MATCH pattern` | Buscar claves |
|
|
```
|
|
|
|
#### Seccion Fallbacks
|
|
|
|
```markdown
|
|
## Fallbacks
|
|
|
|
### Estrategia Redis Fallback
|
|
|
|
| Escenario | Estrategia |
|
|
|-----------|------------|
|
|
| Redis no disponible | Memory cache temporal |
|
|
| Conexion perdida | Reconexion automatica |
|
|
| Cluster failover | Sentinel automatico |
|
|
| Memory llena | Eviction LRU |
|
|
|
|
### Configuracion Sentinel
|
|
|
|
- 3 nodos Sentinel minimo
|
|
- Quorum: 2
|
|
- Failover timeout: 30s
|
|
```
|
|
|
|
---
|
|
|
|
## 4. ANALISIS G3: ESPECIFICACIONES TECNICAS (13 archivos)
|
|
|
|
### 4.1 Estructura Base ET-SAAS-*
|
|
|
|
```markdown
|
|
# ET-SAAS-XXX: [Nombre Modulo]
|
|
|
|
## Metadata
|
|
|
|
| Campo | Valor |
|
|
|-------|-------|
|
|
| Codigo | ET-SAAS-XXX |
|
|
| Modulo | SAAS-XXX |
|
|
| Version | 1.0.0 |
|
|
| Estado | Draft |
|
|
| Fecha | 2026-01-10 |
|
|
|
|
---
|
|
|
|
## 1. Descripcion
|
|
|
|
[Descripcion tecnica detallada del modulo]
|
|
|
|
## 2. Arquitectura
|
|
|
|
### 2.1 Diagrama de Componentes
|
|
[Diagrama ASCII o referencia a imagen]
|
|
|
|
### 2.2 Flujo de Datos
|
|
[Descripcion del flujo]
|
|
|
|
## 3. Modelo de Datos
|
|
|
|
### 3.1 Tablas
|
|
[Lista de tablas con campos]
|
|
|
|
### 3.2 Relaciones
|
|
[Diagrama ER simplificado]
|
|
|
|
## 4. API Endpoints
|
|
|
|
| Metodo | Ruta | Descripcion |
|
|
|--------|------|-------------|
|
|
| GET | /api/... | ... |
|
|
|
|
## 5. Implementacion
|
|
|
|
### 5.1 Backend
|
|
[Clases y servicios principales]
|
|
|
|
### 5.2 Frontend
|
|
[Componentes y hooks]
|
|
|
|
## 6. Seguridad
|
|
|
|
### 6.1 Autenticacion
|
|
[Requisitos]
|
|
|
|
### 6.2 Autorizacion
|
|
[RBAC aplicable]
|
|
|
|
## 7. Testing
|
|
|
|
### 7.1 Unitarios
|
|
[Escenarios]
|
|
|
|
### 7.2 Integracion
|
|
[Escenarios]
|
|
|
|
## 8. Referencias
|
|
|
|
- [SAAS-XXX](../01-modulos/SAAS-XXX-*.md)
|
|
- [ADR relacionado](../architecture/adr/ADR-*.md)
|
|
|
|
---
|
|
|
|
**Creado:** 2026-01-10
|
|
**Autor:** Claude Code
|
|
```
|
|
|
|
### 4.2 ET por Crear (13 archivos)
|
|
|
|
| Archivo | Modulo Base | Tablas | Endpoints |
|
|
|---------|-------------|--------|-----------|
|
|
| ET-SAAS-001-authentication.md | SAAS-001 | auth.* | /auth/* |
|
|
| ET-SAAS-002-multi-tenancy.md | SAAS-002 | tenants.* | /tenants/* |
|
|
| ET-SAAS-003-users-rbac.md | SAAS-003 | users.*, rbac.* | /users/*, /roles/* |
|
|
| ET-SAAS-004-billing.md | SAAS-004 | billing.* | /billing/* |
|
|
| ET-SAAS-005-plans.md | SAAS-005 | plans.* | /plans/* |
|
|
| ET-SAAS-006-ai-integration.md | SAAS-006 | ai.* | /ai/* |
|
|
| ET-SAAS-008-audit-logs.md | SAAS-008 | audit.* | /audit/* |
|
|
| ET-SAAS-009-feature-flags.md | SAAS-009 | feature_flags.* | /feature-flags/* |
|
|
| ET-SAAS-010-webhooks.md | SAAS-010 | webhooks.* | /webhooks/* |
|
|
| ET-SAAS-011-storage.md | SAAS-011 | storage.* | /storage/* |
|
|
| ET-SAAS-012-crud-base.md | SAAS-012 | N/A (patron) | N/A |
|
|
| ET-SAAS-013-email.md | SAAS-013 | notifications.* | /email/* |
|
|
| ET-SAAS-014-whatsapp.md | SAAS-014 | whatsapp.* | /whatsapp/* |
|
|
|
|
---
|
|
|
|
## 5. ANALISIS G4: ADRs NUEVOS (6 archivos)
|
|
|
|
### 5.1 ADR-006: AI Integration Multi-Provider
|
|
|
|
```markdown
|
|
# ADR-006: AI Integration Multi-Provider
|
|
|
|
## Metadata
|
|
|
|
| Campo | Valor |
|
|
|-------|-------|
|
|
| ID | ADR-006 |
|
|
| Estado | Accepted |
|
|
| Fecha | 2026-01-10 |
|
|
| Supersedes | N/A |
|
|
|
|
## Contexto
|
|
|
|
El sistema requiere integracion con multiples proveedores de IA (Claude, GPT-4, Gemini)
|
|
para ofrecer flexibilidad y evitar vendor lock-in.
|
|
|
|
## Decision
|
|
|
|
Implementar OpenRouter como gateway unificado para acceso multi-proveedor, con fallback
|
|
a APIs directas cuando sea necesario.
|
|
|
|
## Alternativas Consideradas
|
|
|
|
| Alternativa | Pros | Contras |
|
|
|-------------|------|---------|
|
|
| APIs directas | Sin intermediario | Mayor complejidad de codigo |
|
|
| OpenRouter | Unificado, fallback automatico | Dependencia externa, costo adicional |
|
|
| LangChain | Abstraccion completa | Overhead, curva aprendizaje |
|
|
|
|
## Consecuencias
|
|
|
|
### Positivas
|
|
- Cambio de provider sin modificar codigo
|
|
- Fallback automatico entre providers
|
|
- Billing unificado
|
|
|
|
### Negativas
|
|
- Latencia adicional (~50ms)
|
|
- Costo de gateway (2-5%)
|
|
- Dependencia de OpenRouter
|
|
|
|
---
|
|
|
|
**Fecha decision:** 2026-01-10
|
|
**Autores:** Claude Code (Arquitectura)
|
|
```
|
|
|
|
### 5.2 ADR-007: Storage Abstraction Layer
|
|
|
|
```markdown
|
|
# ADR-007: Storage Abstraction Layer
|
|
|
|
## Metadata
|
|
|
|
| Campo | Valor |
|
|
|-------|-------|
|
|
| ID | ADR-007 |
|
|
| Estado | Accepted |
|
|
| Fecha | 2026-01-10 |
|
|
| Supersedes | N/A |
|
|
|
|
## Contexto
|
|
|
|
Se necesita soporte para multiples providers de storage (S3, R2, MinIO) con posibilidad
|
|
de cambiar entre ellos segun costos o disponibilidad.
|
|
|
|
## Decision
|
|
|
|
Usar AWS SDK v3 con abstraccion S3-compatible, permitiendo conectar cualquier provider
|
|
que implemente el protocolo S3.
|
|
|
|
## Alternativas Consideradas
|
|
|
|
| Alternativa | Pros | Contras |
|
|
|-------------|------|---------|
|
|
| AWS SDK solo | Nativo, bien documentado | Vendor lock-in |
|
|
| Abstraccion propia | Control total | Mantenimiento |
|
|
| MinIO Client | Multi-provider | Menos features que SDK |
|
|
|
|
## Consecuencias
|
|
|
|
### Positivas
|
|
- Cualquier storage S3-compatible funciona
|
|
- Migracion sin cambios de codigo
|
|
- Features avanzados de S3
|
|
|
|
### Negativas
|
|
- Limitado a protocolo S3
|
|
- No aprovecha features especificos de cada provider
|
|
|
|
---
|
|
|
|
**Fecha decision:** 2026-01-10
|
|
**Autores:** Claude Code (Arquitectura)
|
|
```
|
|
|
|
### 5.3 ADR-008: Webhook Retry Strategy
|
|
|
|
```markdown
|
|
# ADR-008: Webhook Retry Strategy
|
|
|
|
## Metadata
|
|
|
|
| Campo | Valor |
|
|
|-------|-------|
|
|
| ID | ADR-008 |
|
|
| Estado | Accepted |
|
|
| Fecha | 2026-01-10 |
|
|
| Supersedes | N/A |
|
|
|
|
## Contexto
|
|
|
|
Los webhooks outbound pueden fallar por multiples razones y se necesita una estrategia
|
|
robusta de reintentos.
|
|
|
|
## Decision
|
|
|
|
Implementar BullMQ con exponential backoff y Dead Letter Queue para webhooks fallidos.
|
|
|
|
## Alternativas Consideradas
|
|
|
|
| Alternativa | Pros | Contras |
|
|
|-------------|------|---------|
|
|
| Retry inmediato | Simple | Puede empeorar situacion |
|
|
| Backoff lineal | Predecible | No optimo para recuperacion |
|
|
| Backoff exponencial | Optimo para recuperacion | Delay maximo largo |
|
|
|
|
## Consecuencias
|
|
|
|
### Positivas
|
|
- Alta tasa de entrega eventual (>99.9%)
|
|
- No sobrecarga destinos problematicos
|
|
- Auditoria completa de fallos
|
|
|
|
### Negativas
|
|
- Delay maximo de entrega: 1 hora
|
|
- Complejidad de DLQ
|
|
|
|
---
|
|
|
|
**Fecha decision:** 2026-01-10
|
|
**Autores:** Claude Code (Arquitectura)
|
|
```
|
|
|
|
### 5.4 ADR-009: WhatsApp Business Integration
|
|
|
|
```markdown
|
|
# ADR-009: WhatsApp Business Integration
|
|
|
|
## Metadata
|
|
|
|
| Campo | Valor |
|
|
|-------|-------|
|
|
| ID | ADR-009 |
|
|
| Estado | Accepted |
|
|
| Fecha | 2026-01-10 |
|
|
| Supersedes | N/A |
|
|
|
|
## Contexto
|
|
|
|
Se requiere integracion con WhatsApp Business API para notificaciones y soporte.
|
|
|
|
## Decision
|
|
|
|
Usar Meta Cloud API directamente en lugar de providers intermediarios (Twilio, etc).
|
|
|
|
## Alternativas Consideradas
|
|
|
|
| Alternativa | Pros | Contras |
|
|
|-------------|------|---------|
|
|
| Meta Cloud API | Sin intermediario, menor costo | Mas complejo |
|
|
| Twilio | Facil integracion | Costo 3x |
|
|
| MessageBird | Multi-canal | Costo 2x |
|
|
|
|
## Consecuencias
|
|
|
|
### Positivas
|
|
- Costo optimizado (~40% ahorro)
|
|
- Acceso a features nuevos primero
|
|
- Sin dependencia de terceros
|
|
|
|
### Negativas
|
|
- Setup inicial mas complejo
|
|
- Manejo directo de webhooks Meta
|
|
|
|
---
|
|
|
|
**Fecha decision:** 2026-01-10
|
|
**Autores:** Claude Code (Arquitectura)
|
|
```
|
|
|
|
### 5.5 ADR-010: Audit Log Retention Policy
|
|
|
|
```markdown
|
|
# ADR-010: Audit Log Retention Policy
|
|
|
|
## Metadata
|
|
|
|
| Campo | Valor |
|
|
|-------|-------|
|
|
| ID | ADR-010 |
|
|
| Estado | Accepted |
|
|
| Fecha | 2026-01-10 |
|
|
| Supersedes | N/A |
|
|
|
|
## Contexto
|
|
|
|
Los audit logs crecen indefinidamente y se necesita definir politica de retencion.
|
|
|
|
## Decision
|
|
|
|
Implementar retencion por niveles: Hot (30 dias), Warm (1 anio), Cold (7 anios).
|
|
|
|
## Alternativas Consideradas
|
|
|
|
| Alternativa | Pros | Contras |
|
|
|-------------|------|---------|
|
|
| Todo en DB | Consulta facil | Costo alto |
|
|
| Solo archivos | Bajo costo | Consulta dificil |
|
|
| Tiered (elegido) | Balance optimo | Complejidad |
|
|
|
|
## Consecuencias
|
|
|
|
### Positivas
|
|
- Costo optimizado
|
|
- Cumplimiento regulatorio
|
|
- Consultas rapidas para logs recientes
|
|
|
|
### Negativas
|
|
- Queries a logs antiguos mas lentas
|
|
- Proceso de archivado automatico necesario
|
|
|
|
---
|
|
|
|
**Fecha decision:** 2026-01-10
|
|
**Autores:** Claude Code (Arquitectura)
|
|
```
|
|
|
|
### 5.6 ADR-011: Rate Limiting Strategy
|
|
|
|
```markdown
|
|
# ADR-011: Rate Limiting Strategy
|
|
|
|
## Metadata
|
|
|
|
| Campo | Valor |
|
|
|-------|-------|
|
|
| ID | ADR-011 |
|
|
| Estado | Accepted |
|
|
| Fecha | 2026-01-10 |
|
|
| Supersedes | N/A |
|
|
|
|
## Contexto
|
|
|
|
Se necesita rate limiting para proteger la API de abuso y garantizar fair use.
|
|
|
|
## Decision
|
|
|
|
Implementar Token Bucket con Redis, con limites por tenant/plan.
|
|
|
|
## Alternativas Consideradas
|
|
|
|
| Alternativa | Pros | Contras |
|
|
|-------------|------|---------|
|
|
| Fixed window | Simple | Burst al inicio de ventana |
|
|
| Sliding window | Sin burst | Mas memoria |
|
|
| Token bucket | Permite burst controlado | Ligeramente mas complejo |
|
|
|
|
## Consecuencias
|
|
|
|
### Positivas
|
|
- Burst legitimo permitido
|
|
- Limites justos por plan
|
|
- Distribuido via Redis
|
|
|
|
### Negativas
|
|
- Dependencia de Redis
|
|
- Configuracion por endpoint
|
|
|
|
---
|
|
|
|
**Fecha decision:** 2026-01-10
|
|
**Autores:** Claude Code (Arquitectura)
|
|
```
|
|
|
|
---
|
|
|
|
## 6. RESUMEN DE ARCHIVOS A MODIFICAR/CREAR
|
|
|
|
### 6.1 Modificar (26 + 7 = 33 archivos)
|
|
|
|
| Categoria | Archivos | Accion |
|
|
|-----------|----------|--------|
|
|
| Frontmatter | 26 | Agregar YAML al inicio |
|
|
| Integraciones | 7 | Agregar secciones faltantes |
|
|
|
|
### 6.2 Crear (13 + 6 = 19 archivos)
|
|
|
|
| Categoria | Archivos | Ubicacion |
|
|
|-----------|----------|-----------|
|
|
| ET Specs | 13 | docs/02-especificaciones/ |
|
|
| ADRs | 6 | docs/architecture/adr/ |
|
|
|
|
### 6.3 Total de Cambios
|
|
|
|
| Tipo | Cantidad |
|
|
|------|----------|
|
|
| Archivos a modificar | 33 |
|
|
| Archivos a crear | 19 |
|
|
| **TOTAL** | **52** |
|
|
|
|
---
|
|
|
|
## 7. DEPENDENCIAS IDENTIFICADAS
|
|
|
|
### 7.1 Orden de Ejecucion
|
|
|
|
```
|
|
WAVE 1 (Sin dependencias):
|
|
├── G1: Frontmatter (26 archivos)
|
|
└── G2: Contenido INT (7 archivos)
|
|
|
|
WAVE 2 (Requiere Wave 1):
|
|
├── G3: ET Specs (13 archivos) - referencias a INT
|
|
└── G4: ADRs (6 archivos) - referencias a modulos
|
|
```
|
|
|
|
### 7.2 Referencias Cruzadas
|
|
|
|
| Documento Nuevo | Referencia a |
|
|
|-----------------|--------------|
|
|
| ET-SAAS-001 | INT-002 (OAuth), ADR-002 |
|
|
| ET-SAAS-004 | INT-001 (Stripe), ADR-003 |
|
|
| ET-SAAS-006 | ADR-006 (AI Integration) |
|
|
| ADR-006 | SAAS-006, INT (potencial) |
|
|
| ADR-007 | INT-005, SAAS-011 |
|
|
|
|
---
|
|
|
|
## 8. CONCLUSION
|
|
|
|
El analisis detallado ha generado contenido especifico para:
|
|
- 26 bloques de frontmatter YAML
|
|
- 7 secciones de contenido para integraciones
|
|
- 13 estructuras de especificaciones tecnicas
|
|
- 6 ADRs completos
|
|
|
|
La FASE 3 creara el plan de ejecucion para implementar estos cambios en el orden optimo.
|
|
|
|
---
|
|
|
|
**Creado:** 2026-01-10
|
|
**Autor:** Claude Code (ORQUESTADOR)
|
|
**Sistema:** SIMCO v3.7
|
|
**Siguiente Fase:** FASE 3 - Plan de Ejecucion Documentacion
|