Configuration & Environment Variables
Relevant source files
The following files were used as context for generating this wiki page:
The Promethean Unified Platform utilizes a decentralized configuration strategy that relies heavily on environment variables to manage integrations between the Flask backend, Supabase database, and the DeepSeek LLM. This approach ensures that sensitive credentials, such as API keys and database URIs, remain isolated from the source code while providing flexibility across different deployment environments like local development and PythonAnywhere.
The configuration management system handles three primary domains: external service authentication (Supabase and DeepSeek), Flask server behavior (debug modes and port mapping), and security enforcement (HTTPS and CSP headers).
Sources: backend/app.py:11-20, DEPLOYMENT.md:46-59
Core Environment Variables
The system requires a .env file located in the project root to function correctly in production. These variables are loaded at runtime using the python-dotenv library.
| Variable | Required | Description | Default/Example |
|---|---|---|---|
SUPABASE_URL | Yes | The project URL for the Supabase instance. | https://[id].supabase.co |
SUPABASE_ANON_KEY | Yes | The anonymous public key for database access. | your_anon_key |
DEEPSEEK_API_KEY | Yes | API key for the DeepSeek LLM provider. | YOUR_API_KEY |
FLASK_ENV | Yes | Defines the environment mode. | production |
FLASK_DEBUG | Yes | Controls the visibility of error traces. | False |
SERVER_PORT | No | Port for the Flask application to listen on. | 5000 |
SERVER_HOST | No | Host address for the Flask application. | 0.0.0.0 |
Sources: DEPLOYMENT.md:144-154, requirements.txt:3
Initialization & Loading Flow
The platform initializes configuration through multiple entry points depending on the deployment method. In a WSGI environment (like PythonAnywhere), the environment is bootstrapped before the Flask application instance is created.
The diagram shows the initialization sequence from entry point to backend configuration.
Sources: pythonanywhere_wsgi.py:6-18, wsgi.py:4-10, backend/app.py:11-30
Loading Mechanisms
- Direct Loading:
backend/app.pycallsload_dotenv()immediately after imports to ensure all subsequentos.environ.get()calls are populated. - WSGI Injection: The
pythonanywhere_wsgi.pyscript manually inserts the project folder intosys.pathand loads the.envfile before importing the application factory to prevent circular import issues or missing configuration during the handshake with the web server.
Sources: backend/app.py:11, pythonanywhere_wsgi.py:12-16
Integration Configurations
Supabase Backend
The connection to the Supabase PostgreSQL backend is established using the supabase-py client. This client requires the SUPABASE_URL and SUPABASE_ANON_KEY to interact with tables such as interactions and chat_messages.
url = os.environ.get("SUPABASE_URL")
key = os.environ.get("SUPABASE_ANON_KEY")
supabase = create_client(url, key)
Sources: backend/app.py:28-30, requirements.txt:4
DeepSeek LLM Integration
The DeepSeek API integration is conditional. The system checks for the presence of DEEPSEEK_API_KEY. if found, it directs chat queries to https://api.deepseek.com/v1/chat/completions. If the key is missing, the system falls back to a descriptive placeholder response.
Sources: backend/app.py:124-142, DEPLOYMENT.md:126-128
Security Configuration
Security is configured programmatically via the set_security_headers function, which applies specific HTTP headers to every response from the Flask application.
| Header | Value | Purpose |
|---|---|---|
Strict-Transport-Security | max-age=31536000 | Enforces HTTPS for 1 year. |
X-Frame-Options | DENY | Prevents Clickjacking by disallowing framing. |
Content-Security-Policy | default-src 'self' ... | Restricts source of scripts and styles. |
X-Content-Type-Options | nosniff | Prevents MIME type sniffing. |
Sources: backend/app.py:17-26, DEPLOYMENT.md:109-114
Environment-Specific Logic
The application distinguishes between production and development through the FLASK_ENV variable. In the pythonanywhere_wsgi.py and wsgi.py files, this is explicitly set to production to ensure performance and security.
The sequence demonstrates how environment variables are accessed during a live API request.
Sources: backend/app.py:124-135, pythonanywhere_wsgi.py:12
Summary
The configuration of the Promethean Unified Platform is strictly environment-driven, utilizing .env files and WSGI script injections to maintain a separation between logic and credentials. By centralizing variables for Supabase and DeepSeek, the platform allows for rapid deployment and easy scaling while maintaining high security standards through forced HTTPS and strict CSP headers defined in the application core.