# Factoryz Labs Integration Configuration for Hypergraph Meta Cluster

# Repository Configuration
repository:
  url: "git@github.com:Afrhone/factoryz-labs.git"
  branch: "main"
  clone_depth: 50
  submodules: false

# CI/CD Integration
ci_cd:
  enabled: true
  workflow_file: ".github/workflows/hyperbolic-ci-workflow.yml"
  build_strategy: "parallel"
  cache_enabled: true
  artifacts:
    - "dist/"
    - "build/"
    - "coverage/"

# Service Configuration
services:
  - name: "factoryz-labs-api"
    image: "ghcr.io/afrhone/factoryz-labs:latest"
    port: 3001
    replicas: 2
    environment:
      NODE_ENV: "production"
      PORT: "3001"
      API_BASE: "/api/factoryz"
      DATABASE_URL: "postgresql://factoryz:password@postgres:5432/factoryz"
    resources:
      cpu: 1.0
      memory: 2048
    health_check:
      endpoint: "/health"
      interval: 30
      timeout: 10
      retries: 3

  - name: "factoryz-labs-web"
    image: "ghcr.io/afrhone/factoryz-labs-web:latest"
    port: 3002
    replicas: 2
    environment:
      NODE_ENV: "production"
      PORT: "3002"
      API_BASE_URL: "http://factoryz-labs-api:3001"
      WS_BASE_URL: "ws://factoryz-labs-api:3001"
    resources:
      cpu: 0.5
      memory: 1024
    health_check:
      endpoint: "/"
      interval: 30
      timeout: 10
      retries: 3

# Remote Services Configuration
remote_services:
  enabled: true
  discovery:
    method: "consul"
    endpoint: "consul:8500"
    service_name: "factoryz-labs"
    tags:
      - "hypergraph"
      - "factory"
      - "production"
  api_gateway:
    enabled: true
    base_path: "/api/factoryz"
    routes:
      - path: "/"
        service: "factoryz-labs-api"
        port: 3001
      - path: "/ws"
        service: "factoryz-labs-api"
        port: 3001
        websocket: true

# Configuration Management
configuration:
  unified: true
  synchronization:
    enabled: true
    interval: 60
    method: "etcd"
    endpoint: "etcd:2379"
  environment_variables:
    FACTORYZ_LABS_ENV: "production"
    FACTORYZ_LABS_DEBUG: "false"
    FACTORYZ_LABS_LOG_LEVEL: "info"
    FACTORYZ_LABS_METRICS_ENABLED: "true"

# Business Intelligence Integration
business_intelligence:
  enabled: true
  data_sources:
    - name: "factoryz-labs-api"
      type: "rest"
      endpoint: "http://factoryz-labs-api:3001/api/metrics"
      interval: 60
    - name: "factoryz-labs-db"
      type: "postgresql"
      connection: "postgresql://factoryz:password@postgres:5432/factoryz"
      queries:
        - "SELECT * FROM metrics WHERE timestamp > NOW() - INTERVAL '1 hour'"
  dashboards:
    - name: "Factoryz Labs Overview"
      file: "dashboards/factoryz-overview.json"
      refresh_interval: 300
    - name: "Factoryz Labs Performance"
      file: "dashboards/factoryz-performance.json"
      refresh_interval: 60
  alerts:
    - name: "High API Latency"
      condition: "api_latency > 1000"
      severity: "warning"
      notification: "slack"
    - name: "Service Unavailable"
      condition: "service_health == 0"
      severity: "critical"
      notification: "slack,pagerduty"

# Admin Management Configuration
admin_management:
  enabled: true
  dashboard:
    title: "Factoryz Labs Admin"
    base_path: "/admin/factoryz"
    sections:
      - name: "Service Health"
        widgets:
          - "service_status"
          - "health_metrics"
          - "resource_usage"
      - name: "Configuration"
        widgets:
          - "config_editor"
          - "environment_variables"
          - "feature_flags"
      - name: "Monitoring"
        widgets:
          - "alerts"
          - "logs"
          - "metrics"
      - name: "User Management"
        widgets:
          - "user_list"
          - "role_management"
          - "access_control"
  rbac:
    roles:
      - name: "admin"
        permissions: ["*"],
      - name: "operator"
        permissions: ["read", "monitor", "restart"],
      - name: "viewer"
        permissions: ["read", "monitor"]

# Monitoring Configuration
monitoring:
  enabled: true
  prometheus:
    enabled: true
    scrape_interval: 15
    scrape_timeout: 10
    targets:
      - "factoryz-labs-api:3001"
      - "factoryz-labs-web:3002"
  grafana:
    enabled: true
    dashboards:
      - "factoryz-labs-overview"
      - "factoryz-labs-performance"
      - "factoryz-labs-resources"
  alerts:
    enabled: true
    rules:
      - alert: "FactoryzLabsHighCPU"
        expr: "sum(rate(container_cpu_usage_seconds_total{name=~'factoryz-labs-.*'}[5m])) by (name) > 0.8"
        for: "5m"
        labels:
          severity: "warning"
        annotations:
          summary: "High CPU usage on {{ $labels.name }}"
      - alert: "FactoryzLabsDown"
        expr: "up{job='factoryz-labs'} == 0"
        for: "1m"
        labels:
          severity: "critical"
        annotations:
          summary: "Factoryz Labs service down"

# Hypergraph Mesh Integration
hypergraph_mesh:
  enabled: true
  connectivity:
    protocol: "tcp"
    encryption: "tls"
    compression: "gzip"
  routing:
    strategy: "least_connections"
    retry_policy:
      attempts: 3
      delay: 1000
      multiplier: 2
  redundancy:
    enabled: true
    replicas: 2
    failover_timeout: 30
  monitoring:
    enabled: true
    metrics:
      - "mesh_connectivity"
      - "data_flow_rate"
      - "latency"
      - "error_rate"

# Security Configuration
security:
  enabled: true
  tls:
    enabled: true
    certificate: "/etc/ssl/certs/factoryz-labs.crt"
    key: "/etc/ssl/private/factoryz-labs.key"
  authentication:
    method: "jwt"
    secret: "factoryz-labs-secret-key"
    token_expiry: 3600
  authorization:
    method: "rbac"
    policy_file: "/app/configs/factoryz-labs/policies.json"
  rate_limiting:
    enabled: true
    limit: 100
    window: 60

# Deployment Configuration
deployment:
  strategy: "rolling"
  rolling_update:
    max_surge: 1
    max_unavailable: 0
  health_check:
    enabled: true
    interval: 30
    timeout: 10
    retries: 3
  auto_healing:
    enabled: true
    threshold: 3
    action: "restart"

# Network Configuration
network:
  overlay: "hypergraph_overlay"
  ingress:
    enabled: true
    class: "nginx"
    annotations:
      nginx.ingress.kubernetes.io/rewrite-target: "/"
  egress:
    enabled: true
    rules:
      - to: "postgres"
        port: 5432
      - to: "redis"
        port: 6379
      - to: "consul"
        port: 8500