version: 1

# Optional multi-service SUT topology template for Ogoron-owned UI testing.
#
# Use this file when a repository needs to describe:
# - multiple services
# - multiple runtime profiles (`local`, `ci`, `shared-env`, ...)
# - different execution modes per service (`shell`, `compose`, `external`, ...)
#
# Keep `test_execution.yml` thin.
# Let `test_execution.yml` call an orchestration layer that reads this topology.

defaults:
  startup_timeout_seconds: 90
  shutdown_timeout_seconds: 30
  healthcheck_timeout_seconds: 5

profiles:
  local:
    description: Developer workstation profile.
    service_modes:
      backend-a: shell
      backend-b: shell
      frontend-main: shell
      frontend-docs: shell
      frontend-public: shell

  ci:
    description: CI-oriented profile.
    service_modes:
      backend-a: compose
      backend-b: shell
      frontend-main: compose
      frontend-docs: compose
      frontend-public: compose

  shared-env:
    description: Reuse services that are already running elsewhere.
    service_modes:
      backend-a: external
      backend-b: external
      frontend-main: external
      frontend-docs: external
      frontend-public: external

services:
  backend-a:
    role: backend
    cwd: systems/backend-a
    depends_on: []

    modes:
      shell:
        start:
          cmd: ["./run-backend-a.sh"]
        stop:
          strategy: process_group
        healthcheck:
          type: http
          url: http://127.0.0.1:33141/health
        base_url: http://127.0.0.1:33141
        env_files:
          - ./.env.local

      compose:
        start:
          cmd: ["docker", "compose", "up", "-d", "backend-a"]
        stop:
          cmd: ["docker", "compose", "down"]
        healthcheck:
          type: http
          url: http://127.0.0.1:33141/health
        base_url: http://127.0.0.1:33141

      external:
        start:
          skip: true
        stop:
          skip: true
        healthcheck:
          type: http
          url: ${BACKEND_A_BASE_URL}/health
        base_url: ${BACKEND_A_BASE_URL}

  backend-b:
    role: backend
    cwd: systems/backend-b
    depends_on: [backend-a]

    modes:
      shell:
        start:
          cmd: ["python", "-m", "uvicorn", "src.main:app", "--host", "127.0.0.1", "--port", "33142"]
        stop:
          strategy: process_group
        healthcheck:
          type: http
          url: http://127.0.0.1:33142/healthz
        readiness:
          type: http
          url: http://127.0.0.1:33142/readyz
        base_url: http://127.0.0.1:33142
        env:
          FEATURE_FLAG_EXAMPLE: "1"

      external:
        start:
          skip: true
        stop:
          skip: true
        healthcheck:
          type: http
          url: ${BACKEND_B_BASE_URL}/healthz
        readiness:
          type: http
          url: ${BACKEND_B_BASE_URL}/readyz
        base_url: ${BACKEND_B_BASE_URL}

  frontend-main:
    role: frontend
    cwd: systems/frontend-main
    depends_on: [backend-a, backend-b]

    modes:
      shell:
        start:
          cmd: ["npm", "run", "dev", "--", "--host", "127.0.0.1", "--port", "33143"]
        stop:
          strategy: process_group
        healthcheck:
          type: http
          url: http://127.0.0.1:33143
        base_url: http://127.0.0.1:33143
        env:
          VITE_BACKEND_A_BASE_URL: http://127.0.0.1:33141
          VITE_BACKEND_B_BASE_URL: http://127.0.0.1:33142

      compose:
        start:
          cmd: ["docker", "compose", "up", "-d", "frontend-main"]
        stop:
          cmd: ["docker", "compose", "down"]
        healthcheck:
          type: http
          url: http://127.0.0.1:33143
        base_url: http://127.0.0.1:33143

      external:
        start:
          skip: true
        stop:
          skip: true
        healthcheck:
          type: http
          url: ${FRONTEND_MAIN_BASE_URL}
        base_url: ${FRONTEND_MAIN_BASE_URL}

  frontend-docs:
    role: frontend
    cwd: systems/frontend-docs
    depends_on: []

    modes:
      shell:
        start:
          cmd: ["npm", "run", "start", "--", "--port", "33144"]
        stop:
          strategy: process_group
        healthcheck:
          type: http
          url: http://127.0.0.1:33144
        base_url: http://127.0.0.1:33144

      compose:
        start:
          cmd: ["docker", "compose", "up", "-d", "frontend-docs"]
        stop:
          cmd: ["docker", "compose", "down"]
        healthcheck:
          type: http
          url: http://127.0.0.1:33144
        base_url: http://127.0.0.1:33144

      external:
        start:
          skip: true
        stop:
          skip: true
        healthcheck:
          type: http
          url: ${FRONTEND_DOCS_BASE_URL}
        base_url: ${FRONTEND_DOCS_BASE_URL}

  frontend-public:
    role: frontend
    cwd: systems/frontend-public
    depends_on: []

    modes:
      shell:
        start:
          cmd: ["npm", "run", "dev", "--", "--host", "127.0.0.1", "--port", "33145"]
        stop:
          strategy: process_group
        healthcheck:
          type: http
          url: http://127.0.0.1:33145
        base_url: http://127.0.0.1:33145

      compose:
        start:
          cmd: ["docker", "compose", "up", "-d", "frontend-public"]
        stop:
          cmd: ["docker", "compose", "down"]
        healthcheck:
          type: http
          url: http://127.0.0.1:33145
        base_url: http://127.0.0.1:33145

      external:
        start:
          skip: true
        stop:
          skip: true
        healthcheck:
          type: http
          url: ${FRONTEND_PUBLIC_BASE_URL}
        base_url: ${FRONTEND_PUBLIC_BASE_URL}

  shared-cdn:
    role: external_dependency
    cwd: .
    depends_on: []

    modes:
      external:
        start:
          skip: true
        stop:
          skip: true
        healthcheck:
          type: none
          reason: No dedicated readiness signal; availability is verified indirectly by consumer tests.
        base_url: ${SHARED_CDN_BASE_URL}
