"""Application settings. Everything comes from the environment — no secrets in code.""" from functools import lru_cache from pydantic import Field from pydantic_settings import BaseSettings, SettingsConfigDict class Settings(BaseSettings): model_config = SettingsConfigDict( env_file=".env", env_file_encoding="utf-8", extra="ignore" ) # --- Application --------------------------------------------------- APP_NAME: str = "Celtic Life Science Pvt Ltd" PDF_COMPANY_NAME: str = "CELTIC LIFE SCIENCE PVT LTD" PDF_COMPANY_ADDRESS: str = "PLOT NO -D/3, KHARVEL NAGAR, UNIT-3, BHUBANESWAR ODISHA-751001" PDF_COMPANY_WEBSITE: str = "www.celticlifescience.com" PDF_COMPANY_EMAIL: str = "info@celticlifescience.com" PDF_COMPANY_PHONE: str = "9090024999" API_V1_PREFIX: str = "/api/v1" ENVIRONMENT: str = "development" DEBUG: bool = False # --- Database ------------------------------------------------------ DATABASE_URL: str = "postgresql+asyncpg://pharma:pharma@localhost:5432/pharma" DB_ECHO: bool = False # --- Authentication ------------------------------------------------ # SECRET_KEY MUST be overridden in production. SECRET_KEY: str = "change-me-in-production-this-is-not-a-secret" JWT_ALGORITHM: str = "HS256" ACCESS_TOKEN_EXPIRE_MINUTES: int = 45 REFRESH_TOKEN_EXPIRE_DAYS: int = 7 LOGIN_MAX_FAILED_ATTEMPTS: int = 10 # Business timezone: "today" and visit-time checks use this, not the server's UTC clock. APP_TIMEZONE: str = "Asia/Kolkata" # --- Business rules (see report §21 — confirm with client) ---------- # A10 / Q8: how many days back an MR may file a report. BACKDATING_WINDOW_DAYS: int = Field(default=7, ge=0, le=90) # A Daily Call Report (Plan) may be made this many days ahead; Done and Self never. PLAN_AHEAD_DAYS: int = Field(default=2, ge=0, le=30) # A16 / Q9: report for date D must be submitted by end of D + this many days. SUBMISSION_DEADLINE_DAYS: int = Field(default=1, ge=0, le=30) # V8: minimum length of a manager's return reason. MIN_RETURN_REASON_LENGTH: int = 10 # --- Storage ------------------------------------------------------- PDF_STORAGE_PATH: str = "./storage/pdf" # --- CORS ---------------------------------------------------------- CORS_ORIGINS: list[str] = Field( default_factory=lambda: ["https://celtic.upskalor.com", "https://www.celtic.upskalor.com", "http://localhost:5173", "http://localhost:3000"] ) @property def sync_database_url(self) -> str: """Alembic runs synchronously through psycopg, not the async API driver.""" return self.DATABASE_URL.replace("+asyncpg", "+psycopg") @lru_cache def get_settings() -> Settings: return Settings() settings = get_settings()