Environment Variables Reference
All env vars across every app and server. Variables marked Required will cause startup failures or silent broken behaviour if missing.
Shared Infrastructure
These are needed by every service that touches a database or queue.
| Variable | Required | Example | Description |
|---|---|---|---|
DATABASE_URL | Yes | postgresql://leadmetrics:leadmetrics@localhost:5434/leadmetrics | Primary PostgreSQL connection string |
MONGO_URL | API + Agents | mongodb://localhost:27017/leadmetrics | MongoDB for audit logs and agent outputs |
REDIS_URL | Yes | redis://localhost:6379 | Redis (ragmanager-redis container — exposed on 6379) |
API (apps/api/.env)
Auth
| Variable | Required | Description |
|---|---|---|
JWT_SECRET | Yes | HS256 signing secret for all portal access tokens |
REFRESH_TOKEN_SECRET | Yes | Signing secret for refresh tokens |
INTERNAL_API_SECRET | Yes | Shared secret for inter-service API calls (worker → API callbacks) |
App URLs
| Variable | Required | Description |
|---|---|---|
NEXT_PUBLIC_APP_URL | Yes | Dashboard URL; used in email links |
APP_URL | Yes | Same as above; used in newsletter unsubscribe links |
CORS_ORIGINS | No | Comma-separated allowed origins. Defaults to localhost:3000,3001,3002 in dev |
TRUST_PROXY | No | true when behind Docker/nginx. Use CIDR in production |
Storage (DigitalOcean Spaces)
All 6 required — missing DO_SPACES_ENDPOINT silently breaks the social post image designer.
| Variable | Description |
|---|---|
DO_SPACES_KEY | Spaces access key |
DO_SPACES_SECRET | Spaces secret key |
DO_SPACES_REGION | Region slug (e.g. sgp1) |
DO_SPACES_ENDPOINT | Full endpoint URL (e.g. https://sgp1.digitaloceanspaces.com) |
DO_SPACES_BUCKET | Bucket name |
DO_SPACES_CDN_URL | CDN base URL (e.g. https://your-bucket.sgp1.cdn.digitaloceanspaces.com) |
LLM Providers
| Variable | Required | Description |
|---|---|---|
OPENAI_API_KEY | For OpenAI agents | OpenAI API key |
ANTHROPIC_API_KEY | For Claude agents | Anthropic API key |
GOOGLE_GENERATIVE_AI_KEY | For Gemini agents | Google Generative AI key |
PERPLEXITY_API_KEY | For AI visibility | Perplexity API key |
Azure (Image Generation)
| Variable | Required | Description |
|---|---|---|
AZURE_IMAGE_API_KEY | Social post images | Azure Cognitive Services key |
AZURE_IMAGE_ENDPOINT | Social post images | Full Azure endpoint URL for GPT Image 1.5 |
Google OAuth Channels
| Variable | Channel |
|---|---|
GOOGLE_ADS_APP_ID + GOOGLE_ADS_APP_SECRET + GOOGLE_ADS_DEVELOPER_TOKEN | Google Ads connect + insights |
GOOGLE_SEARCH_CONSOLE_APP_ID + GOOGLE_SEARCH_CONSOLE_APP_SECRET | GSC connect |
GOOGLE_ANALYTICS_APP_ID + GOOGLE_ANALYTICS_APP_SECRET | GA4 connect |
GOOGLE_BUSINESS_PROFILE_APP_ID + GOOGLE_BUSINESS_PROFILE_APP_SECRET | GBP connect + post publishing |
GitHub OAuth
| Variable | Description |
|---|---|
GITHUB_CLIENT_ID | GitHub OAuth App client ID |
GITHUB_CLIENT_SECRET | GitHub OAuth App secret |
Newsletter Sending (Resend)
| Variable | Required | Description |
|---|---|---|
RESEND_API_KEY | Yes (if using newsletters) | Resend API key |
NEWSLETTER_FROM_EMAIL | Yes | Default from address |
NEWSLETTER_FROM_NAME | Yes | Default sender name |
Email (Notifications)
| Variable | Required | Description |
|---|---|---|
SENDGRID_API_KEY | Platform notifications | SendGrid API key |
DEV_ALLOWED_EMAIL_DOMAINS | Dev only | Only send to these domains in dev (e.g. leadmetrics.ai) |
DEV_CC_EMAIL | Dev only | BCC this address on all dev emails |
Payments (Razorpay)
| Variable | Required | Description |
|---|---|---|
RAZORPAY_KEY_ID | Billing | Razorpay key ID |
RAZORPAY_KEY_SECRET | Billing | Razorpay key secret |
Encryption
| Variable | Required | Description |
|---|---|---|
PROVIDER_CONFIG_ENCRYPTION_KEY | Yes | AES key for encrypting OAuth tokens at rest in the DB |
Dashboard (apps/dashboard/.env.local)
| Variable | Required | Description |
|---|---|---|
NEXT_PUBLIC_APP_URL | Yes | http://localhost:3000 |
NEXT_PUBLIC_API_URL | Yes | http://localhost:3003 |
API_URL | Yes | http://localhost:3003 — used by middleware for silent token refresh |
JWT_SECRET | Yes | Same value as API — used by middleware to verify access tokens |
REFRESH_TOKEN_SECRET | Yes | Same value as API — used to verify refresh tokens |
Manage (apps/manage/.env.local)
| Variable | Required | Description |
|---|---|---|
NEXT_PUBLIC_API_URL | Yes | http://localhost:3003 |
JWT_SECRET | Yes | Secret for manage portal JWT tokens |
REFRESH_TOKEN_SECRET | Yes | Secret for refresh tokens |
DM Portal (apps/dm/.env.local)
| Variable | Required | Description |
|---|---|---|
NEXT_PUBLIC_API_URL | Yes | http://localhost:3003 |
JWT_SECRET | Yes | Same as Manage (shared JWT signing) |
REFRESH_TOKEN_SECRET | Yes | Same as Manage |
Agents Server (apps/servers/agents/.env)
Needs everything the API needs for provider calls, plus:
| Variable | Required | Description |
|---|---|---|
DATABASE_URL | Yes | — |
REDIS_URL | Yes | — |
DASHBOARD_URL | Yes | http://localhost:3000 — used in notification links |
PROVIDER_CONFIG_ENCRYPTION_KEY | Yes | Same value as API — used to decrypt OAuth tokens when insight workers call provider APIs |
OPENAI_API_KEY | Agent-dependent | Required if using OpenAI provider |
ANTHROPIC_API_KEY | Yes | Required — seo-optimizer, brand-narrative-analyst, ai-visibility-monitor all throw without it |
All DO_SPACES_* | Yes | All 6 required for social post image designer |
AZURE_IMAGE_API_KEY | Social images | — |
AZURE_IMAGE_ENDPOINT | Social images | — |
PIXABAY_API_KEY | Stock images | — |
UNSPLASH_ACCESS_KEY | Stock images | — |
Billing Server (apps/servers/billing/.env)
| Variable | Required | Description |
|---|---|---|
DATABASE_URL | Yes | — |
REDIS_URL | Yes | — |
BILLING_CRON_SCHEDULE | No | Defaults to 5 0 1 * * (1st of month, 00:05 UTC) |
OVERDUE_CRON_SCHEDULE | No | Defaults to 0 1 * * * (01:00 daily) |
REMINDER_CRON_SCHEDULE | No | Defaults to 0 * * * * (hourly) |
CREDITS_RESET_CRON_SCHEDULE | No | Defaults to 10 0 1 * * (1st of month, 00:10 UTC) |
Notifications Server (apps/servers/notifications/.env)
| Variable | Required | Description |
|---|---|---|
DATABASE_URL | Yes | — |
REDIS_URL | Yes | — |
SENDGRID_API_KEY | Yes | Platform email sender |
DEV_ALLOWED_EMAIL_DOMAINS | Dev | leadmetrics.ai — only send to these domains |
DEV_CC_EMAIL | Dev | moble@leadmetrics.ai — BCC on all dev emails |
Reporting Server (apps/servers/reporting/.env)
| Variable | Required | Description |
|---|---|---|
DATABASE_URL | Yes | — |
REDIS_URL | Yes | — |
ADMIN_REPORT_EMAIL | Yes | Email address for the nightly admin summary |
ADMIN_REPORT_NAME | Yes | Display name for the admin report recipient |
RAG Engine Server (apps/servers/ragengine/.env)
| Variable | Required | Description |
|---|---|---|
DATABASE_URL | Yes | Used to provision tenant datasets on registration |
REDIS_URL | Yes | — |
QDRANT_URL | Yes | http://localhost:6333 (or ragmanager-qdrant endpoint) |
Search Indexer Server (apps/servers/search-indexer/.env)
| Variable | Required | Description |
|---|---|---|
DATABASE_URL | Yes | Used to fetch full records for indexing |
REDIS_URL | Yes | BullMQ search__sync queue |
TYPESENSE_URL | Yes | http://localhost:8108 (or Docker leadmetrics-typesense:8108) |
TYPESENSE_ADMIN_API_KEY | Yes | Must match --api-key in the Typesense Docker command |
NODE_ENV | No | development | production |
Typesense env vars used at query time (API, Dashboard)
These are also needed by any service that calls Typesense directly (the API, Next.js API routes, or the provider-typesense package):
| Variable | Description |
|---|---|
TYPESENSE_URL | Same value as above |
TYPESENSE_ADMIN_API_KEY | Same value as above |
Dev default:
http://localhost:8108and keyleadmetrics-dev-key(matches thedocker-compose.ymlservice).
Notes
- None of these files are committed. Keep them out of git.
- In production, secrets are injected by Doppler per environment and service — never hardcoded.
PROVIDER_CONFIG_ENCRYPTION_KEYmust be identical in bothapps/apiandapps/servers/agents— the API encrypts OAuth tokens when stored; agents decrypt them when calling provider APIs.JWT_SECRETandREFRESH_TOKEN_SECRETmust be identical acrossapps/api,apps/dashboard,apps/manage, andapps/dm— all portals share the same JWT signing keys.