diff --git a/.env.example b/.env.example index 290e087..b92af17 100644 --- a/.env.example +++ b/.env.example @@ -1,15 +1,57 @@ # Core Code API Configuration +# Copy to .env and fill in real values -# Application settings +# ============================================================================= +# Application +# ============================================================================= APP_NAME="Core Code API" DEBUG=false +LOG_LEVEL=INFO -# Server settings +# ============================================================================= +# Server +# ============================================================================= HOST=0.0.0.0 PORT=8083 -# CORS settings (default allows all origins for internal use) +# CORS (default allows all origins for internal use) # CORS_ORIGINS=["http://192.168.86.149:82"] -# Logging -LOG_LEVEL=INFO \ No newline at end of file +# ============================================================================= +# Infrastructure Services +# ============================================================================= + +# Portainer API (required for container/stack management) +PORTAINER_URL=http://portainer:9000 +PORTAINER_API_KEY=ptr_your-api-key-here + +# Nginx Proxy Manager API +NPM_URL=http://npm:81 +NPM_EMAIL=admin@example.com +NPM_PASSWORD=your-npm-password + +# ============================================================================= +# Home Automation +# ============================================================================= + +# Home Assistant API +HOMEASSISTANT_URL=http://homeassistant:8123 +HOMEASSISTANT_TOKEN=your-long-lived-access-token + +# ============================================================================= +# AI Services +# ============================================================================= + +# Ollama API +OLLAMA_BASE_URL=http://ollama:11434 + +# SearXNG (self-hosted search) +SEARXNG_URL=http://searxng:8080 + +# ============================================================================= +# Vector Database +# ============================================================================= + +# Qdrant +QDRANT_HOST=qdrant +QDRANT_PORT=6333 \ No newline at end of file diff --git a/src/config.py b/src/config.py index 59e3884..b210374 100644 --- a/src/config.py +++ b/src/config.py @@ -1,5 +1,8 @@ """ Global configuration for Core Code API + +All configuration is loaded from environment variables or .env file. +See .env.example for available settings. """ import tomllib from pathlib import Path @@ -20,29 +23,6 @@ def _get_version_from_pyproject() -> str: __version__ = _get_version_from_pyproject() -# Import infrastructure credentials from gitignored module -try: - from src.credentials import ( - PORTAINER_URL, PORTAINER_API_KEY, - NPM_URL, NPM_EMAIL, NPM_PASSWORD, - BRAVE_SEARCH_API_KEY, - GOOGLE_SEARCH_API_KEY, GOOGLE_SEARCH_ENGINE_ID, - HOMEASSISTANT_URL, HOMEASSISTANT_TOKEN - ) -except ImportError: - # Fallback to empty strings if credentials.py doesn't exist - # (e.g., fresh clone before credentials setup) - PORTAINER_URL = "http://localhost:8001" - PORTAINER_API_KEY = "" - NPM_URL = "http://localhost:81" - NPM_EMAIL = "" - NPM_PASSWORD = "" - BRAVE_SEARCH_API_KEY = "" - GOOGLE_SEARCH_API_KEY = "" - GOOGLE_SEARCH_ENGINE_ID = "" - HOMEASSISTANT_URL = "http://localhost:8123" - HOMEASSISTANT_TOKEN = "" - class Settings(BaseSettings): """Global application settings""" @@ -109,25 +89,21 @@ class Settings(BaseSettings): embedding_batch_size: int = 32 # Search Configuration - search_provider: str = "google" # Options: google, brave, searxng, duckduckgo - searxng_url: str = "http://searxng:8080" # For future self-hosted SearxNG + search_provider: str = "searxng" + searxng_url: str = "http://searxng:8080" - # Search API Keys (from credentials.py) - brave_search_api_key: str = BRAVE_SEARCH_API_KEY # https://brave.com/search/api/ - google_search_api_key: str = GOOGLE_SEARCH_API_KEY # https://console.cloud.google.com/ - google_search_engine_id: str = GOOGLE_SEARCH_ENGINE_ID # Custom Search Engine ID + # Infrastructure Management (Portainer) + portainer_url: str = "http://portainer:9000" + portainer_api_key: str = "" - # Infrastructure Management (from credentials.py) - portainer_url: str = PORTAINER_URL - portainer_api_key: str = PORTAINER_API_KEY - - npm_url: str = NPM_URL - npm_email: str = NPM_EMAIL - npm_password: str = NPM_PASSWORD + # Infrastructure Management (Nginx Proxy Manager) + npm_url: str = "http://npm:81" + npm_email: str = "" + npm_password: str = "" # Home Assistant Configuration - homeassistant_url: str = HOMEASSISTANT_URL - homeassistant_token: str = HOMEASSISTANT_TOKEN + homeassistant_url: str = "http://homeassistant:8123" + homeassistant_token: str = "" homeassistant_timeout: int = 30 # Core-AI Service (AI performance metrics) @@ -163,6 +139,7 @@ class Settings(BaseSettings): class Config: env_file = ".env" case_sensitive = False + extra = "ignore" # Ignore extra env vars not defined in Settings @lru_cache() diff --git a/src/credentials.example.py b/src/credentials.example.py deleted file mode 100644 index 62b4915..0000000 --- a/src/credentials.example.py +++ /dev/null @@ -1,23 +0,0 @@ -""" -Infrastructure Credentials Template - -INSTRUCTIONS: -1. Copy this file to credentials.py -2. Fill in your actual credentials -3. DO NOT commit credentials.py to version control (it's in .gitignore) - -This file should be committed to the repository as a template. -""" - -# Portainer Configuration -PORTAINER_URL = "http://localhost:8001" -PORTAINER_API_KEY = "ptr_your_api_token_here" # Create in Portainer UI: User menu → My account → Access tokens - -# Nginx Proxy Manager Configuration -NPM_URL = "http://localhost:81" -NPM_EMAIL = "admin@example.com" -NPM_PASSWORD = "your_password_here" - -# Home Assistant Configuration -HOMEASSISTANT_URL = "http://192.168.86.149:8123" # Or http://home-assistant:8123 in Docker -HOMEASSISTANT_TOKEN = "your_long_lived_access_token_here" # Create in HA: Profile → Long-Lived Access Tokens