PortfolioIntegration Patterns

Integration Patterns

5 patterns · Real code, real architecture diagrams

OutboundEvent-DrivenInbound
🔗

Integration Architecture Philosophy

Every integration pattern I use is chosen for reliability and maintainability. Named Credentials for secret-free callouts. Platform Events for decoupled, event-driven sync. Connected Apps for proper OAuth flows — no username/password in config. The goal: integrations that stay green at 3am without anyone touching them.

Outbound REST CalloutOutbound

Salesforce calls an external REST API using Named Credentials for secure, credential-free callouts. Ideal for real-time data enrichment or pushing records to external systems.

Use Case

Enriching Account records with data from a 3rd-party data provider on save.

Key Components

Named CredentialsHttpRequest / HttpResponseApex CalloutRemote Site Settings
Salesforce
Named Credential
External API
Salesforce
Apex Callout
Named Credential
Named Credential
HTTPS + Auth
External API
External API
JSON Response
Salesforce
Platform Events (Pub/Sub)Event-Driven

Decoupled, asynchronous communication using Salesforce Platform Events. Publishers fire events; subscribers react independently. Enables real-time integration without tight coupling.

Use Case

Syncing Salesforce Order status changes to an ERP system in real-time without blocking the UI.

Key Components

Platform Event ObjectApex Trigger (subscriber)EventBus.publish()CometD / Pub/Sub API
Salesforce Apex
Platform Event Bus
Middleware (Node.js)
ERP System
Salesforce Apex
EventBus.publish()
Platform Event Bus
Platform Event Bus
CometD Subscribe
Middleware (Node.js)
Middleware (Node.js)
REST / SOAP
ERP System
Connected App + OAuth 2.0Inbound

External applications authenticate into Salesforce using OAuth 2.0 flows via Connected Apps. Supports JWT Bearer (server-to-server), Web Server flow (user-context), and Device flow.

Use Case

A React web app accesses Salesforce data on behalf of logged-in users using the Web Server OAuth flow.

Key Components

Connected AppOAuth 2.0 Web Server FlowAccess TokenRefresh TokenSalesforce REST API
External App
OAuth Endpoint
Connected App
Salesforce API
External App
JWT Assertion
OAuth Endpoint
OAuth Endpoint
Validate
Connected App
Connected App
Access Token
External App
External App
Bearer Token
Salesforce API
Change Data Capture (CDC)Event-Driven

Salesforce automatically publishes change events whenever records are created, updated, deleted, or undeleted. External systems subscribe via the Pub/Sub API for a reliable, ordered stream of changes.

Use Case

Keeping a data warehouse in sync with Salesforce Contact record changes in near-real-time.

Key Components

CDC ConfigurationPub/Sub API (gRPC)Change Event HeadersReplay ID (durable subscription)
Salesforce Records
CDC Event Bus
Pub/Sub API
Data Warehouse
Salesforce Records
Auto-published
CDC Event Bus
CDC Event Bus
gRPC stream
Pub/Sub API
Pub/Sub API
ETL / Upsert
Data Warehouse
Apex REST APIInbound

Custom Apex classes exposed as REST endpoints, allowing external systems to interact with Salesforce using bespoke business logic. Far more flexible than standard CRUD APIs — can orchestrate complex operations in a single call.

Use Case

A mobile app creates a case with related line items and sends a confirmation email in one atomic API call.

Key Components

@RestResource annotationRestRequest / RestResponseCustom Auth (Connected App)Apex Test coverage
Mobile App
Connected App / Auth
Apex REST Resource
Case + Email
Mobile App
OAuth Token
Connected App / Auth
Mobile App
POST /cases/v1/
Apex REST Resource
Apex REST Resource
Insert + Email
Case + Email
Apex REST Resource
JSON Response
Mobile App