ESP abstracted behind a common interface
Why it matters
When the ESP SDK is imported and called in six different worker files, route handlers, and service modules, switching providers requires auditing and rewriting every one of those call sites. More practically, a team that needs to rotate to a backup ESP during an outage must make coordinated changes across the codebase under time pressure. ISO-25010:2011 maintainability.modifiability requires that changes to one component do not cascade to unrelated modules — direct SDK spread is the structural cause of that cascade.
Severity rationale
High because tight coupling to a specific ESP SDK prevents safe provider rotation and forces disruptive multi-file changes whenever the ESP contract changes.
Remediation
Create an EmailProvider interface in lib/email/types.ts and a concrete adapter in lib/email/providers/sendgrid.ts. All other application code calls only the interface:
// lib/email/types.ts
export interface EmailProvider {
send(message: EmailMessage): Promise<{ messageId: string }>
healthCheck(): Promise<boolean>
}
The ESP SDK import belongs in at most 2 files: the adapter implementation and its test. Workers, route handlers, and service modules import the interface, not @sendgrid/mail or equivalent.
DetectionPro
The detection method for this pattern is part of AuditBuffet Pro.
The full method (what to look for, pass and fail conditions, and how results get reported) ships inside the Sending Pipeline & Infrastructure Audit. The pattern definition, severity rationale, and remediation remain openly licensed under CC-BY-4.0.
External references
- iso-25010:2011 · maintainability.modifiability — Modifiability
Taxons
History
- 2026-04-18·v1.0.0·Initial import from sending-pipeline-infrastructure·automated