Improve base config
This commit is contained in:
@@ -1,47 +1,56 @@
|
||||
# ================================================================
|
||||
# AUTH SERVICE CONFIGURATION
|
||||
# services/auth/app/core/config.py
|
||||
# ================================================================
|
||||
|
||||
"""
|
||||
Authentication service configuration
|
||||
User management and JWT token handling
|
||||
"""
|
||||
|
||||
from shared.config.base import BaseServiceSettings
|
||||
import os
|
||||
from pydantic_settings import BaseSettings
|
||||
|
||||
class Settings(BaseSettings):
|
||||
"""Application settings"""
|
||||
class AuthSettings(BaseServiceSettings):
|
||||
"""Auth service specific settings"""
|
||||
|
||||
# Basic settings
|
||||
# Service Identity
|
||||
APP_NAME: str = "Authentication Service"
|
||||
VERSION: str = "1.0.0"
|
||||
DEBUG: bool = os.getenv("DEBUG", "False").lower() == "true"
|
||||
LOG_LEVEL: str = os.getenv("LOG_LEVEL", "INFO")
|
||||
SERVICE_NAME: str = "auth-service"
|
||||
DESCRIPTION: str = "User authentication and authorization service"
|
||||
|
||||
# Database settings
|
||||
DATABASE_URL: str = os.getenv("DATABASE_URL", "postgresql+asyncpg://auth_user:auth_pass123@auth-db:5432/auth_db")
|
||||
# Database Configuration
|
||||
DATABASE_URL: str = os.getenv("AUTH_DATABASE_URL",
|
||||
"postgresql+asyncpg://auth_user:auth_pass123@auth-db:5432/auth_db")
|
||||
|
||||
# Redis settings
|
||||
REDIS_URL: str = os.getenv("REDIS_URL", "redis://redis:6379/0")
|
||||
# Redis Database (dedicated for auth)
|
||||
REDIS_DB: int = 0
|
||||
|
||||
# JWT settings
|
||||
JWT_SECRET_KEY: str = os.getenv("JWT_SECRET_KEY", "your-super-secret-jwt-key-change-in-production")
|
||||
JWT_ALGORITHM: str = os.getenv("JWT_ALGORITHM", "HS256")
|
||||
JWT_ACCESS_TOKEN_EXPIRE_MINUTES: int = int(os.getenv("JWT_ACCESS_TOKEN_EXPIRE_MINUTES", "30"))
|
||||
JWT_REFRESH_TOKEN_EXPIRE_DAYS: int = int(os.getenv("JWT_REFRESH_TOKEN_EXPIRE_DAYS", "7"))
|
||||
|
||||
# Password settings
|
||||
# Enhanced Password Requirements for Spain
|
||||
PASSWORD_MIN_LENGTH: int = 8
|
||||
PASSWORD_REQUIRE_UPPERCASE: bool = True
|
||||
PASSWORD_REQUIRE_LOWERCASE: bool = True
|
||||
PASSWORD_REQUIRE_NUMBERS: bool = True
|
||||
PASSWORD_REQUIRE_SYMBOLS: bool = False
|
||||
|
||||
# Security settings
|
||||
BCRYPT_ROUNDS: int = 12
|
||||
# Spanish GDPR Compliance
|
||||
GDPR_COMPLIANCE_ENABLED: bool = True
|
||||
DATA_RETENTION_DAYS: int = int(os.getenv("AUTH_DATA_RETENTION_DAYS", "365"))
|
||||
CONSENT_REQUIRED: bool = True
|
||||
PRIVACY_POLICY_URL: str = os.getenv("PRIVACY_POLICY_URL", "/privacy")
|
||||
|
||||
# Account Security
|
||||
ACCOUNT_LOCKOUT_ENABLED: bool = True
|
||||
MAX_LOGIN_ATTEMPTS: int = 5
|
||||
LOCKOUT_DURATION_MINUTES: int = 30
|
||||
PASSWORD_HISTORY_COUNT: int = 5
|
||||
|
||||
# RabbitMQ settings
|
||||
RABBITMQ_URL: str = os.getenv("RABBITMQ_URL", "amqp://bakery:forecast123@rabbitmq:5672/")
|
||||
# Session Management
|
||||
SESSION_TIMEOUT_MINUTES: int = int(os.getenv("SESSION_TIMEOUT_MINUTES", "60"))
|
||||
CONCURRENT_SESSIONS_LIMIT: int = int(os.getenv("CONCURRENT_SESSIONS_LIMIT", "3"))
|
||||
|
||||
class Config:
|
||||
env_file = ".env"
|
||||
# Email Verification
|
||||
EMAIL_VERIFICATION_REQUIRED: bool = os.getenv("EMAIL_VERIFICATION_REQUIRED", "true").lower() == "true"
|
||||
EMAIL_VERIFICATION_EXPIRE_HOURS: int = int(os.getenv("EMAIL_VERIFICATION_EXPIRE_HOURS", "24"))
|
||||
|
||||
settings = Settings()
|
||||
settings = AuthSettings()
|
||||
|
||||
@@ -1,37 +1,68 @@
|
||||
"""Data service configuration"""
|
||||
# ================================================================
|
||||
# DATA SERVICE CONFIGURATION
|
||||
# services/data/app/core/config.py
|
||||
# ================================================================
|
||||
|
||||
from pydantic_settings import BaseSettings
|
||||
from typing import List
|
||||
"""
|
||||
Data service configuration
|
||||
External data integration and management
|
||||
"""
|
||||
|
||||
class Settings(BaseSettings):
|
||||
# Database
|
||||
DATABASE_URL: str = "postgresql+asyncpg://data_user:data_pass123@data-db:5432/data_db"
|
||||
from shared.config.base import BaseServiceSettings
|
||||
import os
|
||||
|
||||
class DataSettings(BaseServiceSettings):
|
||||
"""Data service specific settings"""
|
||||
|
||||
# Redis
|
||||
REDIS_URL: str = "redis://redis:6379/3"
|
||||
|
||||
# RabbitMQ
|
||||
RABBITMQ_URL: str = "amqp://bakery:forecast123@rabbitmq:5672/"
|
||||
|
||||
# External APIs
|
||||
AEMET_API_KEY: str = "your-aemet-api-key-here"
|
||||
MADRID_OPENDATA_API_KEY: str = "your-madrid-opendata-key-here"
|
||||
|
||||
# Service settings
|
||||
# Service Identity
|
||||
APP_NAME: str = "Data Service"
|
||||
SERVICE_NAME: str = "data-service"
|
||||
SERVICE_VERSION: str = "1.0.0"
|
||||
DESCRIPTION: str = "External data integration and management service"
|
||||
|
||||
# Auth
|
||||
AUTH_SERVICE_URL: str = "http://auth-service:8000"
|
||||
# Database Configuration
|
||||
DATABASE_URL: str = os.getenv("DATA_DATABASE_URL",
|
||||
"postgresql+asyncpg://data_user:data_pass123@data-db:5432/data_db")
|
||||
|
||||
# CORS
|
||||
CORS_ORIGINS: List[str] = ["http://localhost:3000", "http://localhost:3001"]
|
||||
# Redis Database (dedicated for external data cache)
|
||||
REDIS_DB: int = 3
|
||||
|
||||
# Monitoring
|
||||
LOG_LEVEL: str = "INFO"
|
||||
ENABLE_METRICS: bool = True
|
||||
# External API Configuration
|
||||
AEMET_API_KEY: str = os.getenv("AEMET_API_KEY", "")
|
||||
AEMET_BASE_URL: str = "https://opendata.aemet.es/opendata"
|
||||
AEMET_TIMEOUT: int = int(os.getenv("AEMET_TIMEOUT", "30"))
|
||||
AEMET_RETRY_ATTEMPTS: int = int(os.getenv("AEMET_RETRY_ATTEMPTS", "3"))
|
||||
|
||||
class Config:
|
||||
env_file = ".env"
|
||||
MADRID_OPENDATA_API_KEY: str = os.getenv("MADRID_OPENDATA_API_KEY", "")
|
||||
MADRID_OPENDATA_BASE_URL: str = "https://datos.madrid.es"
|
||||
MADRID_OPENDATA_TIMEOUT: int = int(os.getenv("MADRID_OPENDATA_TIMEOUT", "30"))
|
||||
|
||||
# Data Collection Configuration
|
||||
WEATHER_COLLECTION_INTERVAL_HOURS: int = int(os.getenv("WEATHER_COLLECTION_INTERVAL_HOURS", "1"))
|
||||
TRAFFIC_COLLECTION_INTERVAL_HOURS: int = int(os.getenv("TRAFFIC_COLLECTION_INTERVAL_HOURS", "1"))
|
||||
EVENTS_COLLECTION_INTERVAL_HOURS: int = int(os.getenv("EVENTS_COLLECTION_INTERVAL_HOURS", "6"))
|
||||
|
||||
# Cache TTL Configuration
|
||||
WEATHER_CACHE_TTL_HOURS: int = int(os.getenv("WEATHER_CACHE_TTL_HOURS", "1"))
|
||||
TRAFFIC_CACHE_TTL_HOURS: int = int(os.getenv("TRAFFIC_CACHE_TTL_HOURS", "1"))
|
||||
EVENTS_CACHE_TTL_HOURS: int = int(os.getenv("EVENTS_CACHE_TTL_HOURS", "6"))
|
||||
|
||||
# Data Quality Configuration
|
||||
DATA_VALIDATION_ENABLED: bool = os.getenv("DATA_VALIDATION_ENABLED", "true").lower() == "true"
|
||||
OUTLIER_DETECTION_ENABLED: bool = os.getenv("OUTLIER_DETECTION_ENABLED", "true").lower() == "true"
|
||||
DATA_COMPLETENESS_THRESHOLD: float = float(os.getenv("DATA_COMPLETENESS_THRESHOLD", "0.8"))
|
||||
|
||||
# Geolocation Settings (Madrid focus)
|
||||
DEFAULT_LATITUDE: float = float(os.getenv("DEFAULT_LATITUDE", "40.4168")) # Madrid
|
||||
DEFAULT_LONGITUDE: float = float(os.getenv("DEFAULT_LONGITUDE", "-3.7038")) # Madrid
|
||||
LOCATION_RADIUS_KM: float = float(os.getenv("LOCATION_RADIUS_KM", "50.0"))
|
||||
|
||||
# Data Retention
|
||||
RAW_DATA_RETENTION_DAYS: int = int(os.getenv("RAW_DATA_RETENTION_DAYS", "90"))
|
||||
PROCESSED_DATA_RETENTION_DAYS: int = int(os.getenv("PROCESSED_DATA_RETENTION_DAYS", "365"))
|
||||
|
||||
# Batch Processing
|
||||
BATCH_PROCESSING_ENABLED: bool = os.getenv("BATCH_PROCESSING_ENABLED", "true").lower() == "true"
|
||||
BATCH_SIZE: int = int(os.getenv("BATCH_SIZE", "1000"))
|
||||
PARALLEL_PROCESSING_WORKERS: int = int(os.getenv("PARALLEL_PROCESSING_WORKERS", "4"))
|
||||
|
||||
settings = Settings()
|
||||
settings = DataSettings()
|
||||
@@ -1,32 +1,59 @@
|
||||
# ================================================================
|
||||
# FORECASTING SERVICE CONFIGURATION
|
||||
# services/forecasting/app/core/config.py
|
||||
# ================================================================
|
||||
|
||||
"""
|
||||
uLuforecasting service configuration
|
||||
Forecasting service configuration
|
||||
Demand prediction and forecasting
|
||||
"""
|
||||
|
||||
from shared.config.base import BaseServiceSettings
|
||||
import os
|
||||
from pydantic_settings import BaseSettings
|
||||
|
||||
class Settings(BaseSettings):
|
||||
"""Application settings"""
|
||||
class ForecastingSettings(BaseServiceSettings):
|
||||
"""Forecasting service specific settings"""
|
||||
|
||||
# Basic settings
|
||||
APP_NAME: str = "uLuforecasting Service"
|
||||
VERSION: str = "1.0.0"
|
||||
DEBUG: bool = os.getenv("DEBUG", "False").lower() == "true"
|
||||
LOG_LEVEL: str = os.getenv("LOG_LEVEL", "INFO")
|
||||
# Service Identity
|
||||
APP_NAME: str = "Forecasting Service"
|
||||
SERVICE_NAME: str = "forecasting-service"
|
||||
DESCRIPTION: str = "Demand prediction and forecasting service"
|
||||
|
||||
# Database settings
|
||||
DATABASE_URL: str = os.getenv("DATABASE_URL", "postgresql+asyncpg://forecasting_user:forecasting_pass123@forecasting-db:5432/forecasting_db")
|
||||
# Database Configuration
|
||||
DATABASE_URL: str = os.getenv("FORECASTING_DATABASE_URL",
|
||||
"postgresql+asyncpg://forecasting_user:forecasting_pass123@forecasting-db:5432/forecasting_db")
|
||||
|
||||
# Redis settings
|
||||
REDIS_URL: str = os.getenv("REDIS_URL", "redis://redis:6379/0")
|
||||
# Redis Database (dedicated for prediction cache)
|
||||
REDIS_DB: int = 2
|
||||
|
||||
# RabbitMQ settings
|
||||
RABBITMQ_URL: str = os.getenv("RABBITMQ_URL", "amqp://bakery:forecast123@rabbitmq:5672/")
|
||||
# Prediction Configuration
|
||||
MAX_FORECAST_DAYS: int = int(os.getenv("MAX_FORECAST_DAYS", "30"))
|
||||
MIN_HISTORICAL_DAYS: int = int(os.getenv("MIN_HISTORICAL_DAYS", "60"))
|
||||
PREDICTION_CONFIDENCE_THRESHOLD: float = float(os.getenv("PREDICTION_CONFIDENCE_THRESHOLD", "0.8"))
|
||||
|
||||
# Service URLs
|
||||
AUTH_SERVICE_URL: str = os.getenv("AUTH_SERVICE_URL", "http://auth-service:8000")
|
||||
# Caching Configuration
|
||||
PREDICTION_CACHE_TTL_HOURS: int = int(os.getenv("PREDICTION_CACHE_TTL_HOURS", "6"))
|
||||
FORECAST_BATCH_SIZE: int = int(os.getenv("FORECAST_BATCH_SIZE", "100"))
|
||||
|
||||
class Config:
|
||||
env_file = ".env"
|
||||
# Real-time Forecasting
|
||||
REALTIME_FORECASTING_ENABLED: bool = os.getenv("REALTIME_FORECASTING_ENABLED", "true").lower() == "true"
|
||||
FORECAST_UPDATE_INTERVAL_HOURS: int = int(os.getenv("FORECAST_UPDATE_INTERVAL_HOURS", "6"))
|
||||
|
||||
# Business Rules for Spanish Bakeries
|
||||
BUSINESS_HOUR_START: int = 7 # 7 AM
|
||||
BUSINESS_HOUR_END: int = 20 # 8 PM
|
||||
WEEKEND_ADJUSTMENT_FACTOR: float = float(os.getenv("WEEKEND_ADJUSTMENT_FACTOR", "0.8"))
|
||||
HOLIDAY_ADJUSTMENT_FACTOR: float = float(os.getenv("HOLIDAY_ADJUSTMENT_FACTOR", "0.5"))
|
||||
|
||||
# Weather Impact Modeling
|
||||
WEATHER_IMPACT_ENABLED: bool = os.getenv("WEATHER_IMPACT_ENABLED", "true").lower() == "true"
|
||||
TEMPERATURE_THRESHOLD_COLD: float = float(os.getenv("TEMPERATURE_THRESHOLD_COLD", "10.0"))
|
||||
TEMPERATURE_THRESHOLD_HOT: float = float(os.getenv("TEMPERATURE_THRESHOLD_HOT", "30.0"))
|
||||
RAIN_IMPACT_FACTOR: float = float(os.getenv("RAIN_IMPACT_FACTOR", "0.7"))
|
||||
|
||||
# Alert Thresholds
|
||||
HIGH_DEMAND_THRESHOLD: float = float(os.getenv("HIGH_DEMAND_THRESHOLD", "1.5"))
|
||||
LOW_DEMAND_THRESHOLD: float = float(os.getenv("LOW_DEMAND_THRESHOLD", "0.5"))
|
||||
STOCKOUT_RISK_THRESHOLD: float = float(os.getenv("STOCKOUT_RISK_THRESHOLD", "0.9"))
|
||||
|
||||
settings = Settings()
|
||||
settings = ForecastingSettings()
|
||||
|
||||
@@ -1,32 +1,83 @@
|
||||
# ================================================================
|
||||
# NOTIFICATION SERVICE CONFIGURATION
|
||||
# services/notification/app/core/config.py
|
||||
# ================================================================
|
||||
|
||||
"""
|
||||
uLunotification service configuration
|
||||
Notification service configuration
|
||||
Email and WhatsApp notification handling
|
||||
"""
|
||||
|
||||
from shared.config.base import BaseServiceSettings
|
||||
import os
|
||||
from pydantic_settings import BaseSettings
|
||||
|
||||
class Settings(BaseSettings):
|
||||
"""Application settings"""
|
||||
class NotificationSettings(BaseServiceSettings):
|
||||
"""Notification service specific settings"""
|
||||
|
||||
# Basic settings
|
||||
APP_NAME: str = "uLunotification Service"
|
||||
VERSION: str = "1.0.0"
|
||||
DEBUG: bool = os.getenv("DEBUG", "False").lower() == "true"
|
||||
LOG_LEVEL: str = os.getenv("LOG_LEVEL", "INFO")
|
||||
# Service Identity
|
||||
APP_NAME: str = "Notification Service"
|
||||
SERVICE_NAME: str = "notification-service"
|
||||
DESCRIPTION: str = "Email and WhatsApp notification service"
|
||||
|
||||
# Database settings
|
||||
DATABASE_URL: str = os.getenv("DATABASE_URL", "postgresql+asyncpg://notification_user:notification_pass123@notification-db:5432/notification_db")
|
||||
# Database Configuration
|
||||
DATABASE_URL: str = os.getenv("NOTIFICATION_DATABASE_URL",
|
||||
"postgresql+asyncpg://notification_user:notification_pass123@notification-db:5432/notification_db")
|
||||
|
||||
# Redis settings
|
||||
REDIS_URL: str = os.getenv("REDIS_URL", "redis://redis:6379/0")
|
||||
# Redis Database (dedicated for notification queue)
|
||||
REDIS_DB: int = 5
|
||||
|
||||
# RabbitMQ settings
|
||||
RABBITMQ_URL: str = os.getenv("RABBITMQ_URL", "amqp://bakery:forecast123@rabbitmq:5672/")
|
||||
# Email Configuration
|
||||
SMTP_HOST: str = os.getenv("SMTP_HOST", "smtp.gmail.com")
|
||||
SMTP_PORT: int = int(os.getenv("SMTP_PORT", "587"))
|
||||
SMTP_USER: str = os.getenv("SMTP_USER", "")
|
||||
SMTP_PASSWORD: str = os.getenv("SMTP_PASSWORD", "")
|
||||
SMTP_TLS: bool = os.getenv("SMTP_TLS", "true").lower() == "true"
|
||||
SMTP_SSL: bool = os.getenv("SMTP_SSL", "false").lower() == "true"
|
||||
|
||||
# Service URLs
|
||||
AUTH_SERVICE_URL: str = os.getenv("AUTH_SERVICE_URL", "http://auth-service:8000")
|
||||
# Email Settings
|
||||
DEFAULT_FROM_EMAIL: str = os.getenv("DEFAULT_FROM_EMAIL", "noreply@bakeryforecast.es")
|
||||
DEFAULT_FROM_NAME: str = os.getenv("DEFAULT_FROM_NAME", "Bakery Forecast")
|
||||
EMAIL_TEMPLATES_PATH: str = os.getenv("EMAIL_TEMPLATES_PATH", "/app/templates/email")
|
||||
|
||||
class Config:
|
||||
env_file = ".env"
|
||||
# WhatsApp Configuration
|
||||
WHATSAPP_API_KEY: str = os.getenv("WHATSAPP_API_KEY", "")
|
||||
WHATSAPP_BASE_URL: str = os.getenv("WHATSAPP_BASE_URL", "https://api.twilio.com")
|
||||
WHATSAPP_FROM_NUMBER: str = os.getenv("WHATSAPP_FROM_NUMBER", "")
|
||||
WHATSAPP_TEMPLATES_PATH: str = os.getenv("WHATSAPP_TEMPLATES_PATH", "/app/templates/whatsapp")
|
||||
|
||||
# Notification Queuing
|
||||
MAX_RETRY_ATTEMPTS: int = int(os.getenv("MAX_RETRY_ATTEMPTS", "3"))
|
||||
RETRY_DELAY_SECONDS: int = int(os.getenv("RETRY_DELAY_SECONDS", "60"))
|
||||
BATCH_SIZE: int = int(os.getenv("NOTIFICATION_BATCH_SIZE", "100"))
|
||||
|
||||
# Rate Limiting
|
||||
EMAIL_RATE_LIMIT_PER_HOUR: int = int(os.getenv("EMAIL_RATE_LIMIT_PER_HOUR", "1000"))
|
||||
WHATSAPP_RATE_LIMIT_PER_HOUR: int = int(os.getenv("WHATSAPP_RATE_LIMIT_PER_HOUR", "100"))
|
||||
|
||||
# Spanish Localization
|
||||
DEFAULT_LANGUAGE: str = os.getenv("DEFAULT_LANGUAGE", "es")
|
||||
TIMEZONE: str = "Europe/Madrid"
|
||||
DATE_FORMAT: str = "%d/%m/%Y"
|
||||
TIME_FORMAT: str = "%H:%M"
|
||||
|
||||
# Notification Types
|
||||
ENABLE_EMAIL_NOTIFICATIONS: bool = os.getenv("ENABLE_EMAIL_NOTIFICATIONS", "true").lower() == "true"
|
||||
ENABLE_WHATSAPP_NOTIFICATIONS: bool = os.getenv("ENABLE_WHATSAPP_NOTIFICATIONS", "true").lower() == "true"
|
||||
ENABLE_PUSH_NOTIFICATIONS: bool = os.getenv("ENABLE_PUSH_NOTIFICATIONS", "false").lower() == "true"
|
||||
|
||||
# Template Categories
|
||||
ALERT_TEMPLATES_ENABLED: bool = True
|
||||
MARKETING_TEMPLATES_ENABLED: bool = os.getenv("MARKETING_TEMPLATES_ENABLED", "false").lower() == "true"
|
||||
TRANSACTIONAL_TEMPLATES_ENABLED: bool = True
|
||||
|
||||
# Delivery Configuration
|
||||
IMMEDIATE_DELIVERY: bool = os.getenv("IMMEDIATE_DELIVERY", "true").lower() == "true"
|
||||
SCHEDULED_DELIVERY_ENABLED: bool = os.getenv("SCHEDULED_DELIVERY_ENABLED", "true").lower() == "true"
|
||||
BULK_DELIVERY_ENABLED: bool = os.getenv("BULK_DELIVERY_ENABLED", "true").lower() == "true"
|
||||
|
||||
# Analytics
|
||||
DELIVERY_TRACKING_ENABLED: bool = os.getenv("DELIVERY_TRACKING_ENABLED", "true").lower() == "true"
|
||||
OPEN_TRACKING_ENABLED: bool = os.getenv("OPEN_TRACKING_ENABLED", "true").lower() == "true"
|
||||
CLICK_TRACKING_ENABLED: bool = os.getenv("CLICK_TRACKING_ENABLED", "true").lower() == "true"
|
||||
|
||||
settings = Settings()
|
||||
settings = NotificationSettings()
|
||||
@@ -1,32 +1,70 @@
|
||||
# ================================================================
|
||||
# TENANT SERVICE CONFIGURATION
|
||||
# services/tenant/app/core/config.py
|
||||
# ================================================================
|
||||
|
||||
"""
|
||||
uLutenant service configuration
|
||||
Tenant service configuration
|
||||
Multi-tenant management and subscription handling
|
||||
"""
|
||||
|
||||
from shared.config.base import BaseServiceSettings
|
||||
import os
|
||||
from pydantic_settings import BaseSettings
|
||||
|
||||
class Settings(BaseSettings):
|
||||
"""Application settings"""
|
||||
class TenantSettings(BaseServiceSettings):
|
||||
"""Tenant service specific settings"""
|
||||
|
||||
# Basic settings
|
||||
APP_NAME: str = "uLutenant Service"
|
||||
VERSION: str = "1.0.0"
|
||||
DEBUG: bool = os.getenv("DEBUG", "False").lower() == "true"
|
||||
LOG_LEVEL: str = os.getenv("LOG_LEVEL", "INFO")
|
||||
# Service Identity
|
||||
APP_NAME: str = "Tenant Service"
|
||||
SERVICE_NAME: str = "tenant-service"
|
||||
DESCRIPTION: str = "Multi-tenant management and subscription service"
|
||||
|
||||
# Database settings
|
||||
DATABASE_URL: str = os.getenv("DATABASE_URL", "postgresql+asyncpg://tenant_user:tenant_pass123@tenant-db:5432/tenant_db")
|
||||
# Database Configuration
|
||||
DATABASE_URL: str = os.getenv("TENANT_DATABASE_URL",
|
||||
"postgresql+asyncpg://tenant_user:tenant_pass123@tenant-db:5432/tenant_db")
|
||||
|
||||
# Redis settings
|
||||
REDIS_URL: str = os.getenv("REDIS_URL", "redis://redis:6379/0")
|
||||
# Redis Database (dedicated for tenant data)
|
||||
REDIS_DB: int = 4
|
||||
|
||||
# RabbitMQ settings
|
||||
RABBITMQ_URL: str = os.getenv("RABBITMQ_URL", "amqp://bakery:forecast123@rabbitmq:5672/")
|
||||
# Subscription Plans
|
||||
DEFAULT_PLAN: str = os.getenv("DEFAULT_PLAN", "basic")
|
||||
TRIAL_PERIOD_DAYS: int = int(os.getenv("TRIAL_PERIOD_DAYS", "14"))
|
||||
|
||||
# Service URLs
|
||||
AUTH_SERVICE_URL: str = os.getenv("AUTH_SERVICE_URL", "http://auth-service:8000")
|
||||
# Plan Limits
|
||||
BASIC_PLAN_LOCATIONS: int = int(os.getenv("BASIC_PLAN_LOCATIONS", "1"))
|
||||
BASIC_PLAN_PREDICTIONS_PER_DAY: int = int(os.getenv("BASIC_PLAN_PREDICTIONS_PER_DAY", "100"))
|
||||
BASIC_PLAN_DATA_RETENTION_DAYS: int = int(os.getenv("BASIC_PLAN_DATA_RETENTION_DAYS", "90"))
|
||||
|
||||
class Config:
|
||||
env_file = ".env"
|
||||
PREMIUM_PLAN_LOCATIONS: int = int(os.getenv("PREMIUM_PLAN_LOCATIONS", "5"))
|
||||
PREMIUM_PLAN_PREDICTIONS_PER_DAY: int = int(os.getenv("PREMIUM_PLAN_PREDICTIONS_PER_DAY", "1000"))
|
||||
PREMIUM_PLAN_DATA_RETENTION_DAYS: int = int(os.getenv("PREMIUM_PLAN_DATA_RETENTION_DAYS", "365"))
|
||||
|
||||
ENTERPRISE_PLAN_LOCATIONS: int = int(os.getenv("ENTERPRISE_PLAN_LOCATIONS", "50"))
|
||||
ENTERPRISE_PLAN_PREDICTIONS_PER_DAY: int = int(os.getenv("ENTERPRISE_PLAN_PREDICTIONS_PER_DAY", "10000"))
|
||||
ENTERPRISE_PLAN_DATA_RETENTION_DAYS: int = int(os.getenv("ENTERPRISE_PLAN_DATA_RETENTION_DAYS", "1095"))
|
||||
|
||||
# Billing Configuration
|
||||
BILLING_ENABLED: bool = os.getenv("BILLING_ENABLED", "false").lower() == "true"
|
||||
BILLING_CURRENCY: str = os.getenv("BILLING_CURRENCY", "EUR")
|
||||
BILLING_CYCLE_DAYS: int = int(os.getenv("BILLING_CYCLE_DAYS", "30"))
|
||||
|
||||
# Resource Limits
|
||||
MAX_API_CALLS_PER_MINUTE: int = int(os.getenv("MAX_API_CALLS_PER_MINUTE", "100"))
|
||||
MAX_STORAGE_MB: int = int(os.getenv("MAX_STORAGE_MB", "1024"))
|
||||
MAX_CONCURRENT_REQUESTS: int = int(os.getenv("MAX_CONCURRENT_REQUESTS", "10"))
|
||||
|
||||
# Spanish Business Configuration
|
||||
SPANISH_TAX_RATE: float = float(os.getenv("SPANISH_TAX_RATE", "0.21")) # IVA 21%
|
||||
INVOICE_LANGUAGE: str = os.getenv("INVOICE_LANGUAGE", "es")
|
||||
SUPPORT_EMAIL: str = os.getenv("SUPPORT_EMAIL", "soporte@bakeryforecast.es")
|
||||
|
||||
# Onboarding
|
||||
ONBOARDING_ENABLED: bool = os.getenv("ONBOARDING_ENABLED", "true").lower() == "true"
|
||||
DEMO_DATA_ENABLED: bool = os.getenv("DEMO_DATA_ENABLED", "true").lower() == "true"
|
||||
|
||||
# Compliance
|
||||
GDPR_COMPLIANCE_ENABLED: bool = True
|
||||
DATA_EXPORT_ENABLED: bool = True
|
||||
DATA_DELETION_ENABLED: bool = True
|
||||
|
||||
settings = Settings()
|
||||
settings = TenantSettings()
|
||||
|
||||
@@ -1,53 +1,65 @@
|
||||
# ================================================================
|
||||
# TRAINING SERVICE CONFIGURATION
|
||||
# services/training/app/core/config.py
|
||||
# ================================================================
|
||||
|
||||
"""
|
||||
Training service configuration
|
||||
ML model training and management
|
||||
"""
|
||||
|
||||
from shared.config.base import BaseServiceSettings
|
||||
import os
|
||||
from pydantic_settings import BaseSettings
|
||||
from typing import List
|
||||
|
||||
class Settings(BaseSettings):
|
||||
"""Application settings"""
|
||||
class TrainingSettings(BaseServiceSettings):
|
||||
"""Training service specific settings"""
|
||||
|
||||
# Basic settings
|
||||
# Service Identity
|
||||
APP_NAME: str = "Training Service"
|
||||
VERSION: str = "1.0.0"
|
||||
DEBUG: bool = os.getenv("DEBUG", "False").lower() == "true"
|
||||
LOG_LEVEL: str = os.getenv("LOG_LEVEL", "INFO")
|
||||
SERVICE_NAME: str = "training-service"
|
||||
DESCRIPTION: str = "Machine learning model training service"
|
||||
|
||||
# Database settings
|
||||
DATABASE_URL: str = os.getenv("DATABASE_URL", "postgresql+asyncpg://training_user:training_pass123@training-db:5432/training_db")
|
||||
# Database Configuration
|
||||
DATABASE_URL: str = os.getenv("TRAINING_DATABASE_URL",
|
||||
"postgresql+asyncpg://training_user:training_pass123@training-db:5432/training_db")
|
||||
|
||||
# Redis settings
|
||||
REDIS_URL: str = os.getenv("REDIS_URL", "redis://redis:6379/1")
|
||||
# Redis Database (dedicated for training cache)
|
||||
REDIS_DB: int = 1
|
||||
|
||||
# RabbitMQ settings
|
||||
RABBITMQ_URL: str = os.getenv("RABBITMQ_URL", "amqp://bakery:forecast123@rabbitmq:5672/")
|
||||
|
||||
# Service URLs
|
||||
AUTH_SERVICE_URL: str = os.getenv("AUTH_SERVICE_URL", "http://auth-service:8000")
|
||||
DATA_SERVICE_URL: str = os.getenv("DATA_SERVICE_URL", "http://data-service:8000")
|
||||
|
||||
# ML Settings
|
||||
# ML Model Storage
|
||||
MODEL_STORAGE_PATH: str = os.getenv("MODEL_STORAGE_PATH", "/app/models")
|
||||
MODEL_BACKUP_ENABLED: bool = os.getenv("MODEL_BACKUP_ENABLED", "true").lower() == "true"
|
||||
MODEL_VERSIONING_ENABLED: bool = os.getenv("MODEL_VERSIONING_ENABLED", "true").lower() == "true"
|
||||
|
||||
# Training Configuration
|
||||
MAX_TRAINING_TIME_MINUTES: int = int(os.getenv("MAX_TRAINING_TIME_MINUTES", "30"))
|
||||
MAX_CONCURRENT_TRAINING_JOBS: int = int(os.getenv("MAX_CONCURRENT_TRAINING_JOBS", "3"))
|
||||
MIN_TRAINING_DATA_DAYS: int = int(os.getenv("MIN_TRAINING_DATA_DAYS", "30"))
|
||||
TRAINING_BATCH_SIZE: int = int(os.getenv("TRAINING_BATCH_SIZE", "1000"))
|
||||
|
||||
# Prophet Settings
|
||||
# Prophet Specific Configuration
|
||||
PROPHET_SEASONALITY_MODE: str = os.getenv("PROPHET_SEASONALITY_MODE", "additive")
|
||||
PROPHET_DAILY_SEASONALITY: bool = os.getenv("PROPHET_DAILY_SEASONALITY", "true").lower() == "true"
|
||||
PROPHET_WEEKLY_SEASONALITY: bool = os.getenv("PROPHET_WEEKLY_SEASONALITY", "true").lower() == "true"
|
||||
PROPHET_YEARLY_SEASONALITY: bool = os.getenv("PROPHET_YEARLY_SEASONALITY", "true").lower() == "true"
|
||||
PROPHET_CHANGEPOINT_PRIOR_SCALE: float = float(os.getenv("PROPHET_CHANGEPOINT_PRIOR_SCALE", "0.05"))
|
||||
PROPHET_SEASONALITY_PRIOR_SCALE: float = float(os.getenv("PROPHET_SEASONALITY_PRIOR_SCALE", "10.0"))
|
||||
PROPHET_HOLIDAYS_PRIOR_SCALE: float = float(os.getenv("PROPHET_HOLIDAYS_PRIOR_SCALE", "10.0"))
|
||||
|
||||
# CORS
|
||||
CORS_ORIGINS: str = os.getenv("CORS_ORIGINS", "http://localhost:3000,http://localhost:3001")
|
||||
# Spanish Holiday Integration
|
||||
ENABLE_SPANISH_HOLIDAYS: bool = True
|
||||
ENABLE_MADRID_HOLIDAYS: bool = True
|
||||
ENABLE_CUSTOM_HOLIDAYS: bool = os.getenv("ENABLE_CUSTOM_HOLIDAYS", "true").lower() == "true"
|
||||
|
||||
@property
|
||||
def CORS_ORIGINS_LIST(self) -> List[str]:
|
||||
"""Get CORS origins as list"""
|
||||
return [origin.strip() for origin in self.CORS_ORIGINS.split(",")]
|
||||
# Data Processing
|
||||
DATA_PREPROCESSING_ENABLED: bool = True
|
||||
OUTLIER_DETECTION_ENABLED: bool = os.getenv("OUTLIER_DETECTION_ENABLED", "true").lower() == "true"
|
||||
SEASONAL_DECOMPOSITION_ENABLED: bool = os.getenv("SEASONAL_DECOMPOSITION_ENABLED", "true").lower() == "true"
|
||||
|
||||
class Config:
|
||||
env_file = ".env"
|
||||
# Model Validation
|
||||
CROSS_VALIDATION_ENABLED: bool = os.getenv("CROSS_VALIDATION_ENABLED", "true").lower() == "true"
|
||||
VALIDATION_SPLIT_RATIO: float = float(os.getenv("VALIDATION_SPLIT_RATIO", "0.2"))
|
||||
MIN_MODEL_ACCURACY: float = float(os.getenv("MIN_MODEL_ACCURACY", "0.7"))
|
||||
|
||||
# Distributed Training (for future scaling)
|
||||
DISTRIBUTED_TRAINING_ENABLED: bool = os.getenv("DISTRIBUTED_TRAINING_ENABLED", "false").lower() == "true"
|
||||
TRAINING_WORKER_COUNT: int = int(os.getenv("TRAINING_WORKER_COUNT", "1"))
|
||||
|
||||
settings = Settings()
|
||||
settings = TrainingSettings()
|
||||
Reference in New Issue
Block a user