billing-kit-adapters — diagrams

Synced from billing-kit-adapters/docs/DIAGRAMS.md — the repo is canonical.

The mermaid sources for this repo. They live here rather than in the README because npm renders no mermaid: on the package page a fence like this one ships as raw DSL. GitHub and the QuxKit docs site both draw them. The README carries an ASCII equivalent of each.

Where an adapter sits: the core reads capabilities, never a name

flowchart LR
    core["billing-kit core<br/>metering · pricing · ledger"]
    subgraph iface["BillingProvider&lt;Caps&gt;"]
        m["ensureCustomer · findCustomer<br/>ensureSubscription · settle<br/>refund · verifyWebhook"]
    end
    subgraph adapters["adapters/*  (this repo)"]
        a1["Chargebee"]
        a2["Recurly"]
        a3["Braintree"]
        a4["…yours"]
    end
    core -->|reads capabilities| iface
    adapters -.implements.-> iface
    classDef c fill:#0d9488,stroke:#0f766e,color:#fff
    class core c

Settling a closed period, end to end

sequenceDiagram
    participant BK as billing-kit core
    participant A as adapter (this repo)
    participant P as provider API
    BK->>A: settle(closed period)
    A->>P: create invoice / capture
    P-->>A: settlement result
    A-->>BK: exact amounts (idempotent)
    BK->>BK: post balanced ledger
    Note over A,P: verifyWebhook confirms<br/>settlement out-of-band