Skip to content

Provider Adapter Layer

The rule

Frontend applications never call provider APIs directly. All provider interactions go through app-api.

Customer (browser)
app-web / app-admin
app-api
Provider Adapter Layer
Provider APIs (insurers, government systems, payment gateways)

Why

  1. Provider switching — if an insurer changes their API, only the adapter changes; no frontend code changes
  2. Credential security — provider API keys never touch the frontend
  3. Normalization — each provider returns data in different formats; the adapter normalizes to a consistent internal schema
  4. Rate limiting — the adapter can queue, retry, and throttle provider calls
  5. Logging — all provider interactions are logged in one place

Adapter structure

Each provider gets its own adapter module in app-api/src/adapters/:

adapters/
├── insurance/
│ ├── quick-sigorta.adapter.ts
│ ├── hepiyi-sigorta.adapter.ts
│ ├── sompo.adapter.ts
│ └── index.ts ← unified interface
├── government/
│ ├── immigration.adapter.ts
│ └── index.ts
└── payments/
├── stripe.adapter.ts
└── wise.adapter.ts

Adapter contract

Every insurance adapter implements the same interface:

interface InsuranceProviderAdapter {
getQuote(params: QuoteParams): Promise<Quote[]>
issuePolicy(params: PolicyParams): Promise<IssuedPolicy>
cancelPolicy(policyId: string): Promise<void>
renewPolicy(policyId: string, params: RenewalParams): Promise<IssuedPolicy>
}

Frontend code calls:

// app-api route handler
const quotes = await insuranceAdapter.getQuote(params);
// adapter internally calls the right provider

Never:

// ❌ NEVER — direct provider call from frontend or route without adapter
const quotes = await fetch('https://api.quicksigorta.com/quotes', { ... });

Current provider integrations

ProviderCategoryStatus
Quick SigortaInsurancePlanned
Hepiyi SigortaInsurancePlanned
Sompo SigortaInsurancePlanned
Türk Nippon SigortaInsurancePlanned
Doğa SigortaInsurancePlanned
EMAAInsurancePlanned
Arex SigortaInsurancePlanned
Ankara SigortaInsurancePlanned
StripePaymentsActive
WisePaymentsPlanned
WhatsApp Cloud APIMessagingActive
SendGridEmailActive
TwilioSMS / VerifyActive