Files
bakery-ia/gateway/app/core/config.py

65 lines
2.0 KiB
Python
Raw Normal View History

"""
Gateway configuration
"""
import os
from typing import List, Dict
2025-07-17 14:34:24 +02:00
from pydantic_settings import BaseSettings
class Settings(BaseSettings):
"""Application settings"""
# Basic settings
APP_NAME: str = "Bakery Forecasting Gateway"
VERSION: str = "1.0.0"
DEBUG: bool = os.getenv("DEBUG", "False").lower() == "true"
LOG_LEVEL: str = os.getenv("LOG_LEVEL", "INFO")
# Service URLs
2025-07-17 19:46:41 +02:00
AUTH_SERVICE_URL: str = "http://auth-service:8000"
TRAINING_SERVICE_URL: str = "http://training-service:8000"
FORECASTING_SERVICE_URL: str = "http://forecasting-service:8000"
DATA_SERVICE_URL: str = "http://data-service:8000"
TENANT_SERVICE_URL: str = "http://tenant-service:8000"
NOTIFICATION_SERVICE_URL: str = "http://notification-service:8000"
2025-07-17 21:25:27 +02:00
# Service Discovery
CONSUL_URL: str = os.getenv("CONSUL_URL", "http://consul:8500")
ENABLE_SERVICE_DISCOVERY: bool = os.getenv("ENABLE_SERVICE_DISCOVERY", "false").lower() == "true"
# CORS
CORS_ORIGINS: str = os.getenv("CORS_ORIGINS", "http://localhost:3000,http://localhost:3001")
@property
def CORS_ORIGINS_LIST(self) -> List[str]:
"""Get CORS origins as list"""
return [origin.strip() for origin in self.CORS_ORIGINS.split(",")]
# Redis settings
2025-07-17 19:46:41 +02:00
REDIS_URL: str = "redis://redis:6379/6"
# Rate limiting
2025-07-17 19:46:41 +02:00
RATE_LIMIT_REQUESTS: int = 100
RATE_LIMIT_WINDOW: int = 60
# JWT settings
2025-07-17 19:46:41 +02:00
JWT_SECRET_KEY: str = "your-secret-key-change-in-production"
JWT_ALGORITHM: str = "HS256"
@property
def SERVICES(self) -> Dict[str, str]:
"""Service registry"""
return {
"auth": self.AUTH_SERVICE_URL,
"training": self.TRAINING_SERVICE_URL,
"forecasting": self.FORECASTING_SERVICE_URL,
"data": self.DATA_SERVICE_URL,
"tenant": self.TENANT_SERVICE_URL,
"notification": self.NOTIFICATION_SERVICE_URL
}
2025-07-17 19:46:41 +02:00
class Config:
env_file = ".env"
settings = Settings()