Sub topic 1
How systems get connected: point-to-point, hub-and-spoke, and API-led
This chapter describes the three main ways to wire systems together and how each one behaves as the number of systems grows. It is the base for the later chapters, which ask when Salesforce's built-in tools are enough and when a middleware layer is worth its cost.
Prerequisites
This chapter assumes you already know the following:
- Basic Salesforce concepts: objects, records, and that the platform exposes APIs for reading and writing them.
- How a REST API works: HTTP methods, status codes, and JSON bodies.
- What an integration between two systems is: one system sends or requests data from another so both stay consistent.
You do not need MuleSoft experience. Terms such as middleware and API-led are defined where they first appear.
Why the connection style matters
Every integration has two costs. The first is the cost of building it. The second is the cost of living with it: changing it when a system is upgraded, finding out why it failed at 2 a.m., and adding the next system.
An integration style is the overall shape of connections across your landscape. Salesforce can implement any of the three styles in this chapter. The difference is how the cost of change grows as the landscape grows.
The three styles are:
- Point-to-point: each system talks directly to each other system it needs.
- Hub-and-spoke: each system talks to one central hub, and the hub talks to the others.
- API-led: systems are exposed through layered, reusable APIs, and consumers call those APIs instead of the systems.
Point-to-point
In a point-to-point integration, system A connects directly to system B. Each connection has its own endpoint, authentication, field mapping, and error handling.
Here is a typical example from Salesforce. An Apex class calls an ERP's REST endpoint through a Named Credential (a stored endpoint and authentication definition) to fetch an order status.
HttpRequest req = new HttpRequest();
req.setEndpoint('callout:ERP_Credential/orders/' + orderId);
req.setMethod('GET');
HttpResponse res = new Http().send(req);
if (res.getStatusCode() == 200) {
Map<String, Object> order = (Map<String, Object>) JSON.deserializeUntyped(res.getBody());
System.debug(order.get('status'));
}This is a good solution when only two systems are involved. It is quick to build, has few moving parts, and nobody has to learn a new platform.
How the cost grows
The problem appears as systems are added. With n systems that all need to talk to each other, the number of possible connections is n × (n − 1) / 2. Four systems give 6 connections. Eight give 28. Twelve give 66.
| Systems | Maximum direct connections |
|---|---|
| 3 | 3 |
| 4 | 6 |
| 6 | 15 |
| 8 | 28 |
| 12 | 66 |
You rarely build every possible connection. The point is that each new system can require a connection to many existing ones, and every connection carries its own mapping and error handling.
Failure modes of point-to-point
- Duplicated logic. The mapping from "customer" in the ERP to "Account" in Salesforce is written once in Salesforce and again in billing, and the two versions drift apart.
- Brittle coupling. If the ERP changes a field name, every system that calls it must change at the same time.
- Scattered credentials. Each connection holds its own secrets, so rotating one means finding every place it is used.
- Poor visibility. No single place shows what is flowing where. A failure in one link is found by the people downstream.
Hub-and-spoke
In hub-and-spoke, a central component, the hub, sits between systems. Each system, a spoke, has one connection: to the hub. The hub receives a message, transforms it, decides where it goes, and delivers it.
With n systems you need n connections, not up to n × (n − 1) / 2. Adding a ninth system means building one new spoke.
A hub typically provides:
- Transformation: converting one system's data shape to another's.
- Routing: deciding which systems receive a message.
- Protocol mediation: accepting SOAP, REST, files, or message queues and presenting them in a consistent way.
- Central error handling and monitoring.
Trade-offs of hub-and-spoke
The hub centralizes mapping, credentials, and visibility, which fixes most point-to-point problems. It introduces its own:
- Single point of failure. If the hub is down, everything is down. Hubs need high availability and capacity planning.
- Bottleneck. All traffic and all change requests pass through one component and often one team. Queues of requests for the integration team are common.
- Tight shared design. A hub built around one canonical data model can become hard to change, because every spoke depends on that model.
API-led
API-led connectivity organizes integrations into reusable APIs in layers, instead of a single hub that contains all logic. It is a style associated with MuleSoft, but the idea does not depend on any one product. A later chapter covers the layers in detail. Here is the overview:
- System APIs expose one back-end system, such as the ERP or billing, in a stable and consistent way. They hide that system's quirks.
- Process APIs combine system APIs to carry out a business process, such as "fulfil an order". They contain orchestration logic and hold no system-specific details.
- Experience APIs shape data for a particular consumer, such as a mobile app, a partner portal, or Salesforce.
The key difference from hub-and-spoke is reuse and separation of change. When billing is replaced, only the billing system API changes. Process and experience APIs that depend on it keep working, as long as the system API's contract stays the same. A new consumer can reuse existing process APIs instead of building new connections.
Trade-offs of API-led
- More design up front. You must decide the layers, contracts, and ownership before the benefit appears.
- More components to run. Three layers means more APIs to deploy, version, secure, and monitor.
- Extra hops. Each layer adds latency. For a single simple request, three layers can cost more than they return.
- Layering for its own sake. Teams sometimes create a pass-through API at every layer with no logic. That adds hops and ownership with no benefit.
Comparing the three styles
| Aspect | Point-to-point | Hub-and-spoke | API-led |
|---|---|---|---|
| Connections as systems grow | Up to n × (n − 1) / 2 | n | n, plus reusable APIs |
| Where mapping lives | In each connection | In the hub | In system and experience APIs |
| Reuse | Low | Medium | High, by design |
| Main risk | Tangle and drift | Hub as bottleneck | Over-engineering |
| Time to first integration | Shortest | Medium | Longest |
| Best fit | Two or three stable systems | Many systems, central team | Many systems, many consumers, changing landscape |
Where Salesforce sits
Salesforce is usually a spoke or a consumer, not the hub. It has native tools for calling out and for receiving calls, and those tools work well for point-to-point links. They are not designed to be the central place where mapping, routing, and monitoring for the whole company live. Governor limits, which cap what a single transaction can do, also make Salesforce a poor place for heavy orchestration. A later chapter covers these limits.
A common pattern is to publish an event from Salesforce and let something else react. The publisher does not know who listens.
Order_Event__e evt = new Order_Event__e(Order_Number__c = '10045', Status__c = 'Shipped');
Database.SaveResult result = EventBus.publish(evt);
if (!result.isSuccess()) {
for (Database.Error err : result.getErrors()) {
System.debug(err.getMessage());
}
}This code keeps Salesforce decoupled from its subscribers, which is a property of hub-and-spoke and API-led designs, even though Salesforce is doing the publishing natively.
Common mistakes
- Treating the styles as a choice for the whole company. Most landscapes mix them. A single direct link between Salesforce and one stable system can sit next to an API-led design elsewhere.
- Counting only build cost. Point-to-point looks cheap at two systems and expensive at ten. Judge by where the landscape is heading, not only where it is today.
- Calling a hub "API-led" because it exposes REST endpoints. If all logic lives in one place and consumers cannot reuse layered APIs, it is still hub-and-spoke.
- Adopting a hub or layers before there is a second consumer or a third system. The overhead is real, and the benefit is not yet there.
Exercises
Exercise
A company has Salesforce and one ERP. A single Apex callout fetches order status on demand. A new project will add billing, a warehouse system, and a customer portal, each needing order data. Which style are they moving toward, and why is staying with direct callouts risky?
Show answer
They are moving from one point-to-point link toward a landscape of five systems or consumers. Staying direct means each new system builds its own connection and its own mapping of order data, so logic is duplicated and a change in the ERP breaks several callers. A hub-and-spoke or API-led design would put the ERP behind one interface that all consumers reuse.
Exercise
Hub-and-spoke reduces connections from up to n × (n − 1) / 2 to n. Name two new risks it introduces that point-to-point does not have in the same form.
Show answer
The hub is a single point of failure, so its outage affects every integration. It is also a bottleneck for both traffic and change, because all new work passes through one component and usually one team. A shared canonical data model in the hub can also make change slow.
Exercise
In an API-led design, the company replaces its billing system. Which layer must change, and which layers should not need to?
Show answer
Only the billing system API must change, so that it exposes the same contract on top of the new system. Process APIs and experience APIs that depend on that contract should keep working unchanged.