C4+1 — The Services Layer
Adding an extra layer to the C4 Model helps solve the age-old problem of where you put the Services.
Introduction
Having used the C4 model (Context, Containers, Components, and Code) for many years in various projects, I’ve noticed its strengths and areas for potential enhancement.
A recurring challenge in C4 is the ambiguity often encountered in differentiating between Containers and Components. This ambiguity can lead to confusion, particularly in complex Architectures using Microservices or, more recently, Data Mesh patterns.
Proposed Solution
To address this issue, I’ve used an additional layer called Services, which is placed between the Container and Component layers of the C4 model. This Services layer aims to provide a clear demarcation, explicitly defining the roles and responsibilities that might overlap between Containers and Components. For instance, in a web application architecture, the Services layer could be responsible for distinct backend functionalities, such as API management and data processing, which are not explicitly covered by either Containers or Components.
Use Cases
Introducing a Services layer in the C4 model can be particularly beneficial in various scenarios: