"""
Application settings management using Pydantic
"""
from typing import List, Optional
from pydantic_settings import BaseSettings

class Settings(BaseSettings):
    """Application settings loaded from environment variables."""
    APP_NAME: str = "Fundamental Analysis System"
    APP_VERSION: str = "1.0.0"
    DEBUG: bool = False

    # Default database URL switched to SQLite (async) to avoid optional driver issues.
    # You can override via config or env to PostgreSQL later.
    DATABASE_URL: str = "sqlite+aiosqlite:///./app.db"
    DATABASE_ECHO: bool = False

    # API settings
    API_V1_STR: str = "/api"
    ALLOWED_ORIGINS: List[str] = ["http://localhost:3000", "http://127.0.0.1:3000"]

    # External service credentials, can be overridden
    GEMINI_API_KEY: Optional[str] = None
    TUSHARE_TOKEN: Optional[str] = None

    # Microservices
    CONFIG_SERVICE_BASE_URL: str = "http://config-service:7000/api/v1"
    DATA_PERSISTENCE_BASE_URL: str = "http://data-persistence-service:3000/api/v1"

    class Config:
        env_file = ".env"
        case_sensitive = True

# Global settings instance
settings = Settings()
