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.
Required Variables
These variables must be set for the application to function:Firebase API key for authentication.Obtain this from your Firebase project settings at console.firebase.google.com.
Firebase authentication domain.Format:
your-project-id.firebaseapp.comYour Firebase project ID.Find this in your Firebase project settings.
Firebase service account credentials JSON.Download from Firebase Console → Project Settings → Service Accounts → Generate New Private Key.
React Frontend Variables
Configuration for the React application frontend:Port for the production React application.Development mode runs on port 5173 by default.
HTTP URL for the Express API server.
WebSocket URL for the Y-Redis real-time collaboration server.
Analytics Variables (Production Only)
PostHog analytics project key.Optional. Leave empty to disable PostHog analytics.
PostHog analytics host URL.Optional. Leave empty to disable PostHog analytics.
Microsoft Clarity project ID for session recording.Optional. Leave empty to disable Clarity integration.
Express Backend Variables
Configuration for the Express API server:Port for the Express HTTP server.
Secret key for signing room access tokens.Generate a secure secret:
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:Port for the Y-Redis WebSocket server.
Log filter regex pattern for Y-Redis.
Redis connection URL for Y-Redis pub/sub.Used for distributing updates across multiple Y-Redis instances.
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:PostgreSQL database name.
PostgreSQL host address.Use the Docker service name when running in containers.
PostgreSQL port number.
PostgreSQL username.
PostgreSQL password.
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: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:Email address for PgAdmin login.Use this email to log into the PgAdmin web interface.
Password for PgAdmin login.
External port for the PgAdmin web interface.Access PgAdmin at
http://localhost:[PGADMIN_PORT]Example Configuration Files
Development Environment
.env (Development)
Production Environment
.env (Production)
Security Best Practices
- Change all default passwords: Never use default values for
DB_PASS,ADMIN_PASS, orROOM_SIGNATURE_SECRET - Use strong secrets: Generate cryptographically secure random strings for all secrets
- Protect credentials: Never commit
.envfiles or Firebase service account credentials to version control - Use TLS/SSL: In production, use
wss://for WebSocket connections andhttps://for HTTP endpoints - Limit access: Configure firewalls to restrict database and Redis access to only necessary services
- Rotate credentials: Regularly rotate passwords and API keys
- 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:
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_HOSTmatches your PostgreSQL container name or hostnameDB_USERandDB_PASSmatch the credentials configured in PostgreSQL- PostgreSQL container is running:
docker compose ps database-psql-dev