apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization

metadata:
  name: bakery-ia-base

resources:
  # Base configuration
  - namespace.yaml
  - configmap.yaml
  - secrets.yaml
  - ingress-https.yaml

  # TLS configuration
  - configmaps/postgres-logging-config.yaml
  - secrets/postgres-tls-secret.yaml
  - secrets/redis-tls-secret.yaml

  # Additional configs
  - configs/postgres-init-config.yaml

  # Migration jobs
  - migrations/auth-migration-job.yaml
  - migrations/tenant-migration-job.yaml
  - migrations/tenant-seed-pilot-coupon-job.yaml
  - migrations/training-migration-job.yaml
  - migrations/forecasting-migration-job.yaml
  - migrations/sales-migration-job.yaml
  - migrations/external-migration-job.yaml
  - migrations/notification-migration-job.yaml
  - migrations/inventory-migration-job.yaml
  - migrations/recipes-migration-job.yaml
  - migrations/suppliers-migration-job.yaml
  - migrations/pos-migration-job.yaml
  - migrations/orders-migration-job.yaml
  - migrations/production-migration-job.yaml
  - migrations/alert-processor-migration-job.yaml
  - migrations/demo-session-migration-job.yaml
  - migrations/procurement-migration-job.yaml
  - migrations/orchestrator-migration-job.yaml
  - migrations/ai-insights-migration-job.yaml

  # Demo initialization jobs (in Helm hook weight order)
  - jobs/demo-seed-rbac.yaml
  - jobs/demo-seed-users-job.yaml
  - jobs/demo-seed-tenants-job.yaml
  - jobs/demo-seed-tenant-members-job.yaml
  - jobs/demo-seed-subscriptions-job.yaml
  - jobs/demo-seed-inventory-job.yaml
  - jobs/demo-seed-recipes-job.yaml
  - jobs/demo-seed-suppliers-job.yaml
  - jobs/demo-seed-purchase-orders-job.yaml
  - jobs/demo-seed-sales-job.yaml
  - jobs/demo-seed-ai-models-job.yaml
  - jobs/demo-seed-stock-job.yaml
  - jobs/demo-seed-quality-templates-job.yaml
  - jobs/demo-seed-customers-job.yaml
  - jobs/demo-seed-equipment-job.yaml
  - jobs/demo-seed-production-batches-job.yaml
  - jobs/demo-seed-orders-job.yaml
  - jobs/demo-seed-procurement-job.yaml
  - jobs/demo-seed-forecasts-job.yaml
  - jobs/demo-seed-pos-configs-job.yaml
  - jobs/demo-seed-orchestration-runs-job.yaml

  # External data initialization job (v2.0)
  - jobs/external-data-init-job.yaml

  # CronJobs
  - cronjobs/demo-cleanup-cronjob.yaml
  - cronjobs/external-data-rotation-cronjob.yaml

  # Infrastructure components
  - components/databases/redis.yaml
  - components/databases/rabbitmq.yaml
  - components/infrastructure/gateway-service.yaml

  # Nominatim geocoding service
  - components/nominatim/nominatim.yaml
  - jobs/nominatim-init-job.yaml

  # Persistent storage
  - components/volumes/model-storage-pvc.yaml

  # Database services
  - components/databases/auth-db.yaml
  - components/databases/tenant-db.yaml
  - components/databases/training-db.yaml
  - components/databases/forecasting-db.yaml
  - components/databases/sales-db.yaml
  - components/databases/external-db.yaml
  - components/databases/notification-db.yaml
  - components/databases/inventory-db.yaml
  - components/databases/recipes-db.yaml
  - components/databases/suppliers-db.yaml
  - components/databases/pos-db.yaml
  - components/databases/orders-db.yaml
  - components/databases/production-db.yaml
  - components/databases/procurement-db.yaml
  - components/databases/orchestrator-db.yaml
  - components/databases/alert-processor-db.yaml
  - components/databases/ai-insights-db.yaml

  # Demo session components
  - components/demo-session/database.yaml
  - components/demo-session/rbac.yaml
  - components/demo-session/service.yaml
  - components/demo-session/deployment.yaml

  # Microservices
  - components/auth/auth-service.yaml
  - components/tenant/tenant-service.yaml
  - components/training/training-service.yaml
  - components/forecasting/forecasting-service.yaml
  - components/sales/sales-service.yaml
  - components/external/external-service.yaml
  - components/notification/notification-service.yaml
  - components/inventory/inventory-service.yaml
  - components/recipes/recipes-service.yaml
  - components/suppliers/suppliers-service.yaml
  - components/pos/pos-service.yaml
  - components/orders/orders-service.yaml
  - components/production/production-service.yaml
  - components/procurement/procurement-service.yaml
  - components/orchestrator/orchestrator-service.yaml
  - components/alert-processor/alert-processor-service.yaml
  - components/alert-processor/alert-processor-api.yaml
  - components/ai-insights/ai-insights-service.yaml

  # Frontend
  - components/frontend/frontend-service.yaml

  # HorizontalPodAutoscalers (for production autoscaling)
  - components/hpa/orders-hpa.yaml
  - components/hpa/forecasting-hpa.yaml
  - components/hpa/notification-hpa.yaml

labels:
  - includeSelectors: true
    pairs:
      app.kubernetes.io/part-of: bakery-ia
      app.kubernetes.io/managed-by: kustomize

images:
  - name: bakery/auth-service
    newTag: latest
  - name: bakery/tenant-service
    newTag: latest
  - name: bakery/training-service
    newTag: latest
  - name: bakery/forecasting-service
    newTag: latest
  - name: bakery/sales-service
    newTag: latest
  - name: bakery/external-service
    newTag: latest
  - name: bakery/notification-service
    newTag: latest
  - name: bakery/inventory-service
    newTag: latest
  - name: bakery/recipes-service
    newTag: latest
  - name: bakery/suppliers-service
    newTag: latest
  - name: bakery/pos-service
    newTag: latest
  - name: bakery/orders-service
    newTag: latest
  - name: bakery/production-service
    newTag: latest
  - name: bakery/procurement-service
    newTag: latest
  - name: bakery/orchestrator-service
    newTag: latest
  - name: bakery/alert-processor
    newTag: latest
  - name: bakery/ai-insights-service
    newTag: latest
  - name: bakery/demo-session-service
    newTag: latest
  - name: bakery/gateway
    newTag: latest
  - name: bakery/dashboard
    newTag: latest
