Skip to content

Horizon Configuration

Horizon API is configured via environment variables, typically set in a .env file at apps/signal-horizon/api/.env.

Server

VariableDefaultDescription
NODE_ENVdevelopmentproduction enables optimizations and stricter defaults
PORT3100HTTP listener port
HOST0.0.0.0Bind address
LOG_LEVELinfotrace, debug, info, warn, error

Database (PostgreSQL)

VariableDefaultRequiredDescription
DATABASE_URLYesPostgreSQL connection string (e.g., postgresql://user:pass@host:5432/signal_horizon)

ClickHouse (Optional)

VariableDefaultDescription
CLICKHOUSE_ENABLEDfalseEnable ClickHouse for historical queries
CLICKHOUSE_HOSTlocalhostHostname
CLICKHOUSE_HTTP_PORT8123HTTP API port
CLICKHOUSE_DBsignal_horizonDatabase name
CLICKHOUSE_USERdefaultUsername
CLICKHOUSE_PASSWORDPassword
CLICKHOUSE_COMPRESSIONtrueEnable compression
CLICKHOUSE_MAX_CONNECTIONS10Connection pool size

When to enable ClickHouse

Enable ClickHouse when you need time-series queries over large signal volumes or retention beyond what PostgreSQL comfortably handles. For small deployments (< 10 sensors), PostgreSQL alone is sufficient.

WebSocket

VariableDefaultDescription
WS_SENSOR_PATH/ws/sensorsSensor ingestion endpoint
WS_DASHBOARD_PATH/ws/dashboardDashboard push endpoint
WS_HEARTBEAT_INTERVAL_MS30000Heartbeat interval (ms)
WS_MAX_SENSOR_CONNECTIONS1000Max concurrent sensor connections
WS_MAX_DASHBOARD_CONNECTIONS100Max concurrent dashboard connections

Signal Processing

VariableDefaultDescription
SIGNAL_BATCH_SIZE100Signals per aggregation batch
SIGNAL_BATCH_TIMEOUT_MS5000Max wait before flushing a batch
BLOCKLIST_PUSH_DELAY_MS50Delay before broadcasting blocklist updates
BLOCKLIST_CACHE_SIZE100000In-memory blocklist capacity

Security

VariableDefaultDescription
API_KEY_HEADERX-API-KeyHeader name for API key authentication
CORS_ORIGINSComma-separated allowed origins
CONFIG_ENCRYPTION_KEYEncryption key for sensitive config fields at rest
TELEMETRY_JWT_SECRETJWT secret for sensor telemetry endpoint (/_sensor/report)

Production secrets

In production, set CONFIG_ENCRYPTION_KEY and TELEMETRY_JWT_SECRET to strong random values (32+ characters). Use a secrets manager (Vault, AWS Secrets Manager) rather than storing them in .env files.

Example Configurations

Development

sh
NODE_ENV=development
PORT=3100
DATABASE_URL=postgresql://postgres:postgres@localhost:5432/signal_horizon?schema=public
LOG_LEVEL=debug
CLICKHOUSE_ENABLED=false
CORS_ORIGINS=http://localhost:5180,http://127.0.0.1:5180

Production

sh
NODE_ENV=production
PORT=3100
DATABASE_URL=postgresql://app:$DB_PASSWORD@db.internal:5432/signal_horizon
LOG_LEVEL=info
CLICKHOUSE_ENABLED=true
CLICKHOUSE_HOST=clickhouse.internal
CLICKHOUSE_PASSWORD=$CH_PASSWORD
CORS_ORIGINS=https://horizon.example.com
CONFIG_ENCRYPTION_KEY=$ENCRYPTION_KEY
TELEMETRY_JWT_SECRET=$JWT_SECRET
WS_MAX_SENSOR_CONNECTIONS=5000

Licensed under AGPL-3.0 · atlascrew.dev