Skip to content

Configuration

LibreFolio uses a .env file for configuration, powered by Pydantic's BaseSettings. This allows for easy management of environment variables for both local development and Docker deployments.

.env File

The .env file is located at the root of the project. A sample file, .env.example, is provided. To get started, simply copy it:

cp .env.example .env

Key Environment Variables

  • PORT: The port on which the FastAPI server will run.

    • Default: 8000
  • DATABASE_URL: The connection string for the main application database.

    • Default: sqlite:///./backend/data/sqlite/app.db
  • TEST_DATABASE_URL: The connection string for the test database.

    • Default: sqlite:///./backend/data/sqlite/test_app.db
  • SECRET_KEY: A secret key used for signing JWTs (JSON Web Tokens) for authentication.

    • Important: For production, this should be changed to a long, random, and secret string.
  • ACCESS_TOKEN_EXPIRE_MINUTES: The expiration time for access tokens in minutes.

    • Default: 30
  • LOG_LEVEL: The logging level for the application.

    • Options: DEBUG, INFO, WARNING, ERROR, CRITICAL
    • Default: INFO
  • LIBREFOLIO_TEST_MODE: A flag to indicate if the application is running in test mode. This is used internally by the test suite.

    • Set to 1 to enable test mode.

How it Works

The settings are loaded into a Pydantic Settings class located in backend/app/config.py. This class automatically reads variables from the .env file and validates their types.

This approach provides: - Type Safety: Settings are validated at application startup. - Centralized Configuration: All settings are defined in one place. - Flexibility: Settings can be provided via a .env file or as actual environment variables, making it easy to configure in different environments (local, Docker, etc.).