C4 and UML answer different parts of an architecture discussion. C4 organizes the level of abstraction: system context, containers, components and code. UML provides diagram notations for structure and behavior. A C4 Code view can use a UML class diagram, so choosing C4 does not require abandoning UML.
Start with a checkout question
If a product owner asks who processes payments, use a context view showing the commerce system and its external payment provider. A class diagram would hide the system boundary behind implementation detail.
If an engineer asks how checkout is deployed, use a container view for the web application, API and data store, followed by a supplementary deployment view for runtime instances. A C4 container means an application or data store; it does not imply Docker.
Trace the purchase path in this container model. Notice that understanding the payment dependency does not require knowing a class name.
Zoom in only when it changes a decision
Suppose a payment adapter must support two providers. A component view can show the order service depending on a payment adapter. A Code view can then show a PaymentGateway interface implemented by two classes. That is where a UML relationship such as realization carries useful meaning.
The dotted realization arrows point from each adapter to the interface. The dependency from OrderService points to the interface rather than to one provider implementation. This view supports a discussion about substitutability; it does not establish runtime isolation or deployment topology.
A practical review exercise
Download the checkout C4 model and the class diagram SVG. Ask reviewers to answer three questions: who depends on the payment provider, which deployable owns checkout, and which class implements its payment contract. Use context, container and code views respectively. If the answer needs a legend explaining two abstraction levels at once, split the view.
Keep source-level details aligned with code and update them when the contract changes. Do not reproduce every class in architecture documentation. The official C4 guidance recommends using only the levels that add value; the UML specification defines the notation.
The UXXU C4 model tool supports connected views, including Code class diagrams. Learn the notation in the C4 educational hub.