Skip to main content

Overview

Plant Together uses environment variables to configure all services. Create a .env file in the root directory of your project to customize the deployment.
Never commit your .env file to version control. Ensure .env is listed in your .gitignore file to prevent exposing sensitive credentials.

Required Variables

These variables must be set for the application to function:
FIREBASE_API_KEY
string
required
Firebase API key for authentication.Obtain this from your Firebase project settings at console.firebase.google.com.
FIREBASE_AUTH_DOMAIN
string
required
Firebase authentication domain.Format: your-project-id.firebaseapp.com
FIREBASE_PROJECT_ID
string
required
Your Firebase project ID.Find this in your Firebase project settings.
SERVICE_ACCOUNT_CREDENTIAL
string
required
Firebase service account credentials JSON.Download from Firebase Console → Project Settings → Service Accounts → Generate New Private Key.
This contains sensitive credentials. Never commit this to version control.

React Frontend Variables

Configuration for the React application frontend:
VITE_PORT
number
default:"4173"
Port for the production React application.Development mode runs on port 5173 by default.
VITE_SERVER_HTTP_URL
string
default:"http://localhost:3000"
HTTP URL for the Express API server.
VITE_SERVER_HTTP_URL=http://localhost:3000
VITE_SERVER_WS_URL
string
default:"ws://localhost:3003"
WebSocket URL for the Y-Redis real-time collaboration server.
VITE_SERVER_WS_URL=ws://localhost:3003

Analytics Variables (Production Only)

VITE_POSTHOG_KEY
string
default:"''"
PostHog analytics project key.Optional. Leave empty to disable PostHog analytics.
VITE_POSTHOG_HOST
string
default:"''"
PostHog analytics host URL.Optional. Leave empty to disable PostHog analytics.
VITE_CLARITY_PROJECT_ID
string
default:"''"
Microsoft Clarity project ID for session recording.Optional. Leave empty to disable Clarity integration.

Express Backend Variables

Configuration for the Express API server:
PORT
number
default:"3000"
Port for the Express HTTP server.
ROOM_SIGNATURE_SECRET
string
default:"0)8+a~([:<OE8RLj5Zp}"
Secret key for signing room access tokens.
Change this default value in production! Use a strong, randomly generated secret.
Generate a secure secret:
openssl rand -base64 32
REDIS_HOST
string
default:"redis://redis-together-dev"
Redis connection URL for session storage.Format: redis://[host]:[port] or rediss://[host]:[port] for TLS.

Y-Redis WebSocket Server Variables

Configuration for the Y-Redis real-time collaboration server:
YREDIS_PORT
number
default:"3003"
Port for the Y-Redis WebSocket server.
LOG
string
default:"^(?!No tasks available).*$"
Log filter regex pattern for Y-Redis.
LOG="^(?!No tasks available).*$"
REDIS
string
default:"redis://redis-together-dev"
Redis connection URL for Y-Redis pub/sub.Used for distributing updates across multiple Y-Redis instances.
POSTGRES
string
PostgreSQL connection string for Y-Redis document persistence.Format: postgres://[user]:[password]@[host]:[port]/[database]If not specified, Y-Redis will construct this from individual DB_* variables.

PostgreSQL Database Variables

Configuration for the PostgreSQL database:
DB_NAME
string
default:"postgres"
PostgreSQL database name.
DB_HOST
string
default:"database-psql-dev"
PostgreSQL host address.Use the Docker service name when running in containers.
DB_PORT
number
default:"5432"
PostgreSQL port number.
DB_USER
string
default:"postgres"
PostgreSQL username.
Change the default username in production environments.
DB_PASS
string
default:"1234"
PostgreSQL password.
Critical: Change this default password immediately for any production deployment!
PSQL_PORT
number
default:"5432"
External port mapping for PostgreSQL.This is the port exposed on your host machine to access PostgreSQL.

Redis Cache Variables

Configuration for the Redis cache:
REDIS_PORT
number
default:"6379"
External port mapping for Redis.This is the port exposed on your host machine to access Redis.

PgAdmin Variables

Configuration for the PgAdmin web interface:
ADMIN_EMAIL
string
Email address for PgAdmin login.Use this email to log into the PgAdmin web interface.
ADMIN_PASS
string
default:"1234"
Password for PgAdmin login.
Change this default password for production deployments.
PGADMIN_PORT
number
default:"1007"
External port for the PgAdmin web interface.Access PgAdmin at http://localhost:[PGADMIN_PORT]

Example Configuration Files

Development Environment

.env (Development)
# React Configuration
VITE_SERVER_HTTP_URL=http://localhost:3000
VITE_SERVER_WS_URL=ws://localhost:3003

# Express Configuration
PORT=3000
ROOM_SIGNATURE_SECRET=your-secure-secret-here

# Firebase Configuration (Required)
FIREBASE_API_KEY=your-firebase-api-key
FIREBASE_AUTH_DOMAIN=your-project.firebaseapp.com
FIREBASE_PROJECT_ID=your-project-id
SERVICE_ACCOUNT_CREDENTIAL='{"type":"service_account",...}'

# Database Configuration
DB_NAME=postgres
DB_HOST=database-psql-dev
DB_PORT=5432
DB_USER=postgres
DB_PASS=your-secure-password
PSQL_PORT=5432

# Y-Redis Configuration
YREDIS_PORT=3003
LOG="^(?!No tasks available).*$"

# Redis Configuration
REDIS_HOST=redis://redis-together-dev
REDIS_PORT=6379

# PgAdmin Configuration
[email protected]
ADMIN_PASS=your-admin-password
PGADMIN_PORT=1007

Production Environment

.env (Production)
# React Configuration
VITE_PORT=4173
VITE_SERVER_HTTP_URL=http://plant-together-express
VITE_SERVER_WS_URL=ws://plant-together-yredis

# Analytics (Optional)
VITE_POSTHOG_KEY=phc_your_posthog_key
VITE_POSTHOG_HOST=https://app.posthog.com
VITE_CLARITY_PROJECT_ID=your_clarity_id

# Express Configuration
PORT=3000
ROOM_SIGNATURE_SECRET=super-secure-random-secret-string-here

# Firebase Configuration (Required)
FIREBASE_API_KEY=your-production-firebase-api-key
FIREBASE_AUTH_DOMAIN=your-prod-project.firebaseapp.com
FIREBASE_PROJECT_ID=your-prod-project-id
SERVICE_ACCOUNT_CREDENTIAL='{"type":"service_account",...}'

# Database Configuration
DB_NAME=plant_together_prod
DB_HOST=database-psql
DB_PORT=5432
DB_USER=plant_together_user
DB_PASS=very-secure-production-password
PSQL_PORT=5432

# Y-Redis Configuration
YREDIS_PORT=3003
LOG="^(?!No tasks available).*$"
POSTGRES=postgres://plant_together_user:very-secure-production-password@database-psql:5432/plant_together_prod

# Redis Configuration
REDIS_HOST=redis://redis-together
REDIS=redis://redis-together
REDIS_PORT=6379

# PgAdmin Configuration
[email protected]
ADMIN_PASS=strong-admin-password
PGADMIN_PORT=1007

Security Best Practices

Follow these security practices for production deployments:
  1. Change all default passwords: Never use default values for DB_PASS, ADMIN_PASS, or ROOM_SIGNATURE_SECRET
  2. Use strong secrets: Generate cryptographically secure random strings for all secrets
  3. Protect credentials: Never commit .env files or Firebase service account credentials to version control
  4. Use TLS/SSL: In production, use wss:// for WebSocket connections and https:// for HTTP endpoints
  5. Limit access: Configure firewalls to restrict database and Redis access to only necessary services
  6. Rotate credentials: Regularly rotate passwords and API keys
  7. Environment separation: Use different credentials for development, staging, and production environments

Troubleshooting

Variables Not Being Applied

Ensure your .env file is in the correct location (root directory of the project) and restart all services:
docker compose down
docker compose up --build

Firebase Authentication Errors

Verify your Firebase credentials are correctly formatted:
  • API keys should not have quotes
  • Service account JSON should be on a single line or properly escaped
  • Domain should match your Firebase project exactly

Database Connection Failures

Check that:
  • DB_HOST matches your PostgreSQL container name or hostname
  • DB_USER and DB_PASS match the credentials configured in PostgreSQL
  • PostgreSQL container is running: docker compose ps database-psql-dev

Build docs developers (and LLMs) love