Overview
ShopStack Platform uses environment variables to configure both the Python and Node.js services. This page documents all available variables with their default values and usage.Python Service Variables
The Python service uses Flask and supports multiple configuration environments.Flask Environment
Flask environment mode. Controls which configuration class is loaded.Options:
development- Development mode with debug enabledstaging- Staging mode with debug disabledproduction- Production mode with debug disabledtesting- Testing mode with in-memory SQLite database
Security
Secret key for Flask session encryption and JWT token signing. Used for both Generate a secure key:
SECRET_KEY and JWT_SECRET_KEY in the application.Example:Database Configuration (Development)
Used whenFLASK_ENV=development:
PostgreSQL username for database connection in development mode.Example:
PostgreSQL password for database connection in development mode.Example:
PostgreSQL port for database connection in development mode.Example:
PostgreSQL database name in development mode.Example:
Database Configuration (Staging/Production)
Used whenFLASK_ENV=staging or FLASK_ENV=production:
PostgreSQL username for database connection in staging/production mode.Example:
PostgreSQL password for database connection in staging/production mode.Example:
PostgreSQL host for database connection in staging/production mode.Example:
PostgreSQL port for database connection in staging/production mode.Example:
PostgreSQL database name in staging/production mode.Example:
Database Host Configuration: In development mode, the host is hardcoded to
localhost. In staging/production modes, use the DB_HOST variable documented above to specify the PostgreSQL host.Caching
Redis connection URL for caching. The Python service uses Redis database 0.Format:
redis://[host]:[port]/[db]Example:Python Service Configuration Summary
The Python service builds its database connection string based on theFLASK_ENV setting:
Development (FLASK_ENV=development):
FLASK_ENV=staging or FLASK_ENV=production):
FLASK_ENV=testing):
Node.js Service Variables
The Node.js service uses environment variables for database, JWT, and server configuration.Server Configuration
Port number for the Node.js server to listen on.Example:
Node.js environment mode. Controls logging and other environment-specific behavior.Options:
development- Enables SQL query loggingproduction- Disables SQL query logging
Database Configuration
PostgreSQL host for database connection.Example:
PostgreSQL port for database connection.Example:
PostgreSQL username for database connection.Example:
PostgreSQL password for database connection.Example:
PostgreSQL database name.Example:
Security
Secret key for JWT token signing and verification. JWT tokens expire after 24 hours.Example:Generate a secure key:
Caching
Redis connection URL for caching. The Node.js service uses Redis database 1.Format:
redis://[host]:[port]/[db]Example:Docker Compose Environment
When using Docker Compose, environment variables are set in thedocker-compose.yml file:
Python Service Docker Environment
Node Service Docker Environment
Using .env Files
For local development, create a.env file in each service directory:
Python Service .env
Node Service .env
Environment-Specific Configuration
Development
Optimal settings for local development:Staging
Settings for staging environment:Production
Settings for production environment:Security Best Practices
Secret Management
- Never use default secrets in production
- Generate strong random secrets:
- Use secret management tools: AWS Secrets Manager, HashiCorp Vault, etc.
- Rotate secrets regularly
Database Credentials
- Use strong passwords: Minimum 16 characters with mixed case, numbers, and symbols
- Restrict database access: Only allow connections from application services
- Use SSL/TLS: Enable SSL connections for production databases
- Principle of least privilege: Grant only necessary permissions
Environment Isolation
- Separate credentials per environment: Different secrets for dev, staging, and production
- Network isolation: Use private networks for database and Redis
- Access control: Implement proper firewall rules and security groups
Troubleshooting
Database Connection Issues
If services can’t connect to the database:- Verify environment variables: Check that
DB_HOST,DB_PORT,DB_USER,DB_PASSWORD, andDB_NAMEare correct - Check network connectivity: Ensure services can reach the database host
- Verify credentials: Test database login manually:
Configuration Mismatches
For Python service configuration issues:- Development mode: Uses
DATABASE_*variables - Staging/Production mode: Uses
DB_*variables (exceptDATABASE_HOST) - Ensure you’re setting the correct variables for your
FLASK_ENV
Redis Connection Issues
If caching isn’t working:- Check Redis URL format: Should be
redis://host:port/db - Verify Redis is running:
redis-cli pingshould returnPONG - Check database separation: Python uses DB 0, Node uses DB 1
Next Steps
- Learn about Docker deployment
- Review the Python API documentation
- Review the Node API documentation
- Set up monitoring and logging for your deployment