server:
  port: 8080
  # Tomcat thread pool settings for high concurrency
  tomcat:
    threads:
      max: 500
      min-spare: 50
  # Allow large headers (for Telegram auth tokens)
  max-http-header-size: 20KB
  # Graceful shutdown for zero-downtime deployments
  shutdown: graceful

spring:
  application:
    name: honey-be
  lifecycle:
    timeout-per-shutdown-phase: 30s

  datasource:
    url: ${SPRING_DATASOURCE_URL:jdbc:mysql://localhost:3306/honey_db}
    username: ${SPRING_DATASOURCE_USERNAME:root}
    password: ${SPRING_DATASOURCE_PASSWORD:password}
    driver-class-name: com.mysql.cj.jdbc.Driver
    hikari:
      # Connection pool settings for high concurrency
      maximum-pool-size: 50
      minimum-idle: 20
      connection-timeout: 30000
      idle-timeout: 600000
      initialization-fail-timeout: -1

  jpa:
    hibernate:
      ddl-auto: validate
    show-sql: false
    properties:
      hibernate:
        format_sql: false
        dialect: org.hibernate.dialect.MySQLDialect

  flyway:
    enabled: true
    locations: classpath:db/migration
    baseline-on-migrate: true
    connect-retries: 20
    connect-retry-interval: 3000
    validate-on-migrate: false
    repair: true

telegram:
  bot-token: ${TELEGRAM_BOT_TOKEN}
  # Bot token for checking channel membership (separate from main bot token)
  channel-checker-bot-token: ${TELEGRAM_CHANNEL_CHECKER_BOT_TOKEN:}
  # Channel ID for follow tasks (e.g., "@honey_channel" or numeric ID)
  follow-task-channel-id: ${TELEGRAM_FOLLOW_TASK_CHANNEL_ID:@win_spin_news}
  follow-task-channel-id-2: ${TELEGRAM_FOLLOW_TASK_CHANNEL_ID_2:@win_spin_withdrawals}

app:
  session:
    # Maximum number of active sessions per user (multi-device support)
    max-active-per-user: ${APP_SESSION_MAX_ACTIVE_PER_USER:5}
    # Batch cleanup configuration
    cleanup:
      # Number of expired sessions to delete per batch
      batch-size: ${APP_SESSION_CLEANUP_BATCH_SIZE:5000}
      # Maximum number of batches to process per cleanup run
      max-batches-per-run: ${APP_SESSION_CLEANUP_MAX_BATCHES:20}

  data-cleanup:
    # Batch cleanup configuration for transactions and other data
    cleanup:
      # Number of records to delete per batch
      batch-size: ${APP_DATA_CLEANUP_BATCH_SIZE:5000}
      # Maximum number of batches to process per cleanup run
      max-batches-per-run: ${APP_DATA_CLEANUP_MAX_BATCHES:20}
      # Sleep time in milliseconds between batches
      batch-sleep-ms: ${APP_DATA_CLEANUP_BATCH_SLEEP_MS:500}

  avatar:
    # Storage path for avatar files (relative to app root or absolute path)
    # Railway: ephemeral filesystem (acceptable for testing)
    # Inferno: should be mounted as Docker volume (e.g., /data/avatars)
    storage-path: ${APP_AVATAR_STORAGE_PATH:./data/avatars}
    # Enable Spring ResourceHandler for avatar serving
    # Railway: Set ENABLE_SPRING_AVATAR_HANDLER=true (Spring Boot serves avatars)
    # VPS: Leave unset or false (Nginx serves avatars via location ^~ /avatars/)
    enable-spring-handler: ${ENABLE_SPRING_AVATAR_HANDLER:false}
    # Public base URL for avatar URLs (e.g., https://api.example.com)
    # If empty, will use server's base URL
    public-base-url: ${APP_AVATAR_PUBLIC_BASE_URL:}
    # Maximum avatar file size in bytes (default: 2MB)
    max-size-bytes: ${APP_AVATAR_MAX_SIZE_BYTES:2097152}
    # Maximum avatar dimension in pixels (default: 110x110)
    max-dimension: ${APP_AVATAR_MAX_DIMENSION:110}
    # Avatar URL cache TTL in minutes (default: 5 minutes)
    cache-ttl-minutes: ${APP_AVATAR_CACHE_TTL_MINUTES:5}

  # Token in path for open user-check API: GET /api/check_user/{token}/{telegramId}. Set on VPS only.
  check-user:
    token: ${APP_CHECK_USER_TOKEN:}
  # Token in path for 3rd party deposit webhook: POST /api/deposit_webhook/{token}. Body: user_id, usd_amount (bigint: 1_000_000 = 1 USD). Set on VPS only.
  deposit-webhook:
    token: ${APP_PASSIM_WEBHOOK_TOKEN:}
  # Token in path for Telegram webhook: POST /api/telegram/webhook/{token}. Set on VPS only; use same value when registering webhook URL with Telegram.
  telegram-webhook:
    token: ${APP_TELEGRAM_WEBHOOK_TOKEN:}
  # Token in path for notify broadcast: POST /api/notify_broadcast/{token} and POST /api/notify_broadcast/{token}/stop. Set on VPS only.
  notify-broadcast:
    token: ${APP_NOTIFY_BROADCAST_TOKEN:}

  # Crypto payment/payout API (deposit methods, etc.). Base URL and API key for https://spin-passim.tech/
  crypto-api:
    base-url: ${APP_CRYPTO_API_BASE_URL:https://spin-passim.tech/}
    api-key: ${APP_CRYPTO_API_KEY:}

  admin:
    jwt:
      # JWT secret key (MUST be at least 256 bits / 32 characters)
      # Generate a secure random string for production
      # Example: openssl rand -base64 32
      secret: ${APP_ADMIN_JWT_SECRET:change-this-to-a-secure-random-string-in-production-min-32-characters}
      # JWT expiration time in milliseconds (default: 24 hours)
      expiration: ${APP_ADMIN_JWT_EXPIRATION:86400000}
      chatwoot-integration-secret: ${CHATWOOT_INTEGRATION_SECRET:}

# GeoIP configuration
# Set GEOIP_DB_PATH environment variable to use external file (recommended for production)
# If not set, falls back to classpath:geoip/GeoLite2-Country.mmdb
geoip:
  db-path: ${GEOIP_DB_PATH:}

# OpenAPI / Swagger (public API only; admin endpoints excluded via OpenApiConfig)
springdoc:
  api-docs:
    path: /v3/api-docs
  swagger-ui:
    path: /swagger-ui.html
  default-consumes-media-type: application/json
  default-produces-media-type: application/json

# Logging configuration moved to logback-spring.xml
# To use external logback-spring.xml on VPS, set system property:
# -Dlogging.config=/path/to/logback-spring.xml
# Or environment variable: LOGGING_CONFIG=/path/to/logback-spring.xml

management:
  endpoints:
    web:
      exposure:
        include: health,info
      base-path: /actuator
  endpoint:
    health:
      show-details: when-authorized
      probes:
        enabled: true
      group:
        readiness:
          include: db,ping
        liveness:
          include: ping
  health:
    db:
      enabled: true
    diskspace:
      enabled: false
    ping:
      enabled: true

