Skip to main content
Handbook/Architect/Chapter 51 · Integrations

Wrap the Services You Depend On

Share

Share this page

Pass it to someone who needs it.

Key takeaway: Put a vendor behind your own door

Your agent wires a payment SDK, an email service, and an AI API straight into feature code, wherever each one is needed. It works, until the vendor changes its prices, you want to switch providers, or the SDK ships a breaking change. Now that one change is scattered across twenty files. This chapter gets each outside service behind one door you control.

5.6.1A vendor threaded everywhere is a rewrite waiting

When feature code calls a vendor's SDK directly, the vendor is glued into your whole app. Every screen that charges a card imports the payment library, every place that emails a user imports the mail library. This is vendor lock-in: the outside service is now welded into dozens of files.

The day the vendor raises its price, breaks its SDK, or loses your trust, the swap means editing everywhere it appears. Vendor entanglement is one of the most common rewrite triggers in AI-built apps. Note this is a service you consume, distinct from the API you expose.

5.6.2Put each service behind one adapter

Give each outside service one adapter you own, the thin-wrapper shape named in the patterns chapter. Your feature code calls your function (charge(...)), and only the adapter file ever imports the vendor. That one file is the whole surface the rest of your app sees.

// features/checkout.ts (feature code, vendor-free) import { charge } from "../lib/payments" await charge({ amountCents, currency, customerId }) // lib/payments.ts (YOUR adapter: the ONLY file // allowed to import the vendor SDK) import Stripe from "stripe" const stripe = new Stripe(process.env.STRIPE_KEY) export async function charge(p) { const intent = await stripe.paymentIntents.create({ amount: p.amountCents, currency: p.currency, customer: p.customerId, }) return { id: intent.id, status: intent.status } }
Feature code calls your adapter; only the adapter imports the vendor.

5.6.3Now you can swap without a rewrite

To move from one provider to another, or to absorb a breaking SDK change, you rewrite the inside of that one adapter. The charge function keeps the same name and the same shape, so every file that calls it stays untouched.

The rest of your app never notices the vendor changed. That is exactly the "extend without rewrites" this part is built around: a swap that could have touched twenty files now touches one.

5.6.4Keep the door thin and in your words

An adapter is only useful if it stays narrow. Expose the handful of operations your app actually needs, named in your own terms (charge, refund, sendEmail), not the vendor's entire API surface.

Do not let the vendor's own types leak back out through the door. If charge returns the vendor's raw response object, every caller is quietly coupled to that vendor again, and you are back where you started. Return a small shape you define, the same narrow-interface idea from the coupling chapter.

This prompt has your agent pull every vendor behind its own door:

Ready prompt
Act as a senior engineer hardening my vendor boundaries. Find every place my code touches an external service directly: a payment SDK, an email or SMS provider, an LLM API, an auth SDK. For each one, move the vendor call behind a single thin adapter I own, so exactly one file imports that vendor's SDK. Expose only the operations my app needs, named in my own terms, and never leak the vendor's own types back through the adapter. List each service, the one file that should own it, and the functions the rest of my app calls instead. My services and where they are called:

Do this now: paste the prompt so your agent finds every direct vendor call and moves each behind one adapter you own, then confirm exactly one file imports each SDK.

Mahmoud Zalt

Mahmoud Zalt

Software engineer, 16+ yrs · built Sistava.com in 3 months, idea to production, using these methods

Resources
Contribute
Donate

Support my work

A small tip keeps the free work coming.

© 2026 Mahmoud Zalt. Free to read, not to republish.
Copyright & license