Configuration

Configure your Dracory application for different environments and needs.

Configuration

Dracory uses a structured configuration loaded at startup from .env and environment variables via internal/config/load.go. A concrete types.Config implementing types.ConfigInterface is created and injected into the application.

Environment Configuration

Use .env files for environment-specific configuration. Copy .env.example to .env and adjust values such as APP_ENV, APP_HOST, APP_PORT, and database credentials. The loader validates required keys and will error on missing values.

Configuration Scope

Configuration consolidates core settings (app, database, email, i18n, LLM, vault, media, daily analysis). There are no per-store config files; stores read from the centralized ConfigInterface.

App Configuration

Main options (name, host, port, environment, debug, database, email, etc.) are populated by config.Load() and exposed through the application.

Store Configuration

Stores are initialized in the application bootstrap and receive their dependencies (DB, caches, logger) from the application. They do not maintain separate config files.

Accessing Configuration Values

Access configuration through the application instance implementing types.AppInterface:

// given `application` is types.AppInterface
cfg := application.GetConfig() // types.ConfigInterface

appName := cfg.GetAppName()
host := cfg.GetAppHost()
port := cfg.GetAppPort()
env  := cfg.GetAppEnv()
debug := cfg.GetAppDebug()

Configuration Lifecycle

Configuration is loaded once at startup and kept in memory via the application instance:

  1. Fast access via getters on types.ConfigInterface.
  2. Editing .env requires an application restart to take effect.
  3. Use environment-specific .env files and the env encryption key when needed.
Menu