Skip to main content

Overview

The Exness Trading Platform uses environment variables for configuration across all services. This guide documents all available variables from the .env.example file.

Configuration File

Create a .env file in the project root:
cp .env.example .env
Never commit the .env file to version control. The .env.example file serves as a template with safe default values for development.

Complete Environment Variables

Redis Configuration

REDIS_URL
string
required
Redis connection URL for caching and real-time data streams.Default: redis://localhost:6379Docker Network: redis://redis:6379Format: redis://[user:password@]host:port[/database]Used by:
  • Backend API
  • Trading Engine
  • WebSocket Server
  • Price Poller
  • All data processing services
Redis is critical for real-time data flow. All services depend on Redis for inter-service communication.

Market Data Configuration

BINANCE_WS_URL
string
required
Binance WebSocket API endpoint for real-time market data.Default: wss://ws.backpack.exchange/Production: wss://stream.binance.com:9443/wsUsed by Price Poller service to fetch live market prices for BTC, ETH, and SOL.
The default uses Backpack Exchange. Switch to Binance WebSocket API in production for official market data.

TimescaleDB Configuration

TimescaleDB stores historical market data and time-series information.
TIMESCALE_DB_USER
string
required
TimescaleDB username.Default: myuserProduction: Use a strong, unique username.
TIMESCALE_DB_PASSWORD
string
required
TimescaleDB password.Default: mypasswordProduction: Use a strong, randomly generated password (minimum 32 characters).
Change this immediately for production deployments. Never use default passwords.
TIMESCALE_DB_HOST
string
required
TimescaleDB hostname.Development: localhostDocker: timescaledb (service name)Production: Your TimescaleDB server hostname or IP address.
TIMESCALE_DB_PORT
number
required
TimescaleDB port number.Default: 5433 (development)Docker: 5432 (internal container port)Standard PostgreSQL: 5432
TIMESCALE_DB_NAME
string
required
TimescaleDB database name.Default: mydbRecommended: exness_timeseries or similar descriptive name.

Authentication Configuration

JWT_SECRET
string
required
Secret key for JWT token signing and verification.Default: mysecretProduction: Generate a cryptographically secure random string.
# Generate secure secret
openssl rand -base64 64
This is critical for security. All user sessions depend on this secret. Changing it will invalidate all existing sessions.

Application Configuration

NODE_ENV
string
required
Node.js environment mode.Values: development | production | testDefault: productionAffects:
  • Logging verbosity
  • Error stack traces
  • Performance optimizations
  • Debug features
PORT
number
required
Backend API server port.Default: 8000Used by the Express.js backend service for REST API endpoints.
WEBSOCKET_PORT
number
required
WebSocket server port for real-time data streaming.Default: 7070Frontend applications connect to this port for live market data and updates.

URL Configuration

FRONTEND_URL
string
required
Frontend application URL for CORS and redirects.Default: http://localhost:3001Production: Your production frontend domain (e.g., https://trading.exness.com)Used for:
  • CORS whitelisting
  • OAuth redirects
  • Email links
BACKEND_URL
string
required
Backend API URL for service-to-service communication.Default: http://localhost:8000Docker: http://backend:8000Production: Your production API domain (e.g., https://api.exness.com)

Database Configuration

DATABASE_URL
string
required
PostgreSQL connection string for Prisma ORM.Default: postgresql://postgresql:postgresql@localhost:5434/exnessDocker: postgresql://postgresql:postgresql@postgres:5432/exnessFormat: postgresql://USER:PASSWORD@HOST:PORT/DATABASEUsed by:
  • Prisma ORM for migrations
  • Backend API for user management
  • Database Storage service
  • Trading Engine for order persistence
This is the primary database for all transactional data, user accounts, and orders.
MONGODB_URL
string
required
MongoDB connection string for snapshot storage.Default: mongodb://admin:admin123@localhost:27017/exness_snapshots?authSource=adminDocker: mongodb://admin:admin123@mongodb:27017/exness_snapshots?authSource=adminFormat: mongodb://USER:PASSWORD@HOST:PORT/DATABASE?authSource=adminUsed by Snap Shotting service for periodic account state backups.
Must be enclosed in quotes in the .env file due to special characters.

Email Configuration

USER_EMAIL
string
required
Email address for sending notifications and alerts.Default: [email protected]Production: Your organization’s SMTP-enabled email address.Used for:
  • Account verification emails
  • Trade notifications
  • Alert system
  • Password resets
USER_PASSWORD
string
required
SMTP app password for email authentication.Default: pvjc ohid eqfl gmpjGmail: Generate an App Password from Google Account settings.Format: Space-separated tokens (Gmail App Password format)
This is NOT your regular email password. Use an app-specific password or SMTP credential.

Environment File Template

Complete .env.example file:
.env.example
# Redis Configuration
REDIS_URL=redis://localhost:6379

# Market Data
BINANCE_WS_URL=wss://ws.backpack.exchange/

# TimescaleDB Configuration
TIMESCALE_DB_USER=myuser
TIMESCALE_DB_PASSWORD=mypassword
TIMESCALE_DB_HOST=localhost
TIMESCALE_DB_PORT=5433
TIMESCALE_DB_NAME=mydb

# Authentication
JWT_SECRET=mysecret

# Application Settings
NODE_ENV=production
PORT=8000
FRONTEND_URL=http://localhost:3001
WEBSOCKET_PORT=7070

# Email Configuration
USER_EMAIL=[email protected]
USER_PASSWORD=pvjc ohid eqfl gmpj

# Service URLs
BACKEND_URL=http://localhost:8000

# Primary Database
DATABASE_URL=postgresql://postgresql:postgresql@localhost:5434/exness

# MongoDB
MONGODB_URL='mongodb://admin:admin123@localhost:27017/exness_snapshots?authSource=admin'

Docker Compose Overrides

Docker Compose automatically overrides certain variables for container networking:
environment:
  REDIS_URL: redis://redis:6379
  TIMESCALE_DB_HOST: timescaledb
  TIMESCALE_DB_PORT: 5432
  DATABASE_URL: postgresql://postgresql:postgresql@postgres:5432/exness
  MONGODB_URL: mongodb://admin:admin123@mongodb:27017/exness_snapshots?authSource=admin
  FRONTEND_URL: http://localhost:3001
  BACKEND_URL: http://localhost:8000
Container-specific variables use internal service names (e.g., postgres, redis) for communication within the Docker network.

Production Configuration

Security Best Practices

1

Change All Default Passwords

Generate strong passwords for:
  • TimescaleDB
  • PostgreSQL (in docker-compose.yml)
  • MongoDB (in docker-compose.yml)
  • JWT secret
# Generate random passwords
openssl rand -base64 32
2

Use Secrets Management

For production, use a secrets management system:
  • AWS Secrets Manager
  • HashiCorp Vault
  • Kubernetes Secrets
  • Docker Secrets
Never store production credentials in plain text .env files.
3

Enable TLS/SSL

Update connection strings to use encrypted connections:
DATABASE_URL=postgresql://user:pass@host:5432/db?sslmode=require
REDIS_URL=rediss://user:pass@host:6380
MONGODB_URL=mongodb://user:pass@host:27017/db?ssl=true
4

Set Production URLs

Update all URLs to production domains:
FRONTEND_URL=https://trading.exness.com
BACKEND_URL=https://api.exness.com
NODE_ENV=production

Environment-Specific Variables

NODE_ENV=development
FRONTEND_URL=http://localhost:3001
BACKEND_URL=http://localhost:8000
REDIS_URL=redis://localhost:6379
DATABASE_URL=postgresql://postgresql:postgresql@localhost:5434/exness

Variable Validation

The platform validates required environment variables on startup. Missing or invalid variables will prevent services from starting.
import { z } from 'zod';

const envSchema = z.object({
  DATABASE_URL: z.string().url(),
  REDIS_URL: z.string().url(),
  JWT_SECRET: z.string().min(32),
  NODE_ENV: z.enum(['development', 'production', 'test']),
  PORT: z.string().transform(Number),
  FRONTEND_URL: z.string().url(),
});

const env = envSchema.parse(process.env);

Troubleshooting

Check that database environment variables match between .env and docker-compose.yml:
# Verify PostgreSQL connection
docker compose exec postgres psql -U postgresql -d exness -c "SELECT 1;"

# Check environment in container
docker compose exec backend env | grep DATABASE_URL
Ensure FRONTEND_URL and BACKEND_URL are correctly configured:
# Frontend should match the URL you're accessing
FRONTEND_URL=http://localhost:3001

# Backend should be accessible from frontend
BACKEND_URL=http://localhost:8000
Verify JWT_SECRET is consistent across all services:
# Check if JWT_SECRET is loaded
docker compose exec backend node -e "console.log(process.env.JWT_SECRET)"
Changing JWT_SECRET invalidates all existing sessions.
Verify email configuration:
# Check email credentials are loaded
docker compose exec backend env | grep USER_EMAIL

# Test SMTP connection
# Gmail requires App Password, not regular password
For Gmail:
  1. Enable 2-factor authentication
  2. Generate App Password at https://myaccount.google.com/apppasswords
  3. Use the generated password in USER_PASSWORD

Next Steps

Docker Compose

Learn how environment variables are used in Docker Compose

Database Setup

Configure database connections and run migrations

Build docs developers (and LLMs) love