Skip to main content

Overview

The Soft-Bee API supports multiple environment configurations to facilitate development, testing, and production deployments. The environment is controlled via the FLASK_ENV variable.
The application automatically loads environment-specific configuration files (.env.{environment}) if they exist, allowing you to override settings per environment.

Available Environments

The API supports four distinct environments:

Local

Used for local development on your machine.
FLASK_ENV
string
default:"local"
Set to local for local development environment
FLASK_ENV=local
Configuration Details:
  • DEBUG: True
  • TESTING: False
  • Default Database: postgresql://postgres:postgres@localhost:5432/softbee_local
  • Frontend URL: http://localhost:3000
  • Base URL: http://localhost:5000

Development

Used for development servers and team collaboration.
FLASK_ENV
string
Set to development for development server environment
FLASK_ENV=development
Configuration Details:
  • DEBUG: True
  • TESTING: False
  • Default Database: postgresql://postgres:postgres@localhost:5432/softbee_dev

Production

Used for production deployments.
FLASK_ENV
string
Set to production for production environment
FLASK_ENV=production
Production environment requires DATABASE_URL, JWT_KEY, and SECRET_KEY to be explicitly set. The application will raise an error if these are missing.
Configuration Details:
  • DEBUG: False
  • TESTING: False
  • Database: Must be provided via DATABASE_URL environment variable
  • Validation: Enforces presence of critical security variables

Testing

Used for automated testing and CI/CD pipelines.
FLASK_ENV
string
Set to testing for test environment
FLASK_ENV=testing
Configuration Details:
  • DEBUG: True
  • TESTING: True
  • Default Database: postgresql://postgres:postgres@localhost:5432/softbee_test
  • CSRF Protection: Disabled for easier testing

Environment Variables

General Configuration

SECRET_KEY
string
required
Flask secret key for session management and cryptographic operations
Never use the default value in production. Generate a secure random key.
SECRET_KEY=your-secret-key-here

URL Configuration

FRONTEND_URL
string
default:"http://localhost:3000"
URL of the frontend application (used for CORS and redirects)
BASE_URL
string
default:"http://localhost:5000"
Base URL of the API server
FRONTEND_URL=http://localhost:3000
BASE_URL=http://localhost:5000

Environment-Specific Files

You can create environment-specific .env files that override the main .env file:
FLASK_ENV=local
DATABASE_URL=postgresql://postgres:postgres@localhost:5432/softbee_local
DEBUG=True

Configuration Loading Priority

The application loads configuration in the following order:
  1. Loads .env file (if exists)
  2. Reads FLASK_ENV variable to determine environment
  3. Loads .env.{environment} file (if exists) - overrides step 1
  4. Applies environment-specific configuration class
  5. Environment variables override all file-based settings
Environment-specific files (.env.{environment}) override values from the main .env file, allowing you to maintain a base configuration with environment-specific overrides.

Example Setup

Local Development

# .env
FLASK_ENV=local
SECRET_KEY=dev-secret-key
JWT_KEY=dev-jwt-key
DATABASE_URL=postgresql://postgres:postgres@localhost:5432/softbee_local

Production Deployment

# Set via environment variables (recommended for production)
export FLASK_ENV=production
export SECRET_KEY=$(openssl rand -hex 32)
export JWT_KEY=$(openssl rand -hex 32)
export DATABASE_URL=postgresql://user:pass@host:5432/softbee_prod
In production, prefer setting sensitive values via environment variables or secret management systems rather than .env files.

Next Steps

Database Configuration

Learn how to configure PostgreSQL connections

JWT Configuration

Configure authentication and token settings

Build docs developers (and LLMs) love