Component Diagram

Component Diagram: A component diagram is a type of structural diagram used in UML (Unified Modeling Language) to visualize the organization and relationships of system components. These diagrams help in breaking down complex systems into manageable components, showcasing their interdependencies, and ensuring efficient system design and architecture.

Advantages of PlantUML:

Components

Components must be bracketed.

You can also use the component keyword to define a component. In this case the brackets can be omitted, but only if the component name does not include white-space or special characters.

You can define an alias, using the as keyword. This alias will be used later, when defining relations.

Naming exceptions

Note that component names starting with $ cannot be hidden or removed later, because hide and remove command will consider the name a $tag instead of a component name. To later remove such component they must have an alias or must be tagged.

Interfaces

Interface can be defined using the () symbol (because this looks like a circle).

You can also use the interface keyword to define an interface. And you can define an alias, using the as keyword. This alias will be used latter, when defining relations.

We will see latter that interface definition is optional.

Basic example

Links between elements are made using combinations of dotted line (..), straight line (--), and arrows (-->) symbols.

Using notes

You can use the note left of , note right of , note top of , note bottom of keywords to define notes related to a single object.

A note can be also defined alone with the note keywords, then linked to other objects using the .. symbol or whatever arrow symbol (-, --, ...).

Another note example:

Grouping Components

You can use several keywords to group components and interfaces together:

Changing arrows direction

By default, links between classes have two dashes -- and are vertically oriented. It is possible to use horizontal link by putting a single dash (or dot) like this:

You can also change directions by reversing the link:

It is also possible to change arrow direction by adding left, right, up or down keywords inside the arrow:

You can shorten the arrow by using only the first character of the direction (for example, -d- instead of -down-) or the two first characters (-do-).

Please note that you should not abuse this functionality : Graphviz gives usually good results without tweaking.

And with the left to right direction parameter:

See also 'Change diagram orientation' on Deployment diagram page.

Use UML2 notation

By default (from v1.2020.13-14), UML2 notation is used.

Use UML1 notation

The skinparam componentStyle uml1 command is used to switch to UML1 notation.

Use rectangle notation (remove UML notation)

The skinparam componentStyle rectangle command is used to switch to rectangle notation (without any UML notation).

Long description

It is possible to put description on several lines using square brackets.

Individual colors

You can specify a color after component definition.

Using Sprite in Stereotype

You can use sprites within stereotype components.

Skinparam

You can use the skinparam command to change colors and fonts for the drawing.

You can use this command :

You can define specific color and fonts for stereotyped components and interfaces.

Specific SkinParameter

componentStyle

[Ref. 10798]

Hide or Remove unlinked component

By default, all components are displayed:

But you can:

[Ref. QA-11052]

Hide, Remove or Restore tagged component or wildcard

You can put $tags (using $) on components, then remove, hide or restore components either individually or by tags.

By default, all components are displayed:

But you can:

[Ref. QA-7337 and QA-11052]

Display JSON Data on Component diagram

Simple example

[Ref. QA-15481]

For another example, see on JSON page.

Port [port, portIn, portOut]

You can add port with port, portinand portout keywords.

Port

PortIn

PortOut

Mixing PortIn & PortOut