Component diagram

Component diagrams show structure at the level of deployable or replaceable parts, with explicit provided and required interfaces. That interface detail is what separates them from a block diagram.

Useful when the contract between parts is the subject.


#When to draw one

  • Documenting a plugin or module architecture.

  • Explaining what a component needs in order to run.

  • Design reviews where interface boundaries are the debate.


#What is on the diagram

Element

Meaning

Component

A replaceable part with defined interfaces

Provided interface

A lollipop: what it offers

Required interface

A socket: what it needs

Port

A named connection point on a component

Assembly connector

A provided interface plugged into a required one


#A worked example

Components with provided and required interfaces:

Component diagram

The source, which you can paste into a new diagram and edit:

@startuml
package "Order platform" {
  [Order API] as API
  [Pricing engine] as Pricing
  [Inventory service] as Inv
  [Notification service] as Notif
}

database "Orders DB" as DB
queue "Event bus" as Bus

API -(0- Pricing : price quote
API -(0- Inv : stock check
API --> DB
API --> Bus
Bus --> Notif

interface "REST /orders" as REST
REST - API
@enduml

#A few things that catch people out

  • Draw the interfaces, not just the boxes. Without them it is a block diagram.

  • A component that requires six interfaces is doing too much, and the diagram says so.

  • Keep deployment out of it; that is a deployment diagram's job.



Four types cover most of it.