# Trouve-KA — configuration validée par variables d'environnement # Author: Simon-Pierre Boucher # Contact: contact@spboucher.ai """Configuration centrale de Trouve-KA. Toutes les valeurs sont surchargeables par variable d'environnement et dimensionnées par défaut pour le node de déploiement m2m32 (32 Go RAM). """ from functools import lru_cache from pydantic_settings import BaseSettings, SettingsConfigDict class Settings(BaseSettings): model_config = SettingsConfigDict(env_file=".env", env_file_encoding="utf-8", extra="ignore") # Bases de données database_url: str = "postgresql://trouveka:trouveka@localhost:5432/trouveka" redis_url: str = "redis://localhost:6379/0" search_url: str = "http://localhost:9200" search_index: str = "trouveka-docs" # Crawler — identité et politesse crawler_user_agent: str = ( "Mozilla/5.0 (compatible; TrouveKABot/0.1; +https://www.trouve-ka.com/trouveka-bot)" ) crawler_contact_url: str = "https://www.trouve-ka.com/trouveka-bot" max_global_concurrency: int = 24 max_per_host_concurrency: int = 2 default_host_delay: float = 2.0 # secondes entre deux requêtes vers un même hôte # Crawler — limites de sécurité (chaque réponse a des limites) max_response_bytes: int = 3_000_000 max_redirects: int = 5 fetch_timeout: float = 20.0 max_crawl_depth: int = 8 max_links_per_page: int = 300 max_urls_per_domain: int = 5_000 max_query_params: int = 8 max_path_segments: int = 12 # Recrawl adaptatif (bornes, en heures) min_recrawl_hours: float = 1.0 max_recrawl_hours: float = 24 * 30.0 default_recrawl_hours: float = 24.0 # Indexation min_quebec_score_to_index: float = 0.15 min_body_length: int = 80 # API api_host: str = "0.0.0.0" api_port: int = 8080 admin_token: str = "change-me-admin-token" public_url: str = "https://www.trouve-ka.com" ngrok_domain: str = "www.trouve-ka.com" # Postgres pool (dimensionné pour 32 Go / plusieurs workers) pg_pool_min: int = 2 pg_pool_max: int = 10 @lru_cache def get_settings() -> Settings: return Settings()