Skip to main content
Every BackAnt project ships with a .env file at the project root. This file is loaded at startup by python-dotenv and mapped to the Environment class in api/startup/Environment.py.

Default .env

POSTGRES_USER=postgres
POSTGRES_PASSWORD=test
POSTGRES_DB=postgres
DB_URL=postgres
CLEAR_DB=False
FLASK_APP=app.py
FLASK_ENV=development
TESTING=False
Never commit real credentials to version control. Add .env to .gitignore and use secrets management in production.

Database variables

VariableDescriptionDefault
POSTGRES_USERPostgreSQL usernamepostgres
POSTGRES_PASSWORDPostgreSQL passwordtest
POSTGRES_DBDatabase namepostgres
DB_URLHostname of the PostgreSQL serverpostgres (Docker service name)
CLEAR_DBDrop and recreate all tables on startupFalse
DB_URL should be set to postgres when running inside Docker Compose (the service name resolves as a hostname), and localhost when running Flask directly outside of Docker.
Set CLEAR_DB=True only during development. It drops all tables on every restart.

Flask variables

VariableDescriptionDefault
FLASK_APPEntry point for Flaskapp.py
FLASK_ENVdevelopment enables debug mode and reloaderdevelopment
TESTINGEnables test mode in FlaskFalse

AWS / S3 variables

These are used by the built-in AWSClient in api/apis/aws/AWSClient.py.
VariableDescription
S3_ACCESS_KEYAWS access key ID
S3_SECRET_KEYAWS secret access key

AWS Cognito variables

Used when integrating Cognito for authentication.
VariableDescription
COGNITO_REGIONAWS region (e.g. eu-central-1)
COGNITO_USERPOOL_IDCognito User Pool ID
COGNITO_APP_CLIENT_IDCognito App Client ID
COGNITO_APP_CLIENT_SECRETCognito App Client Secret
COGNITO_ACCESS_KEY_IDIAM access key with Cognito permissions
COGNITO_SECRET_ACCESS_KEYCorresponding IAM secret key

Environment class

All variables are accessed at runtime via the myEnvironment singleton in api/startup/Environment.py. Never read os.environ directly — import from the singleton instead:
from startup.Environment import myEnvironment

db_url = myEnvironment.DB_URL
region = myEnvironment.COGNITO_REGION

Local development without Docker

Set DB_URL=localhost and ensure PostgreSQL is running locally:
DB_URL=localhost
POSTGRES_USER=postgres
POSTGRES_PASSWORD=test
POSTGRES_DB=postgres
CLEAR_DB=False
Then run Flask directly:
cd my-api
flask run