version: "3.9"
services:
  postgres:
    image: postgres:15
    environment:
      POSTGRES_USER: ${POSTGRES_USER}
      POSTGRES_PASSWORD: ${POSTGRES_PASSWORD}
      POSTGRES_DB: ${POSTGRES_DB}
    ports:
      - "${POSTGRES_PORT}:5432"
    volumes:
      - postgres_data:/var/lib/postgresql/data

  redis:
    image: redis:7
    ports:
      - "${REDIS_PORT}:6379"

  api:
    build: ./apps/api
    environment:
      NODE_ENV: development
      POSTGRES_HOST: postgres
      POSTGRES_PORT: 5432
      POSTGRES_USER: ${POSTGRES_USER}
      POSTGRES_PASSWORD: ${POSTGRES_PASSWORD}
      POSTGRES_DB: ${POSTGRES_DB}
      REDIS_HOST: redis
      REDIS_PORT: 6379
    ports:
      - "${API_PORT}:3000"
    depends_on:
      - postgres
      - redis

  web:
    build: ./apps/web
    environment:
      VITE_API_URL: http://localhost:${API_PORT}
    ports:
      - "${WEB_PORT}:5173"
    depends_on:
      - api

  ai:
    build: ./services/ai
    environment:
      PYTHONUNBUFFERED: 1
    ports:
      - "${AI_PORT}:8000"

volumes:
  postgres_data:
