Integrations

Integrations are where many otherwise clean systems become fragile. External APIs, webhooks and third-party services bring their own formats, delays, error patterns and retry behaviour. The architectural goal is to keep those differences close to adapter code instead of letting them leak into the core of the product.

Keep external detail at the edge

Use dedicated adapter functions for each provider and keep the internal model of your system stable. That makes later replacement, testing and debugging much easier.

Webhook and retry discipline

Webhook handlers should be idempotent. Retry logic should be central, bounded and based on the kind of error that occurred. Otherwise one temporary provider problem can grow into duplicated side effects or unnecessary load.

funksjon er_kan_retry(status: heltall) -> bool {
    hvis status == 429 eller status == 500 eller status == 503 da {
        returner true
    }
    returner false
}

The best companions for this chapter are API contracts, security and reliability.