Repository navigation
Provider kit: write the connection lifecycle once, so a provider is a client + a mapper #4915
jaysbeekay
started this conversation in
Feature Requests
Replies: 2 comments
|
I love this proposal! It prepares us for what is to come later (a bigger overhaul of the |
0 replies
|
This is one of the reasons I am holding off on merging new |
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Describe the feature
Today each account provider (bank, broker, crypto) ships its own full copy of the connection lifecycle: an items controller, item and account models, a syncer, an unlinking concern, a connection card, a settings panel, setup and select-existing views, and a route block. Only two parts actually differ between providers: the API client and the mapping from the provider's payload to
Account::ProviderImportAdaptercalls.The proposal is to do for the top of the stack what
ProviderImportAdapteralready did for the bottom:ProviderItem/ProviderAccountabstract base classes, sitting over the existing*_items/*_accountstables, so there are no data migrations and no table consolidation.accounts,transactions(account, since:), and optionallyholdingsandbalance);FAMILY_PANELS,PANEL_SYNCABLE_TYPES,load_provider_items,provider_summary,ProviderConnectionStatus,Provider::Metadata::REGISTRY, the reset list, the/accountsivars and empty-state check) are derived from the declarations. Theprovider:familygenerator then only creates new files instead of regex-patching existing ones (see provider:family generator has drifted from the current bank-sync / provider-registry architecture #2546).Proposed proof: convert Lunch Flow, Mercury and Brex together, since they are the closest clones and Brex already has an
AccountFlowextraction to start from. Success means those three lose their controller, card, setup views, syncer and unlinking files, while their existing tests pass unchanged. If that works, convert one lineage per PR (Kraken/CoinSpot/Binance/Coinbase, then Monobank/Up/Fio, ...). Each PR deletes code and changes no behaviour. Bespoke providers can stay as they are until there's a reason to move them.Why is this feature important?
1. Every cross-cutting fix becomes N fixes. Since May, 192 commits touched provider controllers, models or views. The biggest fan-outs:
#4048 is a privacy fix, and even within that PR a second commit was needed for the Kraken, CoinSpot and Binance stale-rate warnings and the Trade Republic totals, which still read every account on the connection.
2. N fixes eventually means N−k fixes. Hand-maintained provider lists drift, and the drift is silent:
Family::Syncerreflects over all 28.3. Most of a provider is lifecycle boilerplate. The 28 account providers come to about 87,000 lines (app + lib, excluding locales and tests). For a simple provider, the lifecycle part (everything except client, mapping and importer) is most of it:
4. Much of it is literal copies. With provider names normalised, the connection card partial is identical between Kraken and CoinSpot, and between Lunch Flow and Mercury.
setup_accountsdiffers by two lines between Lunch Flow and Mercury.5. The pattern already works one layer down. All providers write through
Account::ProviderImportAdapter, so dedupe and pending matching are fixed once for everyone.ProviderDisconnectable,ProviderItemOwnable,render_provider_panelandBrexItem::AccountFlowshow the same direction starting in the lifecycle layer.The payoff: a new provider becomes a client, a mapper and a declaration, which is a much smaller review. A fix like #4048 or #4718 lands once.
Additional context, screenshots, and relevant links
name,status,scheduled_for_deletion,pending_account_setup,sync_start_date,institution_*) already line up across the*_itemstables.Provider::*Adapterclasses (which already self-register withProvider::Factory) or in a new object?/settings/providers).All reactions