Skip to content

Environment Variables

The backend reads its configuration from environment variables. A .env file is optional — loading is done through godotenv and every variable has a safe default for local development.

The reference template lives at backend/.env.example:

# Server
PORT=8080
DATABASE_URL=postgres://kazier:kazier@localhost:5432/kazier_dev?sslmode=disable
UPLOAD_DIR=./uploads
MAX_FILE_SIZE_MB=50
OCR_LANG=fra+eng
# Security — change in production (never commit)
AUTH_SECRET=dev-secret-change-me
# First admin (created only if the users table is empty)
ADMIN_USERNAME=admin
ADMIN_PASSWORD=change-me
VariableDefaultDescription
PORT8080HTTP listening port.
DATABASE_URLpostgres://kazier:kazier@localhost:5432/kazier_dev?sslmode=disablePostgreSQL connection URL (lib/pq).
UPLOAD_DIR./uploadsDirectory where uploaded physical files are stored as <UPLOAD_DIR>/<user_id>/<resource_id>.<ext>.
MAX_FILE_SIZE_MB50Maximum upload size in MB. Exceeding it returns FILE_TOO_LARGE (HTTP 413).
OCR_LANGfra+engTesseract language list for OCR jobs (+-separated).
AUTH_SECRETdev-secret-change-meSigning secret for PASETO v4-local tokens. Must be random and secret in production.
ADMIN_USERNAMEUsername of the bootstrap admin. Required on first start if the users table is empty.
ADMIN_PASSWORDPassword of the bootstrap admin. Required on first start.

The first admin is created only when the users table is empty. If the user table is empty and ADMIN_USERNAME or ADMIN_PASSWORD is missing, the server refuses to start.

The environment never overwrites an existing account — admin credentials are ignored on subsequent starts.

  • Set a strong random AUTH_SECRET (e.g. openssl rand -hex 32).
  • Change ADMIN_PASSWORD.
  • Use a dedicated PostgreSQL user/password (not kazier/kazier).
  • Use a DATABASE_URL with real credentials and an external database if needed.
  • Back up UPLOAD_DIR and the database.
  • Never commit a .env file (reference: backend/.env.example).