bmc_hub/app/core/config.py

95 lines
2.7 KiB
Python
Raw Normal View History

2025-12-05 14:22:39 +01:00
"""
Configuration Module
Handles environment variables and application settings
"""
import os
from typing import List
from pydantic import field_validator
2025-12-05 14:22:39 +01:00
from pydantic_settings import BaseSettings
class Settings(BaseSettings):
"""Application settings loaded from environment variables"""
# Database
DATABASE_URL: str = "postgresql://bmc_hub:bmc_hub@localhost:5432/bmc_hub"
# API
API_HOST: str = "0.0.0.0"
API_PORT: int = 8000
API_RELOAD: bool = False
2025-12-05 14:22:39 +01:00
# Security
SECRET_KEY: str = "dev-secret-key-change-in-production"
ALLOWED_ORIGINS: List[str] = ["http://localhost:8000", "http://localhost:3000"]
CORS_ORIGINS: str = "http://localhost:8000,http://localhost:3000"
2025-12-05 14:22:39 +01:00
# Logging
LOG_LEVEL: str = "INFO"
LOG_FILE: str = "logs/app.log"
# e-conomic Integration
ECONOMIC_API_URL: str = "https://restapi.e-conomic.com"
ECONOMIC_APP_SECRET_TOKEN: str = ""
ECONOMIC_AGREEMENT_GRANT_TOKEN: str = ""
ECONOMIC_READ_ONLY: bool = True
ECONOMIC_DRY_RUN: bool = True
# Ollama LLM
OLLAMA_ENDPOINT: str = "http://localhost:11434"
OLLAMA_MODEL: str = "llama3.2:3b"
# vTiger Cloud Integration
VTIGER_URL: str = ""
VTIGER_USERNAME: str = ""
VTIGER_API_KEY: str = ""
# Time Tracking Module Settings
TIMETRACKING_DEFAULT_HOURLY_RATE: float = 1200.00
TIMETRACKING_AUTO_ROUND: bool = True
TIMETRACKING_ROUND_INCREMENT: float = 0.5
TIMETRACKING_ROUND_METHOD: str = "up" # "up", "down", "nearest"
# Time Tracking Module Safety Flags
TIMETRACKING_VTIGER_READ_ONLY: bool = True
TIMETRACKING_VTIGER_DRY_RUN: bool = True
TIMETRACKING_ECONOMIC_READ_ONLY: bool = True
TIMETRACKING_ECONOMIC_DRY_RUN: bool = True
TIMETRACKING_EXPORT_TYPE: str = "draft" # "draft" or "booked"
# Simply-CRM (Old vTiger On-Premise)
OLD_VTIGER_URL: str = ""
OLD_VTIGER_USERNAME: str = ""
OLD_VTIGER_API_KEY: str = ""
# Simply-CRM (Separate System)
SIMPLYCRM_URL: str = ""
SIMPLYCRM_USERNAME: str = ""
SIMPLYCRM_API_KEY: str = ""
# Deployment Configuration (used by Docker/Podman)
POSTGRES_USER: str = "bmc_hub"
POSTGRES_PASSWORD: str = "bmc_hub"
POSTGRES_DB: str = "bmc_hub"
POSTGRES_PORT: int = 5432
RELEASE_VERSION: str = "latest"
GITEA_URL: str = "https://g.bmcnetworks.dk"
GITHUB_TOKEN: str = ""
GITHUB_REPO: str = "ct/bmc_hub"
@field_validator('*', mode='before')
@classmethod
def strip_whitespace(cls, v):
"""Strip leading/trailing whitespace from string values"""
if isinstance(v, str):
return v.strip()
return v
2025-12-05 14:22:39 +01:00
class Config:
env_file = ".env"
case_sensitive = True
settings = Settings()