Configuration

Typed TOML configuration, file discovery order, and environment overlay.

RustaSea reads typed configuration from TOML files in config/. The loader (rustasea_config::ConfigLoader) auto-discovers every config/*.toml:

  1. app.toml is always applied first, as the base layer.
  2. Remaining files are merged in sorted order.
  3. The process environment is applied last — environment variables always win over files.

.env files are supported via dotenvy.

Environment overrides

Nested keys use the __ separator. SERVICES__POSTMARK__KEY sets [services.postmark].key.

Laravel-style single-underscore vars are applied by typed consumers where wired:

PrefixTarget
APP_*AppConfig
LOG_*LoggingConfig
MAIL_*MailConfig
POSTMARK_API_KEY, RESEND_API_KEY, AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY, SLACK_BOT_*ServicesConfig

Config files

FilePurpose
config/app.tomlApplication identity, locale, encryption key, maintenance mode
config/auth.tomlGuards, providers, password-reset brokers
config/cache.tomlDefault store, key prefix, store definitions
config/database.tomlNamed SQL/Redis connections, pool tuning, migrations
config/queue.tomlDefault connection, driver connections, batching, failed jobs
config/session.tomlSession driver, lifetime, cookie policy
config/fortify.tomlAuth feature toggles, route surface, limiters
config/logging.tomlDefault channel, deprecations, named channels
config/mail.tomlDefault mailer, sender, named mailers
config/services.tomlThird-party credentials (Postmark, Resend, AWS SES, Slack)
config/storage.tomlDefault disk, read-through routing, disk definitions
config/mongo.tomlStandalone MongoDB connection
config/broadcasting.tomlBroadcast connection and driver tables
config/cors.tomlCORS allow-list and credentials flag

Key environment variables include APP_NAME, APP_ENV, APP_DEBUG, APP_URL, APP_KEY, APP_LOCALE, DATABASE_URL, DB_*, REDIS_*, QUEUE_CONNECTION, SESSION_*, MAIL_*, and BROADCAST_CONNECTION.

Database connections

rustasea-orm owns config-driven named connections, resolved lazily by ConnectionResolver. Both a legacy flat database.url and explicit [database.connections.<name>] tables are supported.

toml
[database]
default = "pgsql"          # connection used when no name is given

[database.connections.sqlite]
driver = "sqlite"
url = "sqlite://database.sqlite?mode=rwc"

[database.connections.pgsql]
driver = "postgres"
host = "127.0.0.1"
port = 5432
database = "rustasea"
username = "rustasea"
password = "secret"
  • Default switching — [database].default names the connection used by resolve(None); an explicit name overrides it.
  • Read/write split — add an optional [database.connections.<name>.read] (and/or .write) overlay to route reads to a replica. Omitted fields inherit the primary.
  • MongoDB — a connection with driver = "mongodb" resolves to a DatabaseConnection::Mongo handle behind the opt-in mongodb feature; without it, the connection resolves to a typed ConnectionError::UnsupportedDriver rather than panicking.
toml
[database.connections.mongo]
driver = "mongodb"
uri = "mongodb://127.0.0.1:27017"
database = "rustasea"

Last updated Sep 22, 2026