# MASTER_INVENTORY.yml - Platform Marketing Content
# Inventario maestro de implementación
# Versión: 1.0.0
# Fecha: 2025-12-08

project:
  name: Platform Marketing Content
  alias: PMC
  nivel_simco: NIVEL_2B
  status: documentacion

# =============================================================================
# MÓDULOS
# =============================================================================
modules:
  PMC-001-TENANTS:
    name: Tenants
    priority: alta
    status: definido
    doc_path: docs/02-definicion-modulos/PMC-001-TENANTS.md
    dependencies:
      catalog:
        - "@CATALOG_TENANT"
    entities:
      - Tenant
      - Plan
    endpoints_count: 8
    features_count: 10

  PMC-002-CRM:
    name: CRM
    priority: alta
    status: definido
    doc_path: docs/02-definicion-modulos/PMC-002-CRM.md
    dependencies:
      modules:
        - PMC-001-TENANTS
        - PMC-003-PROJECTS
        - PMC-004-GENERATION
        - PMC-006-ASSETS
    entities:
      - Client
      - Contact
      - Brand
      - Product
      - Opportunity
    endpoints_count: 25
    features_count: 18

  PMC-003-PROJECTS:
    name: Projects
    priority: alta
    status: definido
    doc_path: docs/02-definicion-modulos/PMC-003-PROJECTS.md
    dependencies:
      modules:
        - PMC-001-TENANTS
        - PMC-002-CRM
        - PMC-004-GENERATION
        - PMC-006-ASSETS
    entities:
      - Project
      - Campaign
      - CampaignAsset
    endpoints_count: 20
    features_count: 16

  PMC-004-GENERATION:
    name: Generation (Motor IA)
    priority: alta
    status: definido
    doc_path: docs/02-definicion-modulos/PMC-004-GENERATION.md
    dependencies:
      modules:
        - PMC-001-TENANTS
        - PMC-002-CRM
        - PMC-003-PROJECTS
        - PMC-006-ASSETS
      catalog:
        - "@CATALOG_RATELIMIT"
      external:
        - ComfyUI
        - OpenAI/Claude API
        - Redis
        - S3/MinIO
    entities:
      - GenerationJob
      - WorkflowTemplate
      - CustomModel
      - TextGeneration
    endpoints_count: 18
    features_count: 20
    workflows_predefinidos:
      - product_photo_synthetic
      - social_media_post
      - ad_variations
      - virtual_avatar

  PMC-005-AUTOMATION:
    name: Automation
    priority: media
    status: definido
    doc_path: docs/02-definicion-modulos/PMC-005-AUTOMATION.md
    dependencies:
      modules:
        - PMC-001-TENANTS
        - PMC-002-CRM
        - PMC-003-PROJECTS
        - PMC-004-GENERATION
        - PMC-006-ASSETS
      external:
        - n8n
        - SMTP/SendGrid
    entities:
      - AutomationFlow
      - AutomationRun
      - WebhookEndpoint
    endpoints_count: 15
    features_count: 12
    flows_predefinidos:
      - product_asset_kit
      - campaign_initial_batch
      - campaign_delivery_prep
      - job_failure_handler

  PMC-006-ASSETS:
    name: Assets (DAM)
    priority: alta
    status: definido
    doc_path: docs/02-definicion-modulos/PMC-006-ASSETS.md
    dependencies:
      modules:
        - PMC-001-TENANTS
        - PMC-003-PROJECTS
        - PMC-004-GENERATION
      external:
        - S3/MinIO
        - Sharp
    entities:
      - Asset
      - AssetVersion
      - Collection
      - AssetComment
      - Download
    endpoints_count: 25
    features_count: 18

  PMC-007-ADMIN:
    name: Admin
    priority: media
    status: definido
    doc_path: docs/02-definicion-modulos/PMC-007-ADMIN.md
    dependencies:
      modules:
        - PMC-001-TENANTS
      catalog:
        - "@CATALOG_AUTH"
        - "@CATALOG_SESSION"
    entities:
      - User
      - Role
      - Invitation
      - AuditLog
      - Setting
    endpoints_count: 20
    features_count: 14
    roles_sistema:
      - super_admin
      - tenant_admin
      - creative
      - analyst
      - viewer
      - client_portal

  PMC-008-ANALYTICS:
    name: Analytics
    priority: baja
    status: definido
    doc_path: docs/02-definicion-modulos/PMC-008-ANALYTICS.md
    dependencies:
      modules:
        - PMC-001-TENANTS
        - PMC-003-PROJECTS
        - PMC-004-GENERATION
        - PMC-006-ASSETS
      external:
        - Redis
    entities:
      - Metric
      - Report
      - SavedView
    endpoints_count: 12
    features_count: 10
    dashboards:
      - home
      - production
      - campaigns
      - resources

# =============================================================================
# STACK TECNOLÓGICO
# =============================================================================
tech_stack:
  backend:
    framework: NestJS
    language: TypeScript
    database: PostgreSQL 15+
    cache: Redis
    queue: Bull/BullMQ
    orm: TypeORM

  frontend:
    framework: React 18
    bundler: Vite
    styling: TailwindCSS
    components: Shadcn/UI
    state: Zustand o React Query

  ia_engine:
    image_generation: ComfyUI + SDXL
    text_generation: OpenAI API / Claude API
    deployment: ComfyDeploy

  automation:
    orchestrator: n8n

  storage:
    files: S3/MinIO

  infrastructure:
    containers: Docker + Docker Compose
    gpu: NVIDIA (12-24GB VRAM)

# =============================================================================
# CATÁLOGO DE DEPENDENCIAS
# =============================================================================
catalog_dependencies:
  required:
    - id: "@CATALOG_AUTH"
      path: core/catalog/auth/
      description: Autenticación JWT + OAuth + RBAC
      module: PMC-007-ADMIN
      docs: core/catalog/auth/README.md
      ahorro_estimado: "32h"

    - id: "@CATALOG_SESSION"
      path: core/catalog/session-management/
      description: Gestión de sesiones concurrentes
      module: PMC-007-ADMIN
      docs: core/catalog/session-management/README.md
      ahorro_estimado: "8h"

    - id: "@CATALOG_TENANT"
      path: core/catalog/multi-tenancy/
      description: Multi-tenancy con RLS
      module: PMC-001-TENANTS
      docs: core/catalog/multi-tenancy/README.md
      ahorro_estimado: "48h"

    - id: "@CATALOG_RATELIMIT"
      path: core/catalog/rate-limiting/
      description: Rate limiting por tenant/endpoint
      module: PMC-004-GENERATION
      docs: core/catalog/rate-limiting/README.md
      ahorro_estimado: "12h"

    - id: "@CATALOG_NOTIFY"
      path: core/catalog/notifications/
      description: Notificaciones multi-canal
      module: PMC-005-AUTOMATION
      docs: core/catalog/notifications/README.md
      ahorro_estimado: "26h"

  fase_4_saas:
    - id: "@CATALOG_PAYMENTS"
      path: core/catalog/payments/
      description: Suscripciones con Stripe
      module: PMC-001-TENANTS
      docs: core/catalog/payments/README.md
      ahorro_estimado: "36h"

  optional:
    - id: "@CATALOG_FLAGS"
      path: core/catalog/feature-flags/
      description: Feature flags para rollout
      module: PMC-007-ADMIN
      docs: core/catalog/feature-flags/README.md
      ahorro_estimado: "13h"

    - id: "@CATALOG_WS"
      path: core/catalog/websocket/
      description: WebSocket para tiempo real
      module: PMC-004-GENERATION
      docs: core/catalog/websocket/README.md
      ahorro_estimado: "18h"

  ahorro_total: "185h de desarrollo"

# =============================================================================
# PATRONES DE REFERENCIA (desde Catalogo Core)
# =============================================================================
# NOTA: Para componentes reutilizables, usar siempre core/catalog/
# Los proyectos externos sirven solo como inspiracion arquitectonica
reference_patterns:
  auth_and_session:
    catalogo: core/catalog/auth/
    usar_para:
      - Auth module structure
      - Session management
      - JWT patterns

  multi_tenancy:
    catalogo: core/catalog/multi-tenancy/
    usar_para:
      - RLS policies
      - Tenant isolation
      - Feature flags

  payments:
    catalogo: core/catalog/payments/
    usar_para:
      - Stripe integration
      - Wallet patterns

  realtime:
    catalogo: core/catalog/websocket/
    usar_para:
      - WebSocket gateway
      - Notifications

# =============================================================================
# FASES DE IMPLEMENTACIÓN
# =============================================================================
roadmap:
  fase_1_mvp_core:
    duration: "Semanas 1-8"
    modules:
      - PMC-001-TENANTS
      - PMC-007-ADMIN
      - PMC-002-CRM
      - PMC-006-ASSETS
      - PMC-003-PROJECTS
      - PMC-004-GENERATION
    deliverables:
      - Arquitectura base multi-tenant
      - Autenticación y usuarios
      - CRM básico (clientes, marcas, productos)
      - DAM básico
      - Campañas con brief
      - Motor de generación (2-3 workflows)

  fase_2_personalizacion:
    duration: "Semanas 9-14"
    modules:
      - PMC-004-GENERATION (ampliación)
      - PMC-005-AUTOMATION
    deliverables:
      - Entrenamiento de LoRAs
      - Avatares consistentes
      - Flujos automatizados CRM → Generation

  fase_3_contenido_enriquecido:
    duration: "Semanas 15-22"
    modules:
      - PMC-004-GENERATION (video)
      - PMC-008-ANALYTICS
    deliverables:
      - GIFs/cinemagraphs
      - Video básico
      - Dashboards y reportes
      - Portal cliente

  fase_4_saas_comercial:
    duration: "Semanas 23+"
    modules:
      - PMC-001-TENANTS (planes)
      - PMC-007-ADMIN (billing)
    deliverables:
      - SaaS público
      - Planes de suscripción
      - Onboarding automático

# =============================================================================
# MÉTRICAS
# =============================================================================
metrics:
  total_modules: 8
  total_entities: 28
  total_endpoints: ~143
  total_features: 118
  total_requirements: 167
  total_user_stories: 66
  total_adrs: 4
  features_priority:
    alta: 64
    media: 41
    baja: 13
  documentation_status:
    vision_general: completado
    glosario: completado
    arquitectura: completado
    analisis_referencias: completado
    modulos: completado
    requerimientos: completado
    modelo_dominio: completado
    esquema_bd: completado
    user_stories: completado
    guias_desarrollo: completado
    adrs: completado

# =============================================================================
# INVENTARIOS DE ORCHESTRATION
# =============================================================================
orchestration_inventories:
  MASTER_INVENTORY.yml:
    status: actualizado
    descripcion: Este archivo - indice maestro

  DATABASE_INVENTORY.yml:
    status: planificado
    descripcion: 7 schemas, 28 tablas, RLS policies
    schemas:
      - auth
      - crm
      - projects
      - generation
      - assets
      - automation
      - analytics

  BACKEND_INVENTORY.yml:
    status: planificado
    descripcion: 8 modulos NestJS, colas BullMQ, integraciones
    modulos: 8
    endpoints_estimados: 143
    colas:
      - "generation:image"
      - "generation:text"
      - "generation:training"
      - "assets:processing"
      - "notifications:email"

  FRONTEND_INVENTORY.yml:
    status: planificado
    descripcion: React app, paginas, componentes, stores
    paginas_planificadas: 35
    componentes_estimados: 120
    stores:
      - useAuthStore
      - useTenantStore
      - useUIStore
      - useGenerationStore

  DEPENDENCY_GRAPH.yml:
    status: actualizado
    descripcion: Grafo de dependencias entre modulos
    incluye:
      - orden_implementacion
      - impacto_cambios
      - diagrama_mermaid

  TRACEABILITY_MATRIX.yml:
    status: actualizado
    descripcion: Matriz de trazabilidad reqs -> stories -> components
    cobertura: 100%

# =============================================================================
# DOCUMENTACIÓN GENERADA
# =============================================================================
documentation:
  "00-vision-general":
    - VISION-GENERAL.md
    - ARQUITECTURA-TECNICA.md
    - GLOSARIO.md
    - _MAP.md

  "01-analisis-referencias":
    - _INDEX.md
    - ANALISIS-CATALOGO.md       # 8 componentes mapeados, 185h ahorro
    - ANALISIS-PROYECTOS-REFERENCIA.md  # gamilit, trading-platform

  "02-definicion-modulos":
    - _INDEX.md
    - PMC-001-TENANTS.md
    - PMC-002-CRM.md
    - PMC-003-PROJECTS.md
    - PMC-004-GENERATION.md
    - PMC-005-AUTOMATION.md
    - PMC-006-ASSETS.md
    - PMC-007-ADMIN.md
    - PMC-008-ANALYTICS.md

  "03-requerimientos":
    - _INDEX.md
    - RF-PMC-001-TENANTS.md      # 15 requisitos
    - RF-PMC-002-CRM.md          # 25 requisitos
    - RF-PMC-003-PROJECTS.md     # 22 requisitos
    - RF-PMC-004-GENERATION.md   # 28 requisitos
    - RF-PMC-005-AUTOMATION.md   # 18 requisitos
    - RF-PMC-006-ASSETS.md       # 24 requisitos
    - RF-PMC-007-ADMIN.md        # 20 requisitos
    - RF-PMC-008-ANALYTICS.md    # 15 requisitos

  "04-modelado":
    - MODELO-DOMINIO.md          # 28 entidades, 8 agregados DDD
    - ESQUEMA-BD.md              # 6 schemas PostgreSQL

  "05-user-stories":
    - _INDEX.md
    - EPIC-001-SETUP.md          # 8 user stories
    - EPIC-002-CRM.md            # 12 user stories
    - EPIC-003-PROJECTS.md       # 10 user stories
    - EPIC-004-GENERATION.md     # 15 user stories
    - EPIC-005-ASSETS.md         # 10 user stories
    - EPIC-006-AUTOMATION.md     # 6 user stories
    - EPIC-007-ANALYTICS.md      # 5 user stories

  "95-guias-desarrollo":
    - GUIA-CONVENCIONES.md       # Naming, código, git workflow
    - GUIA-SETUP.md              # Docker, environment, instalación

  "97-adr":
    - _INDEX.md
    - ADR-001-stack-tecnologico.md    # NestJS + React + PostgreSQL
    - ADR-002-multi-tenancy.md        # RLS strategy
    - ADR-003-motor-generacion.md     # ComfyUI + SDXL
    - ADR-004-cola-tareas.md          # BullMQ + Redis

  "90-transversal":
    carpetas:
      - arquitectura/
      - correcciones/
      - deuda-tecnica/
      - features/
      - gaps/
      - inventarios/
      - metricas/
      - reportes-implementacion/
      - roadmap/
      - sprints/
    archivos:
      - README.md
      - roadmap/ROADMAP-PMC.md

  "orchestration/00-guidelines":
    - CONTEXTO-PROYECTO.md
    - HERENCIA-DIRECTIVAS.md

  "orchestration/directivas":
    - DIRECTIVA-ARQUITECTURA-MULTI-TENANT.md
    - GUIA-NOMENCLATURA-PMC.md

  "orchestration/inventarios":
    - MASTER_INVENTORY.yml
    - DATABASE_INVENTORY.yml
    - BACKEND_INVENTORY.yml
    - FRONTEND_INVENTORY.yml
    - DEPENDENCY_GRAPH.yml
    - TRACEABILITY_MATRIX.yml

# =============================================================================
# METADATOS
# =============================================================================
metadata:
  created_by: Requirements-Analyst
  created_at: "2025-12-08"
  last_updated: "2025-12-08"
  version: "2.0.0"
  documentation_complete: true
  ready_for_implementation: true
