What is a Component Diagram?

UML Component Diagrams are used to model the physical aspects of an object-oriented system. They are used to visualize, specify, and document component-based systems, as well as to build executable systems through forward and reverse engineering. A component diagram is essentially a specialized class diagram that focuses on the system’s components and is used to model the static implementation view of a system.

Component Diagram Hierarchy

Overview of Component Diagrams

A component diagram breaks down the actual system being developed into various high-level functionalities. Each component is responsible for a clearly defined goal within the system and interacts only with other core elements as needed.
Component Diagram Overview
The example above shows the internal components of a larger component:
  • Data (account and check IDs) flows into the component through ports on the right and is transformed into a format usable by the internal components. The interface on the right is called a provided interface, representing the services the component requires to fulfill its responsibilities.
  • Data is then passed through various connections to and through other components, and output through ports on the left. The interfaces on the left are called required interfaces, representing the services the component provides.
  • It’s important to note that the internal components are enclosed within a larger “box”—this can be the entire system itself (in which case, no component symbol appears in the top-right corner) or a subsystem/component of the system (in which case, the “box” represents the component itself).

Basic Concepts of Component Diagrams

A component represents a modular part of a system, encapsulating its contents and whose behavior can be substituted within its environment. In UML 2, a component is drawn as a rectangle with an optional compartment stacked vertically. The high-level abstract view of a component in UML 2 can be modeled as:
  1. A rectangle with the component name
  2. A rectangle with a component icon
  3. A rectangle with a stereotype text and/or icon
Appearance of a Component

Interfaces

Two types of component interfaces are shown in the example below:
The provided interface symbol with a full circle at the end indicates the interface that the component provides—the “lollipop” symbol is a shorthand notation for the implementation relationship of an interface classifier.
The required interface symbol with a half-circle (also known as a socket) at the end indicates the interface the component requires (in both cases, the interface name is placed near the symbol itself).
Required and Provided Interfaces

Component Diagram Example – Using Interfaces (Ordering System)

Component Diagram Example with Interfaces

Subsystems

A subsystem classifier is a specialized version of a component classifier. Therefore, the subsystem notation element inherits all the same rules as the component notation. The only difference is that the subsystem symbol element uses the keyword “subsystem” instead of “component”.
Component Diagram with Subsystem

Ports

Ports are represented by squares along the edge of a component or system. They are typically used to expose a component’s required and provided interfaces.
Component Diagram with Port

Relationships

Graphically, a component diagram is a set of vertices and arcs, typically containing components, interfaces, and relationships such as dependency, aggregation, constraint, generalization, association, and realization. It may also include notes and constraints.
Relationship Symbol
Association:

  • An association specifies a semantic relationship that can occur between typed instances.
  • It has at least two ends, each represented by an attribute, and each end is connected to the type of the other end. Multiple ends may have the same type.

Component Diagram: Association




Composition:

  • Composition is a strong form of aggregation, requiring that an instance be contained in at most one composite.
  • If the composite is deleted, its parts are typically deleted as well.

Component Diagram: Composition




Aggregation:

  • A form of association where one end is marked as shared aggregation, meaning it has shared aggregation.

Component Diagram: Aggregation




Constraint:

  • A condition or restriction expressed in natural language text or machine-readable language to declare certain semantics of an element.

Component Diagram: Constraint




Dependency:

  • A relationship indicating that one or more model elements require another model element for their specification or implementation.
  • This means the dependent element’s full semantics are semantically or structurally dependent on the definition of the supplier element.

Component Diagram: Dependency




Generalization:

  • A classification relationship between a more general classifier and a more specific classifier.
  • Every instance of the specific classifier is also an indirect instance of the general classifier.
  • Therefore, the specific classifier inherits features from the more general classifier.

Component Diagram: Generalization




Source Code Modeling

  • Identify the set of source code files of interest through forward or reverse engineering, and model them as components constructed as files.
  • For larger systems, use packages to display groups of source code files.
  • Consider including a tagged value to represent information such as version number, author, and last modified date of the source code file. Use tools to manage the values of these tagged values.
  • Use dependencies to model compilation dependencies between these files. Similarly, use tools to help generate and manage these dependencies.
Component Example – Java Source Code
Component Diagram Example: Java Source Code
Component Diagram Example – C++ Code with Versioning
Component Diagram Example: C++ Code with Versioning

Modeling Executable Releases

  • Identify the set of components you want to model. This usually involves some or all components on a node, or a distribution of these components across all nodes in the system.
  • Consider the stereotype for each component in this set. For most systems, you’ll find a small number of different component types (e.g., executables, libraries, tables, files, and documents). You can use UML’s extensibility mechanism to provide visual cues (hints) for these stereotypes.
  • For each component in this set, consider its relationships with its neighbors. Most often, this involves interfaces exported by some components (implemented) and then imported by others (used). If you want to expose seams in the system, explicitly model these interfaces. If you want a higher-level abstraction, eliminate these relationships by showing only dependencies between components.
Component Diagram for Modeling Executable Release

Physical Database Modeling

  • Identify the classes in the model that represent logical database schemas.
  • Choose the strategy for mapping these classes to tables. You must also consider the physical distribution of the database. Your mapping strategy will be influenced by where you want the data to persist in the deployed system.
  • To visualize, specify, construct, and document the mapping, create a component diagram containing components constructed as tables.
  • Where possible, use tools to help you convert the logical design into a physical design.
Component Diagram for Modeling Physical Database


Try Drawing a UML Component Diagram Now

You’ve now learned what a component diagram is and how to draw one. It’s time to create your own. Get the Visual Paradigm Community Edition, a free UML tool, and use the free Component Diagram tool to build your own. It’s easy to use and intuitive.
  1. What is Unified Modeling Language?
  2. Professional UML Tools
  3. Visual Paradigm. (n.d.). How to Draw a Component Diagram? Visual Paradigm. https://www.visual-paradigm.com/support/documents/vpuserguide/94/2581/7292_drawingcompo.html 42.
  4. Visual Paradigm. (2018, May 11). What is a Component Diagram? Visual Paradigm. https://www.visual-paradigm.com/guide/uml-unified-modeling-language/what-is-component-diagram/ 43.
  5. Visual Paradigm. (n.d.). How to Draw a Component Diagram in UML? Visual Paradigm. https://www.visual-paradigm.com/tutorials/how-to-draw-component-diagram-in-uml/ 44.
  6. Visual Paradigm. (n.d.). Component Diagram – UML 2 Diagram – UML Modeling Tool. Visual Paradigm. https://www.visual-paradigm.com/VPGallery/diagrams/Component.html 45.
  7. Visual Paradigm. (n.d.). Component Diagram in Visual Paradigm. Visual Paradigm. https://www.visual-paradigm.com/support/documents/vpuserguide/94/2581_componentdia.html 46.
  8. Visual Paradigm Community Circle. (2018, May 11). 7. Component Diagram. Visual Paradigm. https://circle.visual-paradigm.com/docs/uml-and-sysml/component-diagram/ 47.
  9. Visual Paradigm Online. (n.d.). Free Component Diagram Tool. Visual Paradigm. https://online.visual-paradigm.com/diagrams/solutions/free-component-diagram-tool/ 48.
  10. Visual Paradigm Online. (n.d.). Component Diagram Tutorial. Visual Paradigm. https://online.visual-paradigm.com/tutorials/component-diagram-tutorial/ 49.
  11. Visual Paradigm. (2022, September 2). UML Class Diagram Tutorial. Visual Paradigm. https://www.visual-paradigm.com/guide/uml-unified-modeling-language/uml-class-diagram-tutorial/ 50.
  12. Visual Paradigm Online. (n.d.). Online UML Diagram Tools. Visual Paradigm. https://online.visual-paradigm.com/diagrams/features/uml-tool/ 51.