Skip to main content

Environment Variables

All environment variables are loaded from a .env file at the project root. Never commit this file to version control.

Database Configuration

VariableRequiredDefaultDescription
DB_HOSTYeslocalhostPostgreSQL server hostname
DB_PORTYes5432PostgreSQL server port
DB_NAMEYesintellicon_crmDatabase name
DB_USERYespostgresDatabase username
DB_PASSYesDatabase password
DB_SSLNofalseEnable SSL for database connections
DB_POOL_SIZENo10Maximum connection pool size
DB_HOST=localhost
DB_PORT=5432
DB_NAME=intellicon_crm
DB_USER=postgres
DB_PASS=your_secure_password
DB_SSL=false
DB_POOL_SIZE=10
Production

In production, always use SSL (DB_SSL=true) and a strong password. Never use the postgres superuser — create a dedicated application user with limited privileges.

JWT Configuration

VariableRequiredDefaultDescription
JWT_SECRETYesSecret key for signing JWT tokens
JWT_EXPIRYNo1hAccess token expiration duration
REFRESH_TOKEN_EXPIRYNo7dRefresh token expiration duration
JWT_SECRET=change-this-to-a-long-random-string-in-production
JWT_EXPIRY=1h
REFRESH_TOKEN_EXPIRY=7d
danger

The JWT_SECRET must be a strong, random string in production (minimum 64 characters). A compromised JWT secret allows forging authentication tokens for any user/tenant.

Redis Configuration

VariableRequiredDefaultDescription
REDIS_HOSTYeslocalhostRedis server hostname
REDIS_PORTYes6379Redis server port
REDIS_PASSWORDNoRedis password (if AUTH is enabled)
REDIS_DBNo0Redis database number
REDIS_HOST=localhost
REDIS_PORT=6379
REDIS_PASSWORD=
REDIS_DB=0

Application Configuration

VariableRequiredDefaultDescription
PORTNo3000API server port
NODE_ENVNodevelopmentEnvironment: development, staging, production
FRONTEND_URLYeshttp://localhost:5173Frontend URL (used for CORS and email links)
API_URLNohttp://localhost:3000API URL (used in email templates)
CORS_ORIGINSNoFRONTEND_URLComma-separated list of allowed CORS origins
PORT=3000
NODE_ENV=development
FRONTEND_URL=http://localhost:5173
API_URL=http://localhost:3000

Email / SMTP Configuration

VariableRequiredDefaultDescription
SMTP_HOSTNoSMTP server hostname
SMTP_PORTNo587SMTP server port
SMTP_USERNoSMTP username
SMTP_PASSNoSMTP password
SMTP_FROMNoDefault "From" email address
SMTP_FROM_NAMENoIntellicon CRMDefault "From" display name
SMTP_SECURENofalseUse TLS for SMTP connection
SMTP_HOST=smtp.example.com
SMTP_PORT=587
SMTP_USER=notifications@example.com
SMTP_PASS=smtp_password
SMTP_FROM=notifications@example.com
SMTP_FROM_NAME=Intellicon CRM
SMTP_SECURE=false
Development

For local development, you can use Mailtrap or Mailhog to capture outgoing emails without sending them.

File Upload Configuration

VariableRequiredDefaultDescription
UPLOAD_DIRNo./uploadsLocal directory for file uploads
MAX_FILE_SIZENo10485760Maximum file size in bytes (10MB)
ALLOWED_FILE_TYPESNojpg,jpeg,png,gif,pdf,doc,docx,xls,xlsx,csvAllowed upload extensions
UPLOAD_DIR=./uploads
MAX_FILE_SIZE=10485760

Third-Party API Keys

VariableRequiredDefaultDescription
GOOGLE_CLIENT_IDNoGoogle OAuth client ID (calendar sync)
GOOGLE_CLIENT_SECRETNoGoogle OAuth client secret
GOOGLE_REDIRECT_URINoGoogle OAuth redirect URI
XERO_CLIENT_IDNoXero accounting integration
XERO_CLIENT_SECRETNoXero client secret
TWILIO_ACCOUNT_SIDNoTwilio SMS/voice account SID
TWILIO_AUTH_TOKENNoTwilio authentication token
TWILIO_FROM_NUMBERNoTwilio sender phone number
# Google Calendar Sync
GOOGLE_CLIENT_ID=your-client-id.apps.googleusercontent.com
GOOGLE_CLIENT_SECRET=your-client-secret
GOOGLE_REDIRECT_URI=http://localhost:3000/calendar-sync/callback

# Xero (optional)
XERO_CLIENT_ID=
XERO_CLIENT_SECRET=

# Twilio (optional)
TWILIO_ACCOUNT_SID=
TWILIO_AUTH_TOKEN=
TWILIO_FROM_NUMBER=

Web Push Notifications

VariableRequiredDefaultDescription
VAPID_PUBLIC_KEYNoVAPID public key for push notifications
VAPID_PRIVATE_KEYNoVAPID private key
VAPID_SUBJECTNoVAPID subject (mailto: URL)
VAPID_PUBLIC_KEY=
VAPID_PRIVATE_KEY=
VAPID_SUBJECT=mailto:admin@example.com
Generating VAPID Keys

Use the admin endpoint POST /notifications/admin/generate-vapid or the web-push CLI:

npx web-push generate-vapid-keys

Frontend Environment Variables

Frontend variables must be prefixed with VITE_ to be accessible in the browser.

Create apps/web/.env:

VariableRequiredDefaultDescription
VITE_API_URLYeshttp://localhost:3000Backend API base URL
VITE_APP_NAMENoIntellicon CRMApplication display name
VITE_VAPID_PUBLIC_KEYNoVAPID public key for push subscriptions
VITE_API_URL=http://localhost:3000
VITE_APP_NAME=Intellicon CRM
VITE_VAPID_PUBLIC_KEY=

Environment-Specific Configurations

Development

NODE_ENV=development
DB_HOST=localhost
FRONTEND_URL=http://localhost:5173
JWT_EXPIRY=24h # Longer expiry for convenience

Staging

NODE_ENV=staging
DB_HOST=staging-db.internal
DB_SSL=true
FRONTEND_URL=https://staging.intellicon.app
JWT_EXPIRY=1h

Production

NODE_ENV=production
DB_HOST=prod-db.internal
DB_SSL=true
DB_POOL_SIZE=25
FRONTEND_URL=https://app.intellicon.com
JWT_SECRET=<64+ character random string>
JWT_EXPIRY=1h
REFRESH_TOKEN_EXPIRY=7d
SMTP_SECURE=true
Production Checklist

Before deploying to production, verify:

  • JWT_SECRET is a strong random string (64+ chars)
  • DB_PASS is not the default password
  • DB_SSL=true is set
  • NODE_ENV=production
  • SMTP credentials are configured
  • CORS origins are restricted to production domains
  • All third-party API keys are production keys