# CRM Pro Georgia - Environment Variables Configuration
# Copy this file to .env and update with your actual values

# ============================================
# DATABASE CONFIGURATION (REQUIRED)
# ============================================
# PostgreSQL connection string
# Format: postgresql://username:password@host:port/database
DATABASE_URL=postgresql://crmuser:changeme@localhost:5432/crm_pro_georgia

# Database connection pool size (default: 20)
DB_POOL_SIZE=20

# Database connection timeout in milliseconds (default: 10000)
DB_TIMEOUT=10000

# PostgreSQL password (used by docker-compose)
POSTGRES_PASSWORD=changeme

# ============================================
# REDIS CONFIGURATION (REQUIRED)
# ============================================
# Redis connection URL for rate limiting and session management
# Format: redis://host:port
REDIS_URL=redis://localhost:6379

# ============================================
# AUTHENTICATION & SECURITY (REQUIRED)
# ============================================
# JWT secret key - MUST be set in production (minimum 32 characters, 64 recommended)
# Generate with: openssl rand -hex 32
# Server will FAIL to start if not set
JWT_SECRET=2d16b918ffc0ae12ea109ce17641b0bd58bce68f1aa7098a3a19cec9a3dde97e

# JWT token expiry (default: 1h)
JWT_EXPIRY=1h

# TOTP encryption key for 2FA secrets - MUST be exactly 64 hex characters (32 bytes)
# Generate with: openssl rand -hex 32
# Used to encrypt TOTP secrets at rest
TOTP_ENCRYPTION_KEY=8fcc1d9551be65cf346ff3f4bb7c2f43d33473a4d041fa520f44076f28972d6d

# ============================================
# RATE LIMITING & SECURITY
# ============================================
# Rate limit window in milliseconds (default: 60000 = 1 minute)
RATE_LIMIT_WINDOW_MS=60000

# Maximum requests per window (default: 200)
RATE_LIMIT_MAX_REQUESTS=200

# Brute force protection: max failed login attempts (default: 5)
BRUTE_FORCE_MAX_ATTEMPTS=5

# Brute force lockout duration in milliseconds (default: 900000 = 15 minutes)
BRUTE_FORCE_LOCKOUT_MS=900000

# ============================================
# APPLICATION CONFIGURATION
# ============================================
# Node environment (development | production | test)
NODE_ENV=production

# Backend server port (default: 3001)
PORT=3001

# CORS allowed origins (comma-separated for multiple)
# Examples:
#   Development: http://localhost:3000
#   Production: https://crm.example.com,https://www.crm.example.com
CORS_ORIGINS=http://localhost:3000

# ============================================
# OBSERVABILITY & LOGGING
# ============================================
# Log level (error | warn | info | debug)
LOG_LEVEL=info

# OpenTelemetry collector endpoint (optional)
# Example: http://jaeger:4318/v1/traces
OTLP_ENDPOINT=

# Service name for tracing
SERVICE_NAME=crm-pro-georgia

# ============================================
# BACKUP CONFIGURATION
# ============================================
# Backup retention period in days (default: 30)
RETENTION_DAYS=30

# Backup directory path
BACKUP_DIR=/var/backups/crm-pro-georgia

# ============================================
# MULTI-TENANCY (Future)
# ============================================
# Default tenant ID for single-tenant deployments
DEFAULT_TENANT_ID=default

# ============================================
# DEVELOPMENT & TESTING
# ============================================
# Enable debug mode (development only)
DEBUG=false

# Auto-seed database with demo data (development only)
AUTO_SEED=false
