Some checks failed
ERP Core CI / Backend Lint (push) Has been cancelled
ERP Core CI / Backend Unit Tests (push) Has been cancelled
ERP Core CI / Backend Integration Tests (push) Has been cancelled
ERP Core CI / Frontend Lint (push) Has been cancelled
ERP Core CI / Frontend Unit Tests (push) Has been cancelled
ERP Core CI / Frontend E2E Tests (push) Has been cancelled
ERP Core CI / Database DDL Validation (push) Has been cancelled
ERP Core CI / Backend Build (push) Has been cancelled
ERP Core CI / Frontend Build (push) Has been cancelled
ERP Core CI / CI Success (push) Has been cancelled
Performance Tests / Lighthouse CI (push) Has been cancelled
Performance Tests / Bundle Size Analysis (push) Has been cancelled
Performance Tests / k6 Load Tests (push) Has been cancelled
Performance Tests / Performance Summary (push) Has been cancelled
- HERENCIA-SIMCO.md actualizado con directivas v3.7 y v3.8 - Actualizaciones en modulos CRM y OpenAPI Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
819 lines
27 KiB
Markdown
819 lines
27 KiB
Markdown
# FASE 1: ANALISIS Y PLANEACION INICIAL
|
|
# Integracion de Alcances SaaS e IA en ERP Core
|
|
|
|
**Version:** 1.0.0
|
|
**Fecha:** 2026-01-10
|
|
**Estado:** EN PROGRESO
|
|
**Agente Orquestador:** Architecture-Analyst + Documentation-Agent + Requirements-Analyst
|
|
|
|
---
|
|
|
|
## RESUMEN EJECUTIVO
|
|
|
|
Este documento consolida el analisis inicial para la integracion de nuevos alcances de **Plataforma SaaS** e **Inteligencia Artificial** en el proyecto ERP Core. Se basa en:
|
|
|
|
1. **Proyecto base:** `erp-core` - Base generica reutilizable para ERPs verticales
|
|
2. **Fuente SaaS:** `template-saas` - Plataforma SaaS multi-tenant completa
|
|
3. **Fuente IA:** `michangarrito` - Implementaciones de IA para retail
|
|
|
|
**Objetivo:** Actualizar la documentacion de vision-general de erp-core para incluir alcances SaaS e IA como parte integral del core.
|
|
|
|
---
|
|
|
|
## 1. ESTADO ACTUAL DE ERP-CORE
|
|
|
|
### 1.1 Estadisticas del Proyecto
|
|
|
|
| Metrica | Valor |
|
|
|---------|-------|
|
|
| Archivos documentacion | 756 |
|
|
| Modulos core definidos | 19 (MGN-001 a MGN-019) |
|
|
| Progreso general | 60% |
|
|
| Cobertura Odoo 18 | 78% |
|
|
| Archivos DDL | 14 (~13,200 lineas) |
|
|
| Tests pasando | 700+ |
|
|
|
|
### 1.2 Archivo Actual: VISION-ERP-CORE.md
|
|
|
|
**Ubicacion:** `/docs/00-vision-general/VISION-ERP-CORE.md`
|
|
**Tamano:** 218 lineas
|
|
**Ultima actualizacion:** Diciembre 2025
|
|
|
|
**Contenido actual:**
|
|
- Resumen ejecutivo (ERP Core = 60-70% codigo compartido)
|
|
- Proposito y problema que resuelve
|
|
- Objetivos corto/mediano/largo plazo
|
|
- Arquitectura de capas (Frontend, API, Backend, Database)
|
|
- Modelo de extension (Core + Verticales)
|
|
- Modulos Core (MGN-001 a MGN-015)
|
|
- Stack tecnologico (Node.js, React, PostgreSQL)
|
|
- Principios de diseno (5 principios)
|
|
- Entregables por fase (3 fases)
|
|
- Metricas de exito
|
|
|
|
### 1.3 Deficiencias Identificadas en vision-general/
|
|
|
|
| Deficiencia | Descripcion | Impacto |
|
|
|-------------|-------------|---------|
|
|
| **Sin alcance SaaS** | No documenta capacidades multi-tenant avanzadas, billing, subscripciones | Alto |
|
|
| **Sin alcance IA** | No documenta integraciones de IA, chatbots, predicciones | Alto |
|
|
| **Modulos incompletos** | Solo llega hasta MGN-015, faltan MGN-016 a MGN-022+ | Medio |
|
|
| **Sin integraciones externas** | No documenta Stripe, OpenRouter, SendGrid, WhatsApp | Medio |
|
|
| **Arquitectura simplificada** | Falta detalle de capas SaaS y servicios IA | Medio |
|
|
| **Sin frontmatter SIMCO** | Archivo no sigue formato con metadatos YAML | Bajo |
|
|
|
|
### 1.4 Modulos Actuales vs Requeridos
|
|
|
|
**Modulos actuales (15):**
|
|
```
|
|
P0: MGN-001(auth), MGN-002(users), MGN-003(roles), MGN-004(tenants)
|
|
P1: MGN-005(catalogs), MGN-006(settings), MGN-010(financial),
|
|
MGN-011(inventory), MGN-012(purchasing), MGN-013(sales)
|
|
P2: MGN-007(audit), MGN-008(notifications), MGN-009(reports),
|
|
MGN-014(crm), MGN-015(projects)
|
|
```
|
|
|
|
**Modulos nuevos requeridos (7+):**
|
|
```
|
|
P3-SaaS: MGN-016(billing), MGN-017(plans), MGN-018(webhooks), MGN-019(feature-flags)
|
|
P3-IA: MGN-020(ai-integration), MGN-021(whatsapp-business), MGN-022(mcp-server)
|
|
```
|
|
|
|
---
|
|
|
|
## 2. CARACTERISTICAS SAAS A INTEGRAR (desde template-saas)
|
|
|
|
### 2.1 Resumen de template-saas
|
|
|
|
| Metrica | Valor |
|
|
|---------|-------|
|
|
| Modulos SaaS | 14 (SAAS-001 a SAAS-014) |
|
|
| Integraciones externas | 7 |
|
|
| Schemas de BD | 12 |
|
|
| Tablas | 24+ |
|
|
| Tests unitarios | 798 |
|
|
| Tests E2E | 47 |
|
|
| Cobertura | 76.37% |
|
|
| Estado | Release Candidate (100% completado) |
|
|
|
|
### 2.2 Modulos SaaS para ERP Core
|
|
|
|
#### 2.2.1 Autenticacion Avanzada (SAAS-001)
|
|
```yaml
|
|
id: SAAS-001
|
|
nombre: Autenticacion
|
|
estado: Completado
|
|
caracteristicas:
|
|
- Login/Registro con email/password
|
|
- JWT con refresh tokens (15min access, 7 dias refresh)
|
|
- MFA preparado (TOTP/Google Authenticator)
|
|
- OAuth 2.0 preparado (Google, Microsoft, GitHub)
|
|
- Session management con revocacion
|
|
- Password reset flow
|
|
- Email verification
|
|
tablas:
|
|
- auth.sessions
|
|
- auth.tokens
|
|
- auth.oauth_connections
|
|
endpoints: 9
|
|
```
|
|
|
|
#### 2.2.2 Multi-Tenancy Avanzado (SAAS-002)
|
|
```yaml
|
|
id: SAAS-002
|
|
nombre: Multi-Tenancy
|
|
estado: Completado
|
|
caracteristicas:
|
|
- Row-Level Security (RLS) en todas las tablas
|
|
- Creacion automatica de tenant al registrar owner
|
|
- Contexto automatico via middleware
|
|
- Configuracion por tenant (JSONB flexible)
|
|
- Slug unico por tenant
|
|
- Subdominios/custom domains listos
|
|
tablas:
|
|
- tenants.tenants
|
|
- tenants.tenant_settings
|
|
```
|
|
|
|
#### 2.2.3 Billing y Suscripciones (SAAS-004)
|
|
```yaml
|
|
id: SAAS-004
|
|
nombre: Billing
|
|
estado: Completado
|
|
proveedor: Stripe
|
|
caracteristicas:
|
|
- Suscripciones recurrentes (mensual/anual)
|
|
- Trial gratuito (14 dias configurable)
|
|
- Upgrade/downgrade con prorateo automatico
|
|
- Facturas y recibos
|
|
- Webhooks Stripe sincronizados
|
|
- Portal de cliente Stripe integrado
|
|
tablas:
|
|
- billing.subscriptions
|
|
- billing.invoices
|
|
- billing.payment_methods
|
|
- billing.payments
|
|
estados_suscripcion:
|
|
- trialing -> active -> past_due -> cancelled
|
|
```
|
|
|
|
#### 2.2.4 Planes y Limites (SAAS-005)
|
|
```yaml
|
|
id: SAAS-005
|
|
nombre: Plans
|
|
estado: Completado
|
|
planes_definidos:
|
|
- Free: $0/mes, 1 usuario, 100MB
|
|
- Starter: $29/mes, 5 usuarios, 1GB, API
|
|
- Pro: $79/mes, 20 usuarios, 10GB, AI, webhooks
|
|
- Enterprise: $199/mes, unlimited, custom branding
|
|
caracteristicas:
|
|
- Features booleanas por plan
|
|
- Limites numericos por plan (-1 = unlimited)
|
|
- Verificacion en runtime
|
|
- Feature gating basado en plan
|
|
tablas:
|
|
- plans.plans
|
|
- plans.plan_features
|
|
```
|
|
|
|
#### 2.2.5 Notificaciones Multicanal (SAAS-007)
|
|
```yaml
|
|
id: SAAS-007
|
|
nombre: Notifications
|
|
estado: Completado
|
|
canales:
|
|
- Email (SendGrid, SES, SMTP)
|
|
- Push Web (Web Push API con VAPID)
|
|
- In-App (WebSocket real-time)
|
|
- WhatsApp Business
|
|
caracteristicas:
|
|
- Templates de email personalizables (MJML)
|
|
- Cola asincrona (BullMQ + Redis)
|
|
- Reintentos automaticos
|
|
- Preferencias por usuario
|
|
tablas:
|
|
- notifications.notification_templates
|
|
- notifications.notifications
|
|
- notifications.user_notification_preferences
|
|
- notifications.user_devices
|
|
- notifications.notification_queue
|
|
- notifications.notification_logs
|
|
```
|
|
|
|
#### 2.2.6 Feature Flags (SAAS-009)
|
|
```yaml
|
|
id: SAAS-009
|
|
nombre: Feature Flags
|
|
estado: Completado
|
|
caracteristicas:
|
|
- Flags por tenant
|
|
- Flags por usuario
|
|
- Rollout gradual
|
|
- A/B testing
|
|
- Evaluaciones por contexto
|
|
tablas:
|
|
- feature_flags.flags
|
|
- feature_flags.tenant_flags
|
|
- feature_flags.user_flags
|
|
- feature_flags.evaluations
|
|
```
|
|
|
|
#### 2.2.7 Webhooks Outbound (SAAS-010)
|
|
```yaml
|
|
id: SAAS-010
|
|
nombre: Webhooks
|
|
estado: Completado
|
|
caracteristicas:
|
|
- Configuracion de webhooks por tenant
|
|
- 13 eventos disparables
|
|
- Firma HMAC de payloads
|
|
- Reintentos exponenciales (6 intentos)
|
|
- Logs de entregas detallados
|
|
eventos_disponibles:
|
|
- user.created/updated/deleted
|
|
- subscription.created/updated/cancelled
|
|
- invoice.paid/failed
|
|
- file.uploaded/deleted
|
|
- tenant.updated
|
|
tablas:
|
|
- webhooks.webhooks
|
|
- webhooks.deliveries
|
|
```
|
|
|
|
#### 2.2.8 Almacenamiento (SAAS-011)
|
|
```yaml
|
|
id: SAAS-011
|
|
nombre: Storage
|
|
estado: Completado
|
|
proveedores:
|
|
- AWS S3
|
|
- Cloudflare R2
|
|
- MinIO (self-hosted)
|
|
caracteristicas:
|
|
- Limites por tenant
|
|
- CDN integration
|
|
- Gestion de uploads pendientes
|
|
tablas:
|
|
- storage.files
|
|
- storage.pending_uploads
|
|
- storage.usage
|
|
```
|
|
|
|
#### 2.2.9 WhatsApp Business (SAAS-014)
|
|
```yaml
|
|
id: SAAS-014
|
|
nombre: WhatsApp Business
|
|
estado: Completado
|
|
proveedor: Meta Cloud API
|
|
caracteristicas:
|
|
- Envio de mensajes de texto
|
|
- Templates pre-aprobados
|
|
- Tracking de estado de entrega
|
|
- Rate limiting por tenant
|
|
- Webhook para status updates
|
|
- Configuracion por tenant
|
|
tablas:
|
|
- whatsapp.whatsapp_configs
|
|
- whatsapp.whatsapp_messages
|
|
```
|
|
|
|
### 2.3 Integraciones Externas SaaS
|
|
|
|
| Integracion | Proveedor | Estado | Descripcion |
|
|
|-------------|-----------|--------|-------------|
|
|
| Billing | Stripe | Completado | Suscripciones, facturas, pagos |
|
|
| Email | SendGrid/SES/SMTP | Completado | Email transaccional |
|
|
| Push | Web Push API | Completado | Notificaciones push |
|
|
| Storage | S3/R2/MinIO | Completado | Almacenamiento de archivos |
|
|
| Cache/Queue | Redis/BullMQ | Completado | Cache y colas asincronas |
|
|
| WhatsApp | Meta Cloud API | Completado | Mensajeria WhatsApp |
|
|
| OAuth | Google/Microsoft/GitHub | DDL listo | Autenticacion social |
|
|
|
|
### 2.4 Arquitectura SaaS
|
|
|
|
```
|
|
+------------------------------------------------------------------+
|
|
| ARQUITECTURA SAAS |
|
|
+------------------------------------------------------------------+
|
|
| |
|
|
| FRONTEND (React 18 + Vite) |
|
|
| +------------------+ +------------------+ +------------------+ |
|
|
| | Portal Usuario | | Portal Admin | | Portal SuperAdmin| |
|
|
| | - Dashboard | | - Usuarios | | - Tenants | |
|
|
| | - Perfil | | - Billing | | - Metricas | |
|
|
| | - Funciones | | - Settings | | - Config Global | |
|
|
| +------------------+ +------------------+ +------------------+ |
|
|
| |
|
|
+------------------------------------------------------------------+
|
|
| API Gateway (NestJS/Express) |
|
|
| +------------------------------------------------------------+ |
|
|
| | Middleware: Auth | Tenant Context | Rate Limiting | CORS | |
|
|
| +------------------------------------------------------------+ |
|
|
| |
|
|
+------------------------------------------------------------------+
|
|
| SERVICIOS BACKEND (Modulos) |
|
|
| +----------+ +----------+ +----------+ +----------+ +----------+ |
|
|
| | Auth | | Users | | Billing | | Plans | | Webhooks | |
|
|
| +----------+ +----------+ +----------+ +----------+ +----------+ |
|
|
| +----------+ +----------+ +----------+ +----------+ +----------+ |
|
|
| | Notif | | Storage | | Audit | | FFlags | | WhatsApp | |
|
|
| +----------+ +----------+ +----------+ +----------+ +----------+ |
|
|
| |
|
|
+------------------------------------------------------------------+
|
|
| BASE DE DATOS (PostgreSQL 16+ con RLS) |
|
|
| +------------------------------------------------------------+ |
|
|
| | Schemas: auth | users | tenants | billing | plans | audit | |
|
|
| | notifications | feature_flags | storage | webhooks| |
|
|
| | RLS: Aislamiento automatico por tenant_id | |
|
|
| +------------------------------------------------------------+ |
|
|
| |
|
|
+------------------------------------------------------------------+
|
|
| SERVICIOS EXTERNOS |
|
|
| +----------+ +----------+ +----------+ +----------+ +----------+ |
|
|
| | Stripe | | SendGrid | | S3/R2 | | Redis | | WhatsApp | |
|
|
| +----------+ +----------+ +----------+ +----------+ +----------+ |
|
|
+------------------------------------------------------------------+
|
|
```
|
|
|
|
---
|
|
|
|
## 3. CAPACIDADES IA A INTEGRAR (desde michangarrito)
|
|
|
|
### 3.1 Resumen de michangarrito
|
|
|
|
| Metrica | Valor |
|
|
|---------|-------|
|
|
| Archivos TS/TSX | 271 |
|
|
| Aplicaciones | 6 |
|
|
| Modulos backend | 17 |
|
|
| Schemas BD | 12 |
|
|
| Estado | En desarrollo activo |
|
|
|
|
### 3.2 Arquitectura IA
|
|
|
|
```
|
|
+------------------------------------------------------------------+
|
|
| ARQUITECTURA IA ERP |
|
|
+------------------------------------------------------------------+
|
|
| |
|
|
| CLIENTES |
|
|
| +----------+ +----------+ +----------+ +----------+ |
|
|
| | Web App | |Mobile App| | WhatsApp | | API Rest | |
|
|
| +----------+ +----------+ +----------+ +----------+ |
|
|
| | | | | |
|
|
+------------------------------------------------------------------+
|
|
| CAPA DE ORQUESTACION IA |
|
|
| +----------------------------------------------------------+ |
|
|
| | MCP SERVER | |
|
|
| | (Model Context Protocol - Anthropic) | |
|
|
| | +-------+ +-------+ +-------+ +-------+ +-------+ | |
|
|
| | |Products|Inventory| Orders | Fiados |Customers| | |
|
|
| | | Tools | Tools | Tools | Tools | Tools | | |
|
|
| | +-------+ +-------+ +-------+ +-------+ +-------+ | |
|
|
| +----------------------------------------------------------+ |
|
|
| | |
|
|
+------------------------------------------------------------------+
|
|
| GATEWAY LLM (OpenRouter) |
|
|
| +----------------------------------------------------------+ |
|
|
| | Proveedores: Claude | GPT-4 | Gemini | Mistral | Llama | |
|
|
| | Fallback automatico | Rate limiting | Token tracking | |
|
|
| +----------------------------------------------------------+ |
|
|
| | |
|
|
+------------------------------------------------------------------+
|
|
| SERVICIOS IA |
|
|
| +---------------+ +---------------+ +---------------+ |
|
|
| | WhatsApp Svc | | LLM Service | | Prediction | |
|
|
| | - Webhooks | | - Chat | | - Demanda | |
|
|
| | - Messages | | - Transcribe | | - Inventario | |
|
|
| | - Templates | | - Context | | - Reorden | |
|
|
| +---------------+ +---------------+ +---------------+ |
|
|
| |
|
|
+------------------------------------------------------------------+
|
|
| BASE DE DATOS IA |
|
|
| +----------------------------------------------------------+ |
|
|
| | Schemas: messaging | ai | subscriptions (token_usage) | |
|
|
| | Tablas: conversations | messages | configs | usage | |
|
|
| +----------------------------------------------------------+ |
|
|
+------------------------------------------------------------------+
|
|
```
|
|
|
|
### 3.3 Modulos IA para ERP Core
|
|
|
|
#### 3.3.1 MCP Server (Model Context Protocol)
|
|
```yaml
|
|
id: AI-001
|
|
nombre: MCP Server
|
|
estado: Completado
|
|
tecnologia: TypeScript + SDK Anthropic
|
|
puerto: 3142
|
|
proposito: Gateway agnostico que expone herramientas del negocio al LLM
|
|
herramientas_implementadas:
|
|
productos:
|
|
- list_products
|
|
- get_product_details
|
|
- check_product_availability
|
|
inventario:
|
|
- check_stock
|
|
- get_low_stock_products
|
|
- record_inventory_movement
|
|
- get_inventory_value
|
|
ventas:
|
|
- create_order
|
|
- get_order_status
|
|
- update_order_status
|
|
- cancel_order
|
|
fiados:
|
|
- get_fiado_balance
|
|
- create_fiado
|
|
- register_fiado_payment
|
|
- get_fiado_history
|
|
- check_fiado_eligibility
|
|
clientes:
|
|
- search_customers
|
|
- get_customer_balance
|
|
recursos_mcp:
|
|
- michangarrito://config/business
|
|
- michangarrito://catalog/categories
|
|
```
|
|
|
|
#### 3.3.2 Integracion LLM Multi-Proveedor
|
|
```yaml
|
|
id: AI-002
|
|
nombre: LLM Integration
|
|
estado: Completado
|
|
gateway: OpenRouter
|
|
modelos_soportados:
|
|
- anthropic/claude-3-haiku (Default - economico)
|
|
- anthropic/claude-3-sonnet (Premium)
|
|
- openai/gpt-4o-mini (Fallback)
|
|
- openai/gpt-3.5-turbo (Fallback)
|
|
- mistralai/mistral-7b (Economico)
|
|
- meta-llama/llama-3-8b (Open source)
|
|
caracteristicas:
|
|
- Cambio de modelo sin modificar codigo
|
|
- Fallback automatico entre modelos
|
|
- Rate limiting inteligente
|
|
- Token tracking por tenant
|
|
- Cost estimation en USD
|
|
- Configuracion por tenant
|
|
tablas:
|
|
- ai.configs
|
|
- ai.usage
|
|
```
|
|
|
|
#### 3.3.3 WhatsApp Service con IA
|
|
```yaml
|
|
id: AI-003
|
|
nombre: WhatsApp Service
|
|
estado: Completado
|
|
puerto: 3143
|
|
tecnologia: NestJS + Meta WhatsApp Business API
|
|
componentes:
|
|
- LLM Service (procesa mensajes con IA)
|
|
- Webhook Handler (recibe mensajes de Meta)
|
|
- WhatsApp Service (envia respuestas)
|
|
flujo_mensaje:
|
|
1: Cliente envia mensaje a WhatsApp
|
|
2: Meta envia POST a /webhook
|
|
3: WebhookService verifica firma
|
|
4: LLMService obtiene configuracion del tenant
|
|
5: Procesa con historial de conversacion
|
|
6: Llama LLM (OpenRouter)
|
|
7: LLM decide si llamar tools (function calling)
|
|
8: MCP Server ejecuta tools si necesario
|
|
9: Genera respuesta natural
|
|
10: WhatsApp Service envia respuesta
|
|
tipos_mensaje:
|
|
entrantes: [text, audio, image, location, interactive]
|
|
salientes: [text, template, interactive, media]
|
|
```
|
|
|
|
#### 3.3.4 Prediccion de Inventario
|
|
```yaml
|
|
id: AI-004
|
|
nombre: Prediccion Inventario
|
|
estado: Completado
|
|
algoritmos:
|
|
prediccion_demanda:
|
|
tipo: Promedio Movil Ponderado
|
|
ventana: 4 semanas
|
|
pesos: [0.40, 0.30, 0.20, 0.10]
|
|
punto_reorden:
|
|
formula: (Demanda_diaria * Lead_time) + Stock_seguridad
|
|
lead_time_default: 3 dias
|
|
stock_seguridad: Demanda_diaria * 2
|
|
dias_inventario:
|
|
formula: Stock_actual / Demanda_diaria
|
|
funcionalidades:
|
|
- Alertas cuando stock < minimo
|
|
- Sugerencias automaticas de pedido
|
|
- Deteccion de productos sin movimiento (> 30 dias)
|
|
- Calculo de valor total del inventario
|
|
- Reportes semanales automaticos via WhatsApp
|
|
endpoints:
|
|
- GET /inventory/low-stock
|
|
- GET /inventory/predictions
|
|
- GET /inventory/reorder-suggestions
|
|
- GET /inventory/slow-moving
|
|
- GET /inventory/days-on-hand
|
|
- GET /inventory/analytics
|
|
```
|
|
|
|
#### 3.3.5 Chat LLM para Usuarios
|
|
```yaml
|
|
id: AI-005
|
|
nombre: Chat LLM
|
|
estado: Planificado
|
|
variantes:
|
|
dueno:
|
|
herramientas:
|
|
- search_products
|
|
- get_product_stock
|
|
- update_product_price
|
|
- get_daily_sales
|
|
- get_sales_report
|
|
- get_low_stock_products
|
|
- search_customers
|
|
- get_customer_balance
|
|
- send_payment_reminder
|
|
- get_top_products
|
|
- get_business_metrics
|
|
alertas_proactivas:
|
|
- Stock bajo (3+ productos)
|
|
- Recordatorio de cobro (cartera > $2,000)
|
|
- Reporte semanal de ventas
|
|
cliente:
|
|
herramientas:
|
|
- search_products
|
|
- get_product_price
|
|
- check_availability
|
|
- create_order
|
|
- get_my_balance
|
|
- get_business_info
|
|
- get_promotions
|
|
restricciones:
|
|
- NO ver info de otros clientes
|
|
- NO modificar precios
|
|
- NO ver reportes financieros
|
|
- Rate limit: 20 mensajes/hora
|
|
```
|
|
|
|
### 3.4 Integraciones Externas IA
|
|
|
|
| Integracion | Proveedor | Estado | Descripcion |
|
|
|-------------|-----------|--------|-------------|
|
|
| LLM Gateway | OpenRouter | Completado | Acceso a 50+ modelos LLM |
|
|
| WhatsApp | Meta Cloud API | Completado | Mensajeria con IA |
|
|
| Transcripcion | OpenAI Whisper | Planeado | Notas de voz a texto |
|
|
| Vision/OCR | Google Vision | Planeado | Reconocimiento de productos |
|
|
|
|
### 3.5 Base de Datos IA
|
|
|
|
```yaml
|
|
schemas_ia:
|
|
messaging:
|
|
descripcion: Conversaciones y mensajes
|
|
tablas:
|
|
- conversations (id, tenant_id, phone_number, contact_name, type, status)
|
|
- messages (id, conversation_id, direction, type, content, llm_processed, tokens_used)
|
|
- notifications (id, tenant_id, type, channels, title, body, data)
|
|
|
|
ai:
|
|
descripcion: Configuracion y uso de IA
|
|
tablas:
|
|
- configs (id, tenant_id, provider, model, temperature, max_tokens, system_prompt)
|
|
- usage (id, tenant_id, tokens_used, model, operation, cost_usd)
|
|
|
|
public_integrations:
|
|
descripcion: Credenciales de integracion
|
|
tablas:
|
|
- tenant_integration_credentials (id, tenant_id, type, provider, credentials, config)
|
|
```
|
|
|
|
---
|
|
|
|
## 4. ANALISIS DE GAPS
|
|
|
|
### 4.1 Gaps en Documentacion
|
|
|
|
| ID | Gap | Ubicacion | Severidad | Accion |
|
|
|----|-----|-----------|-----------|--------|
|
|
| GAP-001 | Falta seccion SaaS en vision-general | VISION-ERP-CORE.md | Alta | Agregar seccion completa |
|
|
| GAP-002 | Falta seccion IA en vision-general | VISION-ERP-CORE.md | Alta | Agregar seccion completa |
|
|
| GAP-003 | Modulos MGN-016 a MGN-022 no definidos | VISION-ERP-CORE.md | Alta | Agregar a tabla de modulos |
|
|
| GAP-004 | Arquitectura no incluye capas SaaS/IA | VISION-ERP-CORE.md | Media | Actualizar diagrama |
|
|
| GAP-005 | Sin documentacion de integraciones externas | 00-vision-general/ | Media | Crear INTEGRACIONES.md |
|
|
| GAP-006 | Sin frontmatter SIMCO | VISION-ERP-CORE.md | Baja | Agregar metadatos YAML |
|
|
| GAP-007 | Sin _MAP.md en vision-general | 00-vision-general/ | Baja | Crear indice |
|
|
|
|
### 4.2 Gaps en Estructura
|
|
|
|
| ID | Gap | Ubicacion Esperada | Estado | Accion |
|
|
|----|-----|-------------------|--------|--------|
|
|
| GAP-008 | MASTER_INVENTORY.yml falta | orchestration/inventarios/ | FALTA | Crear |
|
|
| GAP-009 | DATABASE_INVENTORY.yml falta | orchestration/inventarios/ | FALTA | Crear |
|
|
| GAP-010 | BACKEND_INVENTORY.yml falta | orchestration/inventarios/ | FALTA | Crear |
|
|
| GAP-011 | FRONTEND_INVENTORY.yml falta | orchestration/inventarios/ | FALTA | Crear |
|
|
| GAP-012 | Checklists SIMCO faltan | orchestration/checklists/ | FALTA | Crear |
|
|
|
|
### 4.3 Matriz de Cobertura Requerida
|
|
|
|
| Aspecto | Actual | Requerido | Gap |
|
|
|---------|--------|-----------|-----|
|
|
| Modulos documentados | 15 | 22+ | 7+ modulos |
|
|
| Integraciones documentadas | 0 | 7 | 7 integraciones |
|
|
| Arquitectura SaaS | No | Si | 1 diagrama |
|
|
| Arquitectura IA | No | Si | 1 diagrama |
|
|
| Planes/Pricing | No | Si | 1 seccion |
|
|
| Herramientas MCP | No | Si | 1 seccion |
|
|
| Algoritmos prediccion | No | Si | 1 seccion |
|
|
|
|
---
|
|
|
|
## 5. DEPENDENCIAS IDENTIFICADAS
|
|
|
|
### 5.1 Dependencias de Documentacion
|
|
|
|
```
|
|
VISION-ERP-CORE.md (actualizar)
|
|
|
|
|
+-- ARQUITECTURA-GENERAL.md (crear/actualizar)
|
|
| |
|
|
| +-- ARQUITECTURA-SAAS.md (crear)
|
|
| +-- ARQUITECTURA-IA.md (crear)
|
|
|
|
|
+-- STACK-TECNOLOGICO.md (crear/actualizar)
|
|
| |
|
|
| +-- INTEGRACIONES-EXTERNAS.md (crear)
|
|
|
|
|
+-- MODULOS-CORE.md (actualizar)
|
|
| |
|
|
| +-- MGN-016-billing/ (crear)
|
|
| +-- MGN-017-plans/ (crear)
|
|
| +-- MGN-018-webhooks/ (crear)
|
|
| +-- MGN-019-feature-flags/ (crear)
|
|
| +-- MGN-020-ai-integration/ (crear)
|
|
| +-- MGN-021-whatsapp-business/ (crear)
|
|
| +-- MGN-022-mcp-server/ (crear)
|
|
|
|
|
+-- _MAP.md (crear)
|
|
```
|
|
|
|
### 5.2 Dependencias de Modulos
|
|
|
|
```
|
|
MGN-001 (auth) ← MGN-002 (users) ← MGN-003 (roles)
|
|
↑ ↑ ↑
|
|
| | |
|
|
MGN-004 (tenants) ────+───────────────+
|
|
↑
|
|
|
|
|
+── MGN-016 (billing) ← MGN-017 (plans)
|
|
| ↑
|
|
| +── MGN-018 (webhooks)
|
|
| +── MGN-019 (feature-flags)
|
|
|
|
|
+── MGN-020 (ai-integration)
|
|
| ↑
|
|
| +── MGN-021 (whatsapp-business)
|
|
| +── MGN-022 (mcp-server)
|
|
|
|
|
+── MGN-008 (notifications) [existente - extender]
|
|
```
|
|
|
|
### 5.3 Dependencias de Integraciones
|
|
|
|
| Modulo | Integracion Requerida | Proveedor |
|
|
|--------|----------------------|-----------|
|
|
| MGN-016 (billing) | Stripe | stripe.com |
|
|
| MGN-008 (notifications) | SendGrid/SES | sendgrid.com / AWS |
|
|
| MGN-008 (notifications) | Web Push | VAPID |
|
|
| MGN-019 (feature-flags) | Redis | redis.io |
|
|
| MGN-020 (ai-integration) | OpenRouter | openrouter.ai |
|
|
| MGN-021 (whatsapp) | Meta Cloud API | business.whatsapp.com |
|
|
| MGN-018 (webhooks) | Redis/BullMQ | redis.io |
|
|
| Storage | S3/R2/MinIO | aws.amazon.com / cloudflare.com |
|
|
|
|
---
|
|
|
|
## 6. PLAN INICIAL DE IMPLEMENTACION
|
|
|
|
### 6.1 Fases de Trabajo
|
|
|
|
```
|
|
FASE 1: Analisis y Planeacion Inicial (ACTUAL)
|
|
↓
|
|
FASE 2: Analisis Detallado
|
|
- Mapeo completo de archivos a modificar
|
|
- Analisis de contenido especifico por archivo
|
|
- Identificacion de conflictos potenciales
|
|
↓
|
|
FASE 3: Planeacion Basada en Analisis
|
|
- Crear plan de ejecucion detallado
|
|
- Definir orden de modificaciones
|
|
- Establecer checkpoints de validacion
|
|
↓
|
|
FASE 4: Validacion de Planeacion
|
|
- Validar plan contra analisis
|
|
- Verificar cobertura completa de gaps
|
|
- Aprobar plan o iterar
|
|
↓
|
|
FASE 5: Analisis de Dependencias
|
|
- Validar dependencias entre archivos
|
|
- Verificar integridad de referencias
|
|
- Mapear impacto de cambios
|
|
↓
|
|
FASE 6: Refinamiento del Plan
|
|
- Ajustar plan basado en dependencias
|
|
- Optimizar orden de ejecucion
|
|
- Finalizar plan de ejecucion
|
|
↓
|
|
FASE 7: Ejecucion del Plan
|
|
- Modificar archivos segun plan
|
|
- Crear archivos nuevos requeridos
|
|
- Actualizar referencias cruzadas
|
|
↓
|
|
FASE 8: Validacion de Ejecucion
|
|
- Validar todos los archivos modificados
|
|
- Verificar consistencia de documentacion
|
|
- Comparar resultado vs plan
|
|
- Generar reporte final
|
|
```
|
|
|
|
### 6.2 Archivos a Modificar/Crear
|
|
|
|
| Archivo | Accion | Prioridad |
|
|
|---------|--------|-----------|
|
|
| `/docs/00-vision-general/VISION-ERP-CORE.md` | MODIFICAR | P0 |
|
|
| `/docs/00-vision-general/_MAP.md` | CREAR | P1 |
|
|
| `/docs/00-vision-general/ARQUITECTURA-SAAS.md` | CREAR | P1 |
|
|
| `/docs/00-vision-general/ARQUITECTURA-IA.md` | CREAR | P1 |
|
|
| `/docs/00-vision-general/INTEGRACIONES-EXTERNAS.md` | CREAR | P1 |
|
|
| `/docs/00-vision-general/STACK-TECNOLOGICO.md` | CREAR | P1 |
|
|
| `/docs/02-definicion-modulos/INDICE-MODULOS.md` | MODIFICAR | P1 |
|
|
| `/docs/_MAP.md` | MODIFICAR | P2 |
|
|
| `/orchestration/inventarios/MASTER_INVENTORY.yml` | CREAR | P2 |
|
|
|
|
### 6.3 Criterios de Exito
|
|
|
|
| Criterio | Metrica | Objetivo |
|
|
|----------|---------|----------|
|
|
| Cobertura de gaps | Gaps resueltos / Gaps totales | 100% |
|
|
| Modulos documentados | MGN-* con documentacion | 22+ |
|
|
| Integraciones documentadas | INT-* con documentacion | 7 |
|
|
| Consistencia SIMCO | Archivos con frontmatter | 100% |
|
|
| Referencias validas | Links internos funcionales | 100% |
|
|
| Completitud de vision | Secciones requeridas presentes | 100% |
|
|
|
|
---
|
|
|
|
## 7. PROXIMOS PASOS
|
|
|
|
### 7.1 Siguiente Fase: Analisis Detallado
|
|
|
|
**Objetivo:** Analizar en detalle el contenido especifico de cada archivo a modificar/crear
|
|
|
|
**Entregables:**
|
|
1. Documento de analisis detallado por archivo
|
|
2. Contenido propuesto para cada seccion nueva
|
|
3. Lista de cambios especificos por linea
|
|
4. Analisis de impacto en archivos dependientes
|
|
|
|
### 7.2 Preguntas Pendientes
|
|
|
|
1. Precios especificos para planes SaaS en ERP Core?
|
|
2. Modelos LLM default para ERP Core?
|
|
3. Integraciones de pago adicionales (MercadoPago, Clip)?
|
|
4. Alcance de funcionalidades IA para verticales?
|
|
5. Politica de tokens/limites por plan?
|
|
|
|
---
|
|
|
|
## 8. REFERENCIAS
|
|
|
|
### 8.1 Proyectos Fuente
|
|
|
|
| Proyecto | Ubicacion | Rol |
|
|
|----------|-----------|-----|
|
|
| erp-core | /projects/erp-core/ | Proyecto destino |
|
|
| template-saas | /projects/template-saas/ | Fuente SaaS |
|
|
| michangarrito | /projects/michangarrito/ | Fuente IA |
|
|
|
|
### 8.2 Documentacion de Referencia
|
|
|
|
| Documento | Ubicacion | Proposito |
|
|
|-----------|-----------|-----------|
|
|
| SIMCO-DOCUMENTAR.md | /orchestration/directivas/simco/ | Directiva de documentacion |
|
|
| ESTANDAR-ESTRUCTURA-DOCS.md | /orchestration/referencias/ | Estructura de docs |
|
|
| PERFIL-ARCHITECTURE-ANALYST.md | /orchestration/agents/perfiles/ | Perfil de orquestador |
|
|
| PERFIL-DOCUMENTATION.md | /orchestration/agents/perfiles/ | Perfil de documentacion |
|
|
| PERFIL-REQUIREMENTS-ANALYST.md | /orchestration/agents/perfiles/ | Perfil de analisis |
|
|
|
|
---
|
|
|
|
**Documento generado:** 2026-01-10
|
|
**Fase:** 1 de 8 (Analisis y Planeacion Inicial)
|
|
**Estado:** COMPLETADO
|
|
**Siguiente fase:** Analisis Detallado
|