Configuration
Dracory uses a structured configuration loaded at startup from .env and environment variables. A concrete configImplementation implementing config.ConfigInterface is created by config.NewFromEnv() 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, payments, SEO). Store flags are centralized in ConfigInterface — each store has a Get<Name>StoreUsed() bool method. Store factory functions live in internal/config/store_builders.go.
App Configuration
Main options (name, host, port, environment, debug, database, email, etc.) are populated by config.NewFromEnv() and exposed through the application. Additional app-level features include:
- Maintenance mode –
SetAppMaintenanceEnabled(bool)/GetAppMaintenanceEnabled()andSetAppMaintenanceFilePath(string)/GetAppMaintenanceFilePath()for controlled downtime.
Auth Configuration
Authentication settings include registration toggle, allowed emails list, password auth toggle, and a CSRF secret:
- CSRF Secret –
SetCsrfSecret(string)/GetCsrfSecret(). In production and staging environments,AUTH_CSRF_SECRETmust be set explicitly. In other environments a random secret is generated automatically and a warning is logged.
Database Configuration
Database settings support multiple drivers (sqlite, turso, postgres, mysql), connection pooling, charset, timezone, SSL mode, and optional DSN override and table prefix. Multi-connection support is available via GetDatabaseConnections() and GetDatabaseConnectionByName(name).
Store Configuration
Stores are initialized in the application bootstrap (internal/app/datastores.go) and receive their dependencies (DB, caches, logger) from the application. Store factory functions are defined in internal/config/store_builders.go. Each store's enabled flag is read from the centralized ConfigInterface.
Accessing Configuration Values
Access configuration through the application instance implementing app.AppInterface:
// given `application` is app.AppInterface
cfg := application.GetConfig() // config.ConfigInterface
appName := cfg.GetAppName()
host := cfg.GetAppHost()
port := cfg.GetAppPort()
env := cfg.GetAppEnv()
debug := cfg.GetAppDebug()
csrfSecret := cfg.GetCsrfSecret()
Configuration Lifecycle
Configuration is loaded once at startup and kept in memory via the application instance:
- Fast access via getters on
config.ConfigInterface. - Editing
.envrequires an application restart to take effect. - Use environment-specific
.envfiles and the env encryption key when needed. - Encrypted environment variables are hydrated before other config sections read them.