SOVEREIGNTY.
/// PROVIDER_ADAPTER_PATTERN Framework-neutral provider contracts for billing, communication, storage, and identity, with Django and FastAPI adapters.
UNIFIED INTERFACES FOR
The Architectural Shift
Move from fragile, tightly-coupled implementations to robust, provider-agnostic domain logic.
Vendor Captivity
Direct SDK usage scatters vendor-specific logic across your entire codebase. Changing providers means rewriting your business.
Adapter Pattern
Code against a stable, unified interface. The implementation details are abstracted away. Swap providers via configuration.
UNIFIED CAPABILITIES.
Explicit provider capability boundaries across billing, communication, identity, storage, and agent tooling.
Universal Billing
Stripe, PayPal, and Square adapters for customers, payments, subscriptions, catalog, checkout, invoices, refunds, and webhooks.
- Provider-neutral customer and subscription flows
- Stripe catalog discovery, meters, prices, and Entitlements
- Explicit capability errors where providers differ
Communication Hub
Direct SMTP and Django-anymail email paths, plus Twilio and AWS SNS SMS adapters.
- Consistent email and SMS send contracts
- Optional dependencies remain provider-scoped
- Normalized configuration and error handling
Identity & Auth
Use Auth0 or WorkOS behind one identity-platform contract, with Stripe Identity verification as a separate capability.
- Authorization URL, code exchange, session, and logout flows
- Provider selection by application configuration
Storage Agnosticism
Write files to S3, Azure Blob, GCS, or Local Disk with one API.
- Uniform signed URL generation
- CDN Integration helpers
Framework adapters
Python core, thin integrations
Configure SwapLayer directly in Python, load settings from Django, or attach the same validated settings to a FastAPI application.
- • Process-local framework-neutral configuration
- • Django settings, model, admin, and storage integration
- • FastAPI application-state adapter
Agent interface
Scoped MCP tooling
The optional swaplayer-mcp command helps agents inspect redacted configuration, compare providers, troubleshoot setup, and generate migration guidance.
- • Install with
swaplayer[mcp] - • Secrets are redacted from configuration output
- • Transactional production operations remain outside the MCP surface
Designed for Developer Sanity
Stop mocking 4 different third-party libraries in your tests. SwapLayer provides standard, predictable exceptions and responses.
Standardized Exceptions
Catch `PaymentError` instead of `stripe.error.CardError` or `braintree.AuthenticationError`.
Testability First
Adapter pattern makes mocking trivial. Test your business logic purely against the abstract interface.
Strict Typing
Fully typed interfaces for VS Code autocompletion and MyPy compliance.
def process_payment(user): try: # Interface remains consistent provider.charge(amount=2000, currency='usd') except PaymentDeclinedError: # Catches Stripe, PayPal, or any provider error return notify_user("Payment failed")
INTEGRATION
1 Install the package
2 Configure providers in settings.py
# settings.py
# Switch providers simply by changing the key or backend
PAYMENT_PROVIDER = 'stripe'
STRIPE_SECRET_KEY = env('STRIPE_SECRET_KEY')
IDENTITY_PROVIDER = 'auth0' # or 'workos'
STORAGE_PROVIDER = 'django' # Wraps S3/GCS/Azure
DEFAULT_FILE_STORAGE = 'storages.backends.s3boto3.S3Boto3Storage'
Migration blueprint
How teams remove lock-in without rewrites
SwapLayer is designed for staged migrations. Keep your existing provider in production, add a second provider behind the same interface, then progressively shift traffic while preserving one application contract.
Phase 1 — Normalize
Wrap the incumbent provider using SwapLayer adapters and map provider-specific errors into domain-level errors.
Phase 2 — Parallelize
Connect a second provider in shadow mode and compare outcomes through structured logs and contract tests.
Phase 3 — Cut over
Switch one configuration flag by market or feature segment, with fallback paths ready if anomaly rates increase.
Implemented boundaries teams can verify
- • Framework-neutral configuration with thin Django and FastAPI adapters.
- • Provider-specific capability gaps fail explicitly instead of pretending parity.
- • Secret-aware configuration errors and webhook verification helpers.
- • A scoped MCP server for configuration, comparison, troubleshooting, and test workflows.