|
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> |
||
|---|---|---|
| .. | ||
| especificaciones | ||
| historias-usuario | ||
| implementacion | ||
| requerimientos | ||
| _MAP.md | ||
| README.md | ||
MGN-004: Multi-tenant
Metadata
| Campo | Valor |
|---|---|
| ID | MGN-004 |
| Nombre | Multi-tenant |
| Fase | 01 - Foundation |
| Prioridad | P0 (Critico) |
| Story Points | 35 SP |
| Estado | Documentado |
| Dependencias | MGN-001, MGN-002, MGN-003 |
Descripcion
Sistema de multi-tenancy que permite que multiples organizaciones/empresas utilicen la misma instancia del ERP con completo aislamiento de datos.
Caracteristicas principales:
- Aislamiento RLS: Row Level Security en PostgreSQL
- Configuracion por tenant: Moneda, zona horaria, formato de fecha
- Planes de suscripcion: Diferentes niveles de servicio
- Limites por plan: Usuarios, almacenamiento, modulos
- Onboarding automatizado: Creacion de tenant con datos iniciales
Arquitectura
Request
│
▼
┌──────────────────────┐
│ TenantMiddleware │ <- Extrae tenant_id del token JWT
└──────────┬───────────┘
│
▼
┌──────────────────────┐
│ SET app.tenant_id │ <- Establece contexto PostgreSQL
└──────────┬───────────┘
│
▼
┌──────────────────────┐
│ RLS Policies │ <- Filtra automaticamente
│ tenant_isolation │ por tenant_id
└──────────────────────┘
Planes de Suscripcion
| Plan | Usuarios | Almacenamiento | Modulos |
|---|---|---|---|
| Free | 3 | 1 GB | Core |
| Starter | 10 | 5 GB | Core + Ventas |
| Professional | 50 | 25 GB | Todos |
| Enterprise | Ilimitado | Ilimitado | Todos + Soporte |
Endpoints API
| Metodo | Path | Descripcion |
|---|---|---|
| GET | /api/v1/tenants |
Listar tenants (super admin) |
| POST | /api/v1/tenants |
Crear tenant |
| GET | /api/v1/tenants/:id |
Obtener tenant |
| PATCH | /api/v1/tenants/:id |
Actualizar tenant |
| GET | /api/v1/tenants/current |
Tenant actual |
| GET | /api/v1/tenants/current/settings |
Config del tenant |
| PATCH | /api/v1/tenants/current/settings |
Actualizar config |
| GET | /api/v1/plans |
Listar planes |
| POST | /api/v1/subscriptions |
Crear suscripcion |
| GET | /api/v1/subscriptions/current |
Suscripcion actual |
Tablas de Base de Datos
| Tabla | Descripcion |
|---|---|
tenants |
Organizaciones/empresas |
tenant_settings |
Configuracion por tenant |
plans |
Planes de suscripcion |
subscriptions |
Suscripciones activas |
Documentacion
- Mapa del modulo: _MAP.md
- Trazabilidad: TRACEABILITY.yml
Generado por: Requirements-Analyst Fecha: 2025-12-05