2025-12-05 14:22:39 +01:00
|
|
|
"""
|
|
|
|
|
Configuration Module
|
|
|
|
|
Handles environment variables and application settings
|
|
|
|
|
"""
|
|
|
|
|
|
|
|
|
|
import os
|
|
|
|
|
from typing import List
|
2025-12-17 20:58:01 +01:00
|
|
|
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
|
2025-12-17 17:28:50 +01:00
|
|
|
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"]
|
2025-12-17 17:28:50 +01:00
|
|
|
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
|
2025-12-22 11:44:13 +01:00
|
|
|
ECONOMIC_ENABLED: bool = False
|
2025-12-05 14:22:39 +01:00
|
|
|
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
|
|
|
|
|
|
2025-12-16 15:36:11 +01:00
|
|
|
# Ollama LLM
|
|
|
|
|
OLLAMA_ENDPOINT: str = "http://localhost:11434"
|
|
|
|
|
OLLAMA_MODEL: str = "llama3.2:3b"
|
|
|
|
|
|
2025-12-19 13:09:42 +01:00
|
|
|
# Email System Configuration
|
|
|
|
|
# IMAP Settings
|
|
|
|
|
IMAP_SERVER: str = ""
|
|
|
|
|
IMAP_PORT: int = 993
|
|
|
|
|
IMAP_USERNAME: str = ""
|
|
|
|
|
IMAP_PASSWORD: str = ""
|
|
|
|
|
IMAP_USE_SSL: bool = True
|
|
|
|
|
IMAP_FOLDER: str = "INBOX"
|
|
|
|
|
IMAP_READ_ONLY: bool = True
|
|
|
|
|
|
|
|
|
|
# Microsoft Graph API (alternative to IMAP)
|
|
|
|
|
USE_GRAPH_API: bool = False
|
|
|
|
|
GRAPH_TENANT_ID: str = ""
|
|
|
|
|
GRAPH_CLIENT_ID: str = ""
|
|
|
|
|
GRAPH_CLIENT_SECRET: str = ""
|
|
|
|
|
GRAPH_USER_EMAIL: str = ""
|
|
|
|
|
|
|
|
|
|
# Email Processing Settings
|
|
|
|
|
EMAIL_TO_TICKET_ENABLED: bool = False
|
|
|
|
|
EMAIL_RULES_ENABLED: bool = True
|
|
|
|
|
EMAIL_RULES_AUTO_PROCESS: bool = False
|
|
|
|
|
EMAIL_AI_ENABLED: bool = False
|
|
|
|
|
EMAIL_AUTO_CLASSIFY: bool = False
|
|
|
|
|
EMAIL_AI_CONFIDENCE_THRESHOLD: float = 0.7
|
|
|
|
|
EMAIL_MAX_FETCH_PER_RUN: int = 50
|
|
|
|
|
EMAIL_PROCESS_INTERVAL_MINUTES: int = 5
|
|
|
|
|
EMAIL_WORKFLOWS_ENABLED: bool = True
|
2026-01-06 13:16:25 +01:00
|
|
|
EMAIL_MAX_UPLOAD_SIZE_MB: int = 50 # Max file size for email uploads
|
2025-12-19 13:09:42 +01:00
|
|
|
|
2025-12-16 15:36:11 +01:00
|
|
|
# vTiger Cloud Integration
|
2025-12-22 11:44:13 +01:00
|
|
|
VTIGER_ENABLED: bool = False
|
feat(timetracking): Implement time tracking module with frontend views, HTML templates, and database migrations
- Added FastAPI router for time tracking views including dashboard, wizard, and orders.
- Created HTML templates for the time tracking wizard with responsive design and Bootstrap integration.
- Developed SQL migration script for the time tracking module, including tables for customers, cases, time entries, orders, and audit logs.
- Introduced a script to list all registered routes, focusing on time tracking routes.
- Added test script to verify route registration and specifically check for time tracking routes.
2025-12-09 22:46:30 +01:00
|
|
|
VTIGER_URL: str = ""
|
|
|
|
|
VTIGER_USERNAME: str = ""
|
|
|
|
|
VTIGER_API_KEY: str = ""
|
feat: Implement email processing system with scheduler, fetching, classification, and rule matching
- Added EmailProcessorService to orchestrate email workflow: fetching, saving, classifying, and matching rules.
- Introduced EmailScheduler for background processing of emails every 5 minutes.
- Developed EmailService to handle email fetching from IMAP and Microsoft Graph API.
- Created database migration for email system, including tables for email messages, rules, attachments, and analysis.
- Implemented AI classification and extraction for invoices and time confirmations.
- Added logging for better traceability and error handling throughout the email processing pipeline.
2025-12-11 02:31:29 +01:00
|
|
|
|
2025-12-16 22:07:20 +01:00
|
|
|
# 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"
|
2025-12-23 01:04:44 +01:00
|
|
|
TIMETRACKING_ECONOMIC_LAYOUT: int = 19 # e-conomic invoice layout number (default: 19 = Danish standard)
|
2025-12-23 01:11:58 +01:00
|
|
|
TIMETRACKING_ECONOMIC_PRODUCT: str = "1000" # e-conomic product number for time entries (default: 1000)
|
2025-12-16 22:07:20 +01:00
|
|
|
|
2025-12-16 15:36:11 +01:00
|
|
|
# Simply-CRM (Old vTiger On-Premise)
|
|
|
|
|
OLD_VTIGER_URL: str = ""
|
|
|
|
|
OLD_VTIGER_USERNAME: str = ""
|
|
|
|
|
OLD_VTIGER_API_KEY: str = ""
|
feat: Implement email processing system with scheduler, fetching, classification, and rule matching
- Added EmailProcessorService to orchestrate email workflow: fetching, saving, classifying, and matching rules.
- Introduced EmailScheduler for background processing of emails every 5 minutes.
- Developed EmailService to handle email fetching from IMAP and Microsoft Graph API.
- Created database migration for email system, including tables for email messages, rules, attachments, and analysis.
- Implemented AI classification and extraction for invoices and time confirmations.
- Added logging for better traceability and error handling throughout the email processing pipeline.
2025-12-11 02:31:29 +01:00
|
|
|
|
2025-12-16 15:36:11 +01:00
|
|
|
# Simply-CRM (Separate System)
|
|
|
|
|
SIMPLYCRM_URL: str = ""
|
|
|
|
|
SIMPLYCRM_USERNAME: str = ""
|
|
|
|
|
SIMPLYCRM_API_KEY: str = ""
|
2025-12-15 12:28:12 +01:00
|
|
|
|
2026-01-02 01:54:52 +01:00
|
|
|
# Backup System Configuration
|
2026-01-02 02:13:17 +01:00
|
|
|
BACKUP_ENABLED: bool = True
|
2026-01-02 01:54:52 +01:00
|
|
|
BACKUP_STORAGE_PATH: str = "/app/backups"
|
|
|
|
|
BACKUP_DRY_RUN: bool = False
|
2026-01-02 02:26:33 +01:00
|
|
|
BACKUP_READ_ONLY: bool = False
|
2026-01-02 12:35:02 +01:00
|
|
|
BACKUP_RESTORE_DRY_RUN: bool = True # SAFETY: Test restore uden at overskrive data
|
2026-01-02 01:54:52 +01:00
|
|
|
BACKUP_RETENTION_DAYS: int = 30
|
|
|
|
|
BACKUP_RETENTION_MONTHLY: int = 12
|
2026-01-02 02:23:10 +01:00
|
|
|
BACKUP_MAX_SIZE_GB: int = 100
|
|
|
|
|
STORAGE_WARNING_THRESHOLD_PCT: int = 80
|
2026-01-02 12:35:02 +01:00
|
|
|
DB_DAILY_FORMAT: str = "dump" # Compressed format for daily backups
|
|
|
|
|
DB_MONTHLY_FORMAT: str = "sql" # Plain SQL for monthly backups
|
|
|
|
|
BACKUP_INCLUDE_UPLOADS: bool = True # Include uploads/ in file backups
|
|
|
|
|
BACKUP_INCLUDE_LOGS: bool = True # Include logs/ in file backups
|
|
|
|
|
BACKUP_INCLUDE_DATA: bool = True # Include data/ in file backups
|
|
|
|
|
UPLOAD_DIR: str = "uploads" # Upload directory path
|
2026-01-02 01:54:52 +01:00
|
|
|
|
|
|
|
|
# Offsite Backup Settings (SFTP)
|
|
|
|
|
OFFSITE_ENABLED: bool = False
|
2026-01-06 15:11:28 +01:00
|
|
|
OFFSITE_WEEKLY_DAY: str = "sunday"
|
|
|
|
|
OFFSITE_RETRY_DELAY_HOURS: int = 1
|
|
|
|
|
OFFSITE_RETRY_MAX_ATTEMPTS: int = 3
|
2026-01-02 01:54:52 +01:00
|
|
|
SFTP_HOST: str = ""
|
|
|
|
|
SFTP_PORT: int = 22
|
|
|
|
|
SFTP_USER: str = ""
|
|
|
|
|
SFTP_PASSWORD: str = ""
|
|
|
|
|
SFTP_REMOTE_PATH: str = "/backups"
|
|
|
|
|
SSH_KEY_PATH: str = ""
|
|
|
|
|
|
2026-01-02 02:02:44 +01:00
|
|
|
# Mattermost Notifications
|
|
|
|
|
MATTERMOST_WEBHOOK_URL: str = ""
|
2026-01-02 02:06:05 +01:00
|
|
|
MATTERMOST_ENABLED: bool = False
|
|
|
|
|
MATTERMOST_CHANNEL: str = ""
|
2026-01-02 02:02:44 +01:00
|
|
|
|
2025-12-17 17:28:50 +01:00
|
|
|
# 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"
|
|
|
|
|
|
2025-12-17 20:58:01 +01:00
|
|
|
@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()
|