# Project Specification for Mode B Example
# This file defines a provisioning configuration without relying on Cargo.toml

[project]
description = "Distributed microservice platform with event streaming"
name = "microservice-platform"
type = "Microservice"

[infrastructure]
# SSH configuration for remote deployments
ssh = true

  # Database configuration
  [[infrastructure.databases]]
  required = true
  type = "postgres"

  # Monitoring stack
  monitoring = ["prometheus", "grafana"]

  # Cloud provider options
  cloud_providers = ["aws", "gcp"]

  # Optional services
  cache_enabled = true

  # Domain Features - define what your service actually does

[features.api_gateway]
description = "REST API gateway with rate limiting"
enabled = true

  [[features.api_gateway.fields]]
  default = "0.0.0.0:8080"
  help = "Interface and port for API requests"
  name = "bind_address"
  prompt = "API Gateway bind address"
  required = true
  type = "Text"

  [[features.api_gateway.fields]]
  default = 100
  help = "Maximum requests per second per client"
  max = 10000
  min = 1
  name = "rate_limit"
  prompt = "Rate limit (requests/second)"
  type = "Number"

  [[features.api_gateway.fields]]
  default = 30
  max = 300
  min = 5
  name = "timeout_seconds"
  prompt = "Request timeout"
  type = "Number"

[features.event_streaming]
description = "Event-driven architecture with message queue"
enabled = true

  [[features.event_streaming.fields]]
  help = "Connection string for event broker"
  name = "broker_url"
  placeholder = "kafka://localhost:9092"
  prompt = "Message broker URL"
  required = true
  type = "Text"

  [[features.event_streaming.fields]]
  default = "microservice-platform"
  name = "consumer_group"
  prompt = "Consumer group ID"
  required = true
  type = "Text"

  [[features.event_streaming.fields]]
  default = 10
  max = 100
  min = 1
  name = "max_concurrent_consumers"
  prompt = "Max concurrent consumers"
  type = "Number"

[features.authentication]
description = "JWT-based authentication with role-based access"
enabled = true

  [[features.authentication.fields]]
  encryption_backend = "age"
  help = "Secret key for JWT token signing and verification"
  name = "jwt_secret"
  prompt = "JWT signing secret"
  required = true
  sensitive = true
  type = "Password"

  [[features.authentication.fields]]
  default = 24
  max = 720
  min = 1
  name = "jwt_expiry_hours"
  prompt = "JWT token expiry (hours)"
  type = "Number"

  [[features.authentication.fields]]
  default = true
  help = "Enable token refresh mechanism"
  name = "allow_refresh_tokens"
  prompt = "Allow token refresh?"
  type = "Confirm"

[features.observability]
description = "Comprehensive logging and tracing"
enabled = true

  [[features.observability.fields]]
  default = "info"
  name = "log_level"
  options = ["trace", "debug", "info", "warn", "error"]
  prompt = "Log level"
  type = "Select"

  [[features.observability.fields]]
  default = true
  name = "enable_distributed_tracing"
  prompt = "Enable distributed tracing?"
  type = "Confirm"

  [[features.observability.fields]]
  default = 0.1
  help = "Percentage of requests to trace (0.0-1.0)"
  max = 1.0
  min = 0.0
  name = "trace_sample_rate"
  prompt = "Trace sampling rate (0.0-1.0)"
  type = "Number"

[features.database_migrations]
description = "Database schema and migration management"
enabled = true

  [[features.database_migrations.fields]]
  default = "./migrations"
  help = "Path to SQL migration files"
  name = "migration_directory"
  prompt = "Migrations directory"
  type = "Text"

  [[features.database_migrations.fields]]
  default = false
  help = "Automatically run pending migrations when service starts"
  name = "auto_migrate_on_startup"
  prompt = "Auto-migrate on startup?"
  type = "Confirm"

  # Constraints - single source of truth for validation bounds

[constraints.api_gateway.bind_address]
max_length = 50
min_length = 3

[constraints.api_gateway.rate_limit]
max = 10000
min = 1

[constraints.event_streaming.consumer_group]
max_length = 100
min_length = 1

[constraints.authentication.jwt_secret]
max_length = 256
min_length = 32

[constraints.observability.trace_sample_rate]
max = 1.0
min = 0.0

[constraints.database_migrations.migration_directory]
max_length = 255
min_length = 1
