The bond system

Every capability in a molecule app sits behind an interface with swappable providers; change vendors by changing one line instead of rewriting the app.

The idea

A core package is an interface plus an accessor, never a concrete implementation. A bond package is a swappable provider that implements it. Your app’s bonds.ts wires which provider is live; that is configuration, not coupling:

// interface: what the app codes against
import { bond } from '@molecule/api-bond'
// provider: one swappable implementation
import { mailgun } from '@molecule/api-emails-mailgun'

bond('emails', mailgun)

Application code asks the category for the interface and never learns which vendor is behind it. Categories with several live providers (like ai) use named bonds, bond('ai', 'anthropic', ai), so they coexist.

Swapping providers

Because every provider implements the same interface, swapping is mechanical: one command rewrites the wiring, migrations included where needed:

mlcl swap @molecule/api-database-mysql      # Postgres → MySQL
mlcl swap @molecule/api-emails-smtp         # Mailgun → plain SMTP

Nothing else in the app changes: same handlers, same calls, different vendor. Stripe → another processor, one OAuth provider for another, one AI host for another: all one-line moves.

Common categories

CategoryProviders include
databasePostgreSQL, MySQL, SQLite, D1/Cloudflare
aiAnthropic, OpenAI, DeepSeek, Moonshot, Z.ai (named bonds per provider)
emailsMailgun, SMTP
paymentsStripe and other processors
authOAuth providers, password auth
files / storagelocal, S3-compatible
code-sandboxDocker, E2B, remote microVM hosts

The authoritative list for any category is the catalog: mlcl search <category> or the packages pages.

Why it matters

  • No vendor lock-in: the provider a demo shipped with is not the provider production must keep.
  • Per-requirement selection: pick MySQL because the project needs MySQL; nothing in the code changes shape.
  • Self-hosting works everywhere: many categories have an open-source provider alongside the paid vendors.