Anti-Vendor-Lock-In Framework

INFRASTRUCTURE SOVEREIGNTY.

/// PROVIDER_ADAPTER_PATTERN Vendor lock-in is now a choice, not a prison. Switch payment, email, and storage providers with a single line of configuration.

UNIFIED INTERFACES FOR

STRIPE AUTH0 WORKOS TWILIO AWS SNS S3/GCS

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.

# ❌ Tightly Coupled Business Logic
import stripe def checkout(user): # Direct dependency on Stripe's API shape customer = stripe.Customer.create( email=user.email, metadata={'uid': user.id} ) # ⚠️ What if you need PayPal later? # ⚠️ How do you mock this easily?

Adapter Pattern

Code against a stable, unified interface. The implementation details are abstracted away. Swap providers via configuration.

# ✅ Agnostic Domain Logic
from swap_layer.factory import get_payment_provider def checkout(user): provider = get_payment_provider() # Interface is consistent regardless of backend customer = provider.create_customer( email=user.email, metadata={ 'uid': str(user.id) } )

UNIFIED CAPABILITIES.

Comprehensive abstractions for the four pillars of modern SaaS infrastructure.

Universal Billing

Subdomain-based architecture for Customers, Subscriptions, and Payment Intents.

  • Unified Customer & Sub management
  • Normalized Webhook Payloads
  • One-time Payments & Invoicing

Communication Hub

Abstraction layer for Transactional Email and SMS with unified templating.

  • Template mgmt across SES/SendGrid
  • Suppression List Management
  • Bulk Sending & Analytics

Identity & Auth

Switch between Auth0, WorkOS, or native Django Auth seamlessly.

  • Unified User Model
  • Multi-provider SSO support

Storage Agnosticism

Write files to S3, Azure Blob, GCS, or Local Disk with one API.

  • Uniform signed URL generation
  • CDN Integration helpers

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.

tests/test_billing.py
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

$ pip install swaplayer[all]

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'