SPB Git

spb/trouve-ka Public

Trouve-KA — moteur de recherche web indépendant, Québec-first. Crawler distribué, index OpenSearch, ranking bilingue, galerie d'images. En prod : www.trouve-ka.com

Python 76.8% TypeScript 15.7% SQL 3.9% Shell 1.4% CSS 1.3% Dockerfile 0.7%
2.1 KB · 68 lines python
Raw Blame History
1# Trouve-KA — configuration validée par variables d'environnement2# Author: Simon-Pierre Boucher3# Contact: contact@spboucher.ai45"""Configuration centrale de Trouve-KA.67Toutes les valeurs sont surchargeables par variable d'environnement et8dimensionnées par défaut pour le node de déploiement m2m32 (32 Go RAM).9"""1011from functools import lru_cache1213from pydantic_settings import BaseSettings, SettingsConfigDict141516class Settings(BaseSettings):17    model_config = SettingsConfigDict(env_file=".env", env_file_encoding="utf-8", extra="ignore")1819    # Bases de données20    database_url: str = "postgresql://trouveka:trouveka@localhost:5432/trouveka"21    redis_url: str = "redis://localhost:6379/0"22    search_url: str = "http://localhost:9200"23    search_index: str = "trouveka-docs"2425    # Crawler — identité et politesse26    crawler_user_agent: str = (27        "Mozilla/5.0 (compatible; TrouveKABot/0.1; +https://www.trouve-ka.com/trouveka-bot)"28    )29    crawler_contact_url: str = "https://www.trouve-ka.com/trouveka-bot"30    max_global_concurrency: int = 2431    max_per_host_concurrency: int = 232    default_host_delay: float = 2.0  # secondes entre deux requêtes vers un même hôte3334    # Crawler — limites de sécurité (chaque réponse a des limites)35    max_response_bytes: int = 3_000_00036    max_redirects: int = 537    fetch_timeout: float = 20.038    max_crawl_depth: int = 839    max_links_per_page: int = 30040    max_urls_per_domain: int = 5_00041    max_query_params: int = 842    max_path_segments: int = 124344    # Recrawl adaptatif (bornes, en heures)45    min_recrawl_hours: float = 1.046    max_recrawl_hours: float = 24 * 30.047    default_recrawl_hours: float = 24.04849    # Indexation50    min_quebec_score_to_index: float = 0.1551    min_body_length: int = 805253    # API54    api_host: str = "0.0.0.0"55    api_port: int = 808056    admin_token: str = "change-me-admin-token"57    public_url: str = "https://www.trouve-ka.com"58    ngrok_domain: str = "www.trouve-ka.com"5960    # Postgres pool (dimensionné pour 32 Go / plusieurs workers)61    pg_pool_min: int = 262    pg_pool_max: int = 10636465@lru_cache66def get_settings() -> Settings:67    return Settings()68