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
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
- ✅ Updates to settings controller and view
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
| Aspect | provider:family | provider:global |
|---|---|---|
| Credentials storage | provider_items table (per-family) | settings table (global) |
| Credential encryption | ✅ Yes (ActiveRecord encryption) | ❌ No (plaintext in settings) |
| Family isolation | ✅ Complete (each family has own credentials) | ❌ None (all families share) |
| Files generated | 9+ files | 5 files |
| Migration includes credentials | ✅ Yes | ❌ No |
| Controller | ✅ Yes (simple CRUD) | ❌ No |
| View | ✅ Manual form panel | ❌ Auto-generated |
| Routes | ✅ Yes | ❌ No |
| UI location | /settings/providers (always) | /settings/providers (self-hosted only) |
| ENV variable support | ❌ No (per-family can’t use ENV) | ✅ Yes (fallback) |
| Use case | User brings own API key | Platform provides API access |
| Examples | Lunch Flow, SimpleFIN, YNAB | Plaid, OpenAI, TwelveData |
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:
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
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.
Examples
Example 1: Simple API key provider
Example 2: OAuth provider
Example 3: Complex provider
Tips & best practices
1. Always run migrations
2. Test in console
3. Use proper encryption
Always check that encryption is set up:4. Implement proper error handling
5. Add integration tests
Troubleshooting
Panel not showing
- Check that the provider is excluded in
settings/providers_controller.rb - Check that the instance variable is set
- Check that the section exists in
settings/providers/show.html.erb
Form not submitting
- Check routes are properly added:
rails routes | grep my_bank - Check turbo frame ID matches between view and controller
Encryption not working
- Check credentials are configured:
rails credentials:edit - Add encryption keys if missing
- Or use environment variables
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