Provider generators, which make it easy to add new integrations with either global or per-family scope credentials.
Quick start
Two generators available
Quick examples
Global vs per-family: Which to use?
Use provider:global when:
- ✅ One set of credentials serves the entire application
- ✅ Provider charges per-application (not per-customer)
- ✅ You control the API account (self-hosted or managed mode)
- ✅ All families can safely share access
- ✅ Examples: Plaid, OpenAI, exchange rate services
Use provider:family when:
- ✅ Each family/customer needs their own credentials
- ✅ Provider charges per-customer
- ✅ Users bring their own API keys
- ✅ Data isolation required between families
- ✅ Examples: Lunch Flow, SimpleFIN, YNAB, personal bank APIs
Provider:family generator
Usage
Reserved field names
The generator rejects field names that are already defined on the items table. Passing a reserved name raises aThor::Error at generation time rather than producing broken migrations or inconsistent models.
Reserved names include: family_id, institution_id, institution_name, institution_domain, institution_url, institution_color, status, scheduled_for_deletion, pending_account_setup, sync_start_date, raw_payload, raw_institution_payload.
Note that family (without _id) is not reserved — the migration writes t.references :family, which creates family_id, so a field named family is not a collision.
Example: Adding a MyBank provider
What gets generated
This single command generates:- ✅ Migration for
my_bank_itemsandmy_bank_accountstables with credential fields - ✅ Models:
MyBankItem,MyBankAccount, andMyBankItem::Providedconcern - ✅ Adapter class for provider integration
- ✅ Simple manual panel view for provider settings
- ✅ Controller with CRUD actions and Turbo Stream support
- ✅ Routes
- ✅ Bank sync wiring: the settings controller’s
FAMILY_PANELSentry and sync maps, and aprovider_summarycase
ProviderLogo. That reads the provider’s Provider::Metadata::REGISTRY entry, which the generator does not create, so add one in app/models/provider/metadata.rb. See the providers LLM guide for the fields it reads (domain, logo_text, logo_color, logo_icon) and which are used when Brandfetch has no icon or is not configured.
The item partial declares visible_accounts: as a strict local. Callers must pass the accounts to display explicitly. The rendered account list uses that local; the partial can still query the item’s accounts for summary counts. Pass only the accounts you want shown:
visible_card_accounts(item) to respect the current user’s account visibility. A strict local requires an explicit argument; it does not enforce authorization, so callers must not replace the filtered list with all accounts indiscriminately.
Key characteristics
- Credentials: Stored in
my_bank_itemstable (encrypted) - Isolation: Each family has completely separate credentials
- UI: Manual form panel at
/settings/providers - Configuration: Per-family, self-service
Provider:global generator
Usage
Example: Adding a Plaid provider
What gets generated
This single command generates:- ✅ Migration for
plaid_itemsandplaid_accountstables without credential fields - ✅ Models:
PlaidItem,PlaidAccount, andPlaidItem::Providedconcern - ✅ Adapter with
Provider::Configurable - ❌ No controller (credentials managed globally)
- ❌ No view (UI auto-generated by
Provider::Configurable) - ❌ No routes (no CRUD needed)
Key characteristics
- Credentials: Stored in
settingstable (global, not encrypted) - Sharing: All families use the same credentials
- UI: Auto-generated at
/settings/providers(self-hosted mode only) - Configuration: ENV variables or admin settings
Important notes
- Credentials are shared by all families - use only for trusted services
- Only available in self-hosted mode (admin-only access)
- No per-family credential management needed
- Simpler implementation (fewer files generated)
Comparison table
What gets generated (detailed)
1. Migration
File:db/migrate/xxx_create_my_bank_tables_and_accounts.rb
Creates two complete tables with all necessary fields. The generator writes the Rails version in use when it runs, taken from Rails::VERSION::MAJOR and Rails::VERSION::MINOR joined by a dot (for example, 8.1). The version in any generated migration is then fixed — it pins the semantics the migration was written against and is not rewritten by later upgrades.
2. Models
File:app/models/my_bank_item.rb
The item model stores per-family connection credentials:
app/models/my_bank_account.rb
The account model stores individual account data from the provider:
app/models/my_bank_item/provided.rb
The Provided concern connects the item to its provider SDK:
3. Adapter
File:app/models/provider/my_bank_adapter.rb
4. Controller
File:app/controllers/my_bank_items_controller.rb
The generated controller inherits StreamExtensions through ApplicationController and uses frame_redirect_to for missing-credential exits. The account-linking flow actions (preload_accounts, select_accounts, select_existing_account) call frame_redirect_to when a required credential check fails. A plain redirect_to inside a Turbo frame follows the redirect inside the frame, so the resulting page renders inside the modal and the flash message is never shown. frame_redirect_to detects whether the request came from a Turbo frame and, when it did, renders a frame containing a turbo-stream redirect action, which causes a full-page visit instead of a frame navigation.
redirect_to in those credential-check guards is that frame_redirect_to uses turbo_frame_request? to detect whether the request originated inside a Turbo frame. When it did, it renders a frame that carries a turbo-stream redirect action, which exits the frame and performs a full-page visit to the target path with the alert flash intact. For requests outside a frame it falls back to a normal redirect_to.
Customization
After generation, you’ll typically want to customize three files:1. Customize the adapter
Implement thebuild_provider method in app/models/provider/my_bank_adapter.rb:
2. Update the model
Add custom validations, helper methods, and business logic inapp/models/my_bank_item.rb:
3. Customize the view
Edit the generated panel viewapp/views/settings/providers/_my_bank_panel.html.erb to add custom content.
StyledFormBuilder (used via styled_form_with) accepts these options on every text-type field in addition to standard HTML attributes:
Example — adding a hint to the API key field:
label: false or inline: true) receive the hint directly after the input, without a wrapper, so their layout stays unchanged.
Examples
Example 1: Simple API key provider
Example 2: OAuth provider
Example 3: Complex provider
Reserved field names
The generator rejects field names that conflict with columns already defined in the standard items table. Passing a reserved name raises an error at generation time rather than failing silently duringdb:migrate.
Reserved names (cannot be used as custom fields):
Note that
family itself is not reserved — the migration uses t.references :family which creates family_id, so a field named family does not collide.
If you need to customize the behavior of a standard column, do so in the model after generation rather than re-declaring it as a custom field.
Tips & best practices
1. Always run migrations
2. Test in console
3. Use proper encryption
Sure uses theEncryptable concern and encryption_ready? to make encryption optional — sensitive fields using this guard are encrypted when all three ACTIVE_RECORD_ENCRYPTION_* keys are configured or Active Record encryption is configured through Rails credentials. Auto-derived runtime keys alone do not enable this opt-in guard. Use this pattern in generated models:
encryption_ready? with throwaway keys, so encryption paths are exercised on every pull request without any manual configuration. Guard your own encryption tests the same way to get that coverage for free:
4. Implement proper error handling
5. Add integration tests
Reserved field names
Theprovider:family generator rejects field names that collide with columns already present on every items table. Passing a reserved name raises an error at generation time rather than failing silently at db:migrate.
Reserved names (cannot be used as custom fields):
institution_id, institution_name, institution_domain, institution_url, institution_color, status, scheduled_for_deletion, pending_account_setup, sync_start_date, raw_payload, raw_institution_payload, family_id
If you need to store data that overlaps with one of these columns, use the built-in column directly — it already exists on the generated table.
Troubleshooting
Reserved field name error
If the generator raisesThor::Error: '<field>' is a reserved field name, remove that field from the command. The items table already defines it, so declaring it again would produce a duplicate migration column and inconsistent model code. See Reserved field names for the full list.
Panel not showing
- Check that
FAMILY_PANELSinsettings/providers_controller.rbincludes an entry for the provider: - Check that the instance variable is set in the controller’s
showaction: - Check that
provider_summaryinapp/helpers/settings_helper.rbhas a"my_bank"case.
Form not submitting
- Check routes are properly added:
rails routes | grep my_bank - Check the panel root ID matches the
turbo_idinFAMILY_PANELS: the view must haveid="my_bank-providers-panel"at its root, whichrender_provider_panelreplaces via Turbo Stream.
Encryption not working
- Check that the model defines
encryption_ready?(as the generator does) or includesEncryptable, and calls the helper beforeencrypts. - Configure encryption through Rails credentials or set all three environment variables:
ACTIVE_RECORD_ENCRYPTION_PRIMARY_KEY,ACTIVE_RECORD_ENCRYPTION_DETERMINISTIC_KEY, andACTIVE_RECORD_ENCRYPTION_KEY_DERIVATION_SALT. Generate values withopenssl rand -hex 32for each. - Restart the app after setting the variables.
- If data was written before encryption was enabled, check whether the model and its fields are listed in
lib/tasks/security_backfill.rake; newly generated providers are not discovered automatically. For covered models,bin/rails security:backfill_encryptiondefaults to a dry run. Review its output before applying the backfill withDRY_RUN=false bin/rails security:backfill_encryption. See Turning on Active Record encryption after first boot.
Reserved field name error
The generator rejects field names that collide with columns already defined on the items table. If you see aThor::Error like:
institution_id, institution_name, institution_domain, institution_url, institution_color, status, family_id, scheduled_for_deletion, pending_account_setup, sync_start_date, raw_payload, raw_institution_payload.
Note that family (without _id) is not reserved — t.references :family creates family_id, so a field named family does not collide.
NoMethodError: undefined method 'syncable' during family sync
If a freshly generated provider raises this error and takes down the nightly family sync, the generated item model is missing the syncable scope. Add it manually:
Advanced: Creating a provider SDK
For complex providers, consider creating a separate SDK class:Summary
The per-familyProvider Rails generator system provides:
- ✅ Fast development - Generate in seconds, not hours
- ✅ Consistency - All providers follow the same pattern
- ✅ Maintainability - Clear structure and conventions
- ✅ Flexibility - Easy to customize for complex needs
- ✅ Security - Built-in encryption for sensitive fields
- ✅ Documentation - Self-documenting with descriptions