# Essential Configuration - Only these variables are required for basic setup
# Authentication token for all interfaces (REST API, MCP server, Web UI)
AUTH_TOKEN=your-secret-token-here
# Database password (required for security)
DB_PASSWORD=your-database-password-here
# Optional Configuration - Uncomment and modify if needed
# Application settings
# PORT=5000
# NODE_ENV=production
# MCP_SERVER_ENABLED=true
# Base path/URL for nginx subpath deployment
#
# Runtime Configuration Support:
# The application supports runtime base path configuration, allowing the same built
# frontend assets to work with different deployment paths without rebuilding.
#
# Configuration Options:
# - BASE_URL: Full URL including protocol and domain (e.g., "https://example.com/md")
# When set, the path portion is extracted and used as the base path
# - BASE_PATH: Path-only configuration (e.g., "/md", "md", "/app/articles")
# BASE_URL takes precedence if both are set
#
# Path Normalization:
# - Leading slash is automatically added if missing
# - Trailing slash is automatically removed
# - Invalid characters are rejected with fallback to root path
# - Empty or unset values default to root path ("/") deployment
#
# Docker Container Support:
# These variables can be set in docker-compose.yml environment section
# or passed as environment variables when running containers
#
# Examples:
# BASE_URL=https://example.com/md # Full URL (path "/md" extracted)
# BASE_PATH=/md # Path only
# BASE_PATH=articles # Normalized to "/articles"
# BASE_PATH=/app/docs/ # Normalized to "/app/docs"
#
# Leave empty or unset for root path deployment:
# BASE_URL=
# BASE_PATH=
# Database settings (defaults work for most setups)
# DB_HOST=localhost
# DB_PORT=5432
# DB_NAME=article_manager
# DB_USER=article_user
# DB_SSL=false
# Semantic search (disabled by default)
# SEMANTIC_SEARCH_ENABLED=false
# EMBEDDING_PROVIDER=ollama
# EMBEDDING_MODEL=nomic-embed-text
# OLLAMA_BASE_URL=http://host.docker.internal:11434
# OPENAI_API_KEY=
# MCP_MULTI_SEARCH_LIMIT=10
# MCP SSE Headers Timeout (milliseconds)
# Timeout waiting for response headers before failing an SSE stream connection.
# Default: 30000 (30 seconds)
# MCP_SSE_HEADERS_TIMEOUT_MS=30000
# MCP Session Management
# Session idle timeout before cleanup (milliseconds)
# Default: 900000 (15 minutes)
# MCP_SESSION_IDLE_MS=900000
# Maximum session lifetime regardless of activity (milliseconds)
# Default: 3600000 (1 hour)
# MCP_SESSION_TTL_MS=3600000
# Maximum total active sessions across all clients
# Default: 200
# MCP_MAX_SESSIONS_TOTAL=200
# Maximum sessions per IP address (DoS protection)
# Default: 50
# MCP_MAX_SESSIONS_PER_IP=50
# Maximum sessions per authentication token
# Default: 100
# MCP_MAX_SESSIONS_PER_TOKEN=100
# Bind sessions to originating IP address (enhanced security)
# Warning: Do not enable behind NAT or load balancers
# Default: false
# MCP_BIND_SESSION_TO_IP=false
# MCP Rate Limiting (DoS Protection)
# Rate limit time window (milliseconds)
# Default: 60000 (1 minute)
# MCP_RATE_LIMIT_WINDOW_MS=60000
# Maximum requests per session per time window
# Default: 100
# MCP_RATE_LIMIT_MAX_REQUESTS=100
# Maximum request body size (bytes)
# Default: 10485760 (10MB)
# MCP_MAX_REQUEST_SIZE_BYTES=10485760
# API Rate Limiting (DoS Protection)
# Rate limit time window for API endpoints (milliseconds)
# Default: 60000 (1 minute)
# API_RATE_LIMIT_WINDOW_MS=60000
# Maximum requests per IP per time window for general API endpoints
# Default: 60
# API_RATE_LIMIT_MAX_REQUESTS=60
# Maximum requests per IP per time window for expensive operations (reindex)
# Default: 5
# API_RATE_LIMIT_EXPENSIVE_MAX_REQUESTS=5
# Maximum requests per IP per time window for public endpoints
# Default: 30
# API_RATE_LIMIT_PUBLIC_MAX_REQUESTS=30
# API Request Size Limits
# Maximum request body size for API endpoints (bytes)
# Default: 10485760 (10MB - matches MCP limit)
# API_MAX_REQUEST_SIZE_BYTES=10485760
# Background embedding queue configuration
# EMBEDDING_QUEUE_ENABLED=true
# EMBEDDING_QUEUE_WORKER_INTERVAL=5000
# EMBEDDING_QUEUE_MAX_RETRIES=3
# EMBEDDING_QUEUE_RETRY_BACKOFF_BASE=1000
# EMBEDDING_QUEUE_BATCH_SIZE=1
# EMBEDDING_QUEUE_CLEANUP_INTERVAL=24
# EMBEDDING_QUEUE_CLEANUP_RETENTION_DAYS=30
# EMBEDDING_QUEUE_HEARTBEAT_INTERVAL=30000
# EMBEDDING_QUEUE_METRICS_INTERVAL=60000
# EMBEDDING_QUEUE_MAX_PROCESSING_TIME=1800000
# EMBEDDING_QUEUE_STUCK_TASK_CLEANUP_ENABLED=true
# Advanced Configuration - For production tuning and customization
# Database performance tuning
# DB_MAX_CONNECTIONS=100
# APP_DB_MAX_CONNECTIONS=20
# DB_IDLE_TIMEOUT=30000
# DB_CONNECTION_TIMEOUT=2000
# DB_SHARED_BUFFERS=256MB
# DB_EFFECTIVE_CACHE_SIZE=1GB
# Backup settings
# BACKUP_DIR=./backups
# RETENTION_DAYS=30
# COMPRESS_BACKUPS=true
# Container customization
# POSTGRES_IMAGE=pgvector/pgvector:pg16
# APP_IMAGE=ghcr.io/joelmnz/mcp-markdown-manager:latest
# RESTART_POLICY=unless-stopped
# Health check intervals
# HEALTH_CHECK_INTERVAL=10s
# APP_HEALTH_CHECK_INTERVAL=30s