SA-201b · Module 3

The 3-Layer Rule in Integration

3 min read

The 3-layer rule from the foundations course applies with even greater force in integration architecture. Every integration layer adds latency, failure modes, and a contract that both sides must honor. At three layers, a competent engineer can hold the entire integration chain in their head. At four, the system requires documentation. At five, the system requires a team. At six, the system requires hope.

Consider a common AI consulting integration: the client application calls your API gateway (layer 1), the gateway routes to your orchestration service (layer 2), the orchestration service calls the AI model (layer 3). Three layers. Manageable. Now add the AI model calling a vector database (layer 4), the vector database calling the client's document store (layer 5). Five layers. The client's request traverses five systems, five contracts, five failure surfaces, and the latency is the sum of all five. This is the point where the architecture needs to be rethought, not extended.

  1. Count the Layers Map every integration layer in the request path. An integration layer is any boundary where one system calls another. Count them. If the count is three or fewer, the architecture is manageable. If the count exceeds three, ask: is each layer earning its place?
  2. Challenge Layer Four When you identify a fourth layer, apply the diagnostic: is this layer necessary, or is it an artifact of the path we took? Can two layers be collapsed into one? Can a synchronous call be replaced with pre-fetched data? Can a middleware layer be eliminated by direct connection? The fourth layer should justify its existence with evidence.
  3. Design for Layer Reduction Build integration architectures with layer reduction as a design goal. Pre-fetch data that would otherwise require a runtime integration call. Cache responses to eliminate redundant cross-layer calls. Colocate services that communicate frequently to reduce network boundaries. Every layer you eliminate is a failure surface removed.