Environment Variables & Configuration
This document describes the hierarchical configuration system used in Syntropy-Journals.Architecture Overview
Syntropy-Journals uses Hydra (OmegaConf) for hierarchical YAML-based configuration, combined with environment variable overrides loaded fromenvs/ files.
File Structure
envs/base and envs/dev are created via make env-dev.
Key Environment Variables
Application Core
| Variable | Description | Default |
|---|---|---|
APP_ENV | Environment name (dev/test/prod) | dev |
LOGLEVEL | Log level | INFO |
Database
| Variable | Description | Default |
|---|---|---|
REFLEX_DB_URL | Full PostgreSQL connection URL | postgresql://postgres:postgres@localhost:5432/syntropy_journals |
Authentication (Clerk)
| Variable | Description | Example |
|---|---|---|
CLERK_PUBLISHABLE_KEY | Frontend key | pk_test_... |
CLERK_SECRET_KEY | Backend key | sk_test_... |
LLM / AI
| Variable | Description | Default |
|---|---|---|
OPENROUTER_API_KEY | OpenRouter API key (primary LLM provider) | (required) |
Payments (Stripe)
| Variable | Description | Example |
|---|---|---|
STRIPE_SECRET_KEY | Stripe secret key | sk_test_... |
STRIPE_PUBLISHABLE_KEY | Stripe publishable key | pk_test_... |
Deployment
| Variable | Description | Default |
|---|---|---|
REFLEX_API_URL | Backend public URL | - |
REFLEX_DEPLOY_URL | Frontend public URL | - |
CORS_ALLOWED_ORIGINS | Comma-separated CORS origins | - |
Analytics & Tracking
| Variable | Description | Default |
|---|---|---|
GA_MEASUREMENT_ID | Google Analytics 4 measurement ID | G-K6TR1P8KFZ |
GTM_CONTAINER_ID | Google Tag Manager container ID | GTM-58ZTSM22 |
GTM_ONLY | Enable GTM-only mode (minimal UI) | false |
POSTHOG_PROJECT_API_KEY | PostHog project API key | (empty = disabled) |
POSTHOG_HOST | PostHog instance URL | https://us.i.posthog.com |
POSTHOG_ENABLED | Enable/disable PostHog | true |
Health Data (Junction/Vital)
| Variable | Description | Default |
|---|---|---|
JUNCTION_API_KEY | Junction (Vital) API key for wearable data | (empty = disabled) |
JUNCTION_ENVIRONMENT | Junction environment: sandbox, production, sandbox_eu, production_eu | sandbox |
JUNCTION_API_KEY is absent, all wearable features are silently disabled — no crash, no error.
See junction-wearables.md for details.
Config Access (Hydra)
Configuration is accessed via typed getter functions insyntropy_journals/app/hydra_config.py:
Hydra YAML Files
| File | Dataclass | Description |
|---|---|---|
app/config/app/default.yaml | AppConfig | App-level settings |
app/config/llm/default.yaml | LLMConfig | LLM model, temperature, etc. |
app/config/ui/default.yaml | UIConfig | UI feature flags |
app/config/admin/default.yaml | AdminConfig | Admin settings |
app/config/head/default.yaml | HeadConfig | HTML head components |
Setup
Create local environment files
envs/template.base to envs/base and envs/template to envs/dev. Then edit them with your actual keys.
Required for development
At minimum, set these inenvs/dev or .env:
Required for payments
Railway / Docker Deployment
Environment variables set in Railway or Docker take precedence overenvs/ files.
The rxconfig.py loader preserves pre-existing environment variables:
Troubleshooting
Config not loading?
Hydra ConfigAttributeError?
Attributes not present in the YAML file will raiseConfigAttributeError even if defined as dataclass defaults. Always add new config keys to both the dataclass AND the YAML file.
Wrong environment?
EnsureAPP_ENV is set before starting the app:
Related Documentation
- Architecture — System overview
- Development — Local setup guide
- CI/CD — Deployment configuration