Accrue.Application (accrue v1.0.0)

Copy Markdown View Source

OTP Application module for Accrue — manages boot-time validation and the supervision tree.

What this is

Accrue follows an empty-supervisor pattern: it is a library, not a service. The supervisor starts with no children. Accrue does not start host-owned processes such as your Repo, Oban, ChromicPDF pool, or Finch pool — your application's supervision tree owns those.

What happens at boot

Before the (empty) supervisor starts, Accrue runs several validations:

  1. Config schema checkAccrue.Config.validate_at_boot!/0 validates the :accrue application environment against the NimbleOptions schema. Misconfiguration fails loudly at startup, before any state is touched.

  2. Auth adapter safety checkAccrue.Auth.Default.boot_check!/0 refuses to start in :prod when :auth_adapter still points at the dev-permissive default adapter.

  3. PDF adapter availability check — warns at boot if Accrue.PDF.ChromicPDF is configured but no ChromicPDF supervisor child is running in the host app's supervision tree.

  4. Oban queue / PDF pool size check — warns if the :accrue_mailers Oban queue concurrency exceeds the ChromicPDF pool size, which can cause back-pressure on invoice email rendering.

  5. Connect webhook secret collision check — warns when a Connect endpoint's webhook signing secret is byte-identical to a platform endpoint secret. Stripe issues a separate signing secret for Connect endpoints in the Dashboard; mixing them causes silent signature verification failures. See guides/connect.md.

  6. Company address / locale check — warns when customers have EU/CA preferred locales but :branding[:company_address] is unset. CAN-SPAM/CASL require a physical postal address in transactional emails for those locales.

Host app integration

Accrue.Application is started automatically by OTP when :accrue is listed as a dependency — host applications do not start it manually. Ensure your config/runtime.exs is complete before the application starts, as validation runs during start/2.