version: '3.8'

services:
  # Heuristic Service - Human vs Bot detection
  heuristic-service:
    build:
      context: ./heuristic-service
      dockerfile: Dockerfile
    container_name: pca-heuristic-service
    ports:
      - "8085:8085"
    environment:
      - PORT=8085
      - GIN_MODE=release
      - CONFIG_PATH=/app/ai-access.json
      - REDIS_URL=redis://redis:6379
    volumes:
      - ./ai-access.json:/app/ai-access.json:ro
    depends_on:
      - redis
    networks:
      - pca-network
    healthcheck:
      test: ["CMD", "wget", "-q", "--spider", "http://localhost:8085/health"]
      interval: 30s
      timeout: 10s
      retries: 3

  # Payment Gateway - HTTP 402 Handler (future)
  # payment-gateway:
  #   build:
  #     context: ./payment-gateway
  #     dockerfile: Dockerfile
  #   container_name: pca-payment-gateway
  #   ports:
  #     - "8086:8086"
  #   environment:
  #     - PORT=8086
  #     - HEURISTIC_SERVICE_URL=http://heuristic-service:8085
  #   depends_on:
  #     - heuristic-service
  #   networks:
  #     - pca-network

  # Redis for session storage
  redis:
    image: redis:7-alpine
    container_name: pca-redis
    ports:
      - "6380:6379"
    volumes:
      - pca-redis-data:/data
    networks:
      - pca-network
    healthcheck:
      test: ["CMD", "redis-cli", "ping"]
      interval: 10s
      timeout: 5s
      retries: 3

  # Demo website to test the SDK
  demo-site:
    image: nginx:alpine
    container_name: pca-demo-site
    ports:
      - "8087:80"
    volumes:
      - ./demo:/usr/share/nginx/html:ro
      - ./sdk/js/src:/usr/share/nginx/html/sdk:ro
      - ./ai-access.json:/usr/share/nginx/html/ai-access.json:ro
    depends_on:
      - heuristic-service
    networks:
      - pca-network

networks:
  pca-network:
    driver: bridge

volumes:
  pca-redis-data:
