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:
- Fast access via getters on
types.ConfigInterface. - Editing
.envrequires an application restart to take effect. - Use environment-specific
.envfiles and the env encryption key when needed.