Skip to content
DiaGO

Component Diagrams

Components, provided and required interfaces, and the assembly connectors that wire them - how a system's replaceable parts plug together.

A component diagram shows a system as a set of replaceable parts and the contracts between them. Where a class diagram zooms in on objects, a component diagram zooms out: each box is a unit you build, test, deploy and swap as a whole — a service, a library, a module — and the lines say which part needs what from which other part.

The notation

ElementDrawn asMeans
ComponentA box with the «component» keyword or a small component iconA modular part that hides its internals
Provided interfaceA lollipop: a line ending in a circle (the ball)A service the component implements for others
Required interfaceA socket: a line ending in a half-circleA service the component needs from someone else
Assembly connectorA ball fitted into a socketThis requirement is satisfied by that provider
DependencyA dashed arrow, often «use»One component needs another, interface unstated

The interfaces are the point of the diagram. A component promises only what it provides and asks only for what it requires; everything else is private. That is encapsulation one level up.

Provided, required, assembled

Take a library system. Catalog provides BookSearch. Lending requires BookSearch (to check availability) and provides LoanService. Drawing an assembly connector from Lending's socket into Catalog's ball says: at run time, the BookSearch that Lending calls is the one Catalog implements.

            BookSearch
[Lending] ------(O------ [Catalog]
 requires  socket  ball   provides

Because Lending depends on the BookSearch contract rather than on Catalog itself, a second catalog — a search-engine adapter, a test double — can be wired in without touching Lending. That is the Dependency Inversion Principle drawn as a picture.

Reach for it

  • Showing the building blocks of a system and the contracts between them
  • Planning which parts can be replaced, tested or deployed independently
  • Explaining a layered or service architecture to a new teammate

Avoid it

  • Drawing every class as a component - components are coarser units
  • Showing behavior or call order - use a sequence diagram
  • Showing which machine runs what - that is a deployment diagram

Common mistakes

A required interface nobody provides. An unconnected socket means the system cannot run as drawn. Wire it, or state that it is provided from outside.

Components that are really classes. If a "component" has one class inside and no interface of its own, it belongs on a class diagram.

Cycles between components. A requires something from B, which requires something from A: neither can be replaced alone. Break the cycle with an interface owned by one side, as layered architecture does between layers.

Practice

Sketch the components of an online shop — Storefront, Cart, Payments, Inventory. Give each the interfaces it provides and requires, wire every required interface with an assembly connector, and check that no two components require each other.