Component Diagram¶
c4.diagrams.component.ComponentDiagram ¶
c4.diagrams.component.Component ¶
Bases: Element
Represents a software component within a container.
A component is a logical unit (such as a class, module, or handler) that performs a specific function within a container. Includes metadata like technology, visual style, and links.
__init__ ¶
__init__(
label: Required[str] = REQUIRED,
description: str | None = None,
technology: str | None = None,
sprite: str | None = None,
tags: list[str] | None = None,
link: str | None = None,
base_shape: str | None = None,
alias: Maybe[str] = MISSING,
) -> None
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
label
|
Required[str]
|
Human-readable name of the component. |
REQUIRED
|
description
|
str | None
|
Optional description of the component's behavior or role. |
None
|
technology
|
str | None
|
Technology used to implement the component. |
None
|
sprite
|
str | None
|
Optional sprite for visual appearance in the diagram. |
None
|
tags
|
list[str] | None
|
Optional tags for styling or grouping. |
None
|
link
|
str | None
|
Optional external link related to the component. |
None
|
base_shape
|
str | None
|
Optional shape override for rendering. |
None
|
alias
|
Maybe[str]
|
Unique identifier for the component. |
MISSING
|
set_property_header ¶
set_property_header(*args: str) -> Self
Sets the column headers for the element's property table.
This must be called either before adding any property rows, or the header length must match the number of values.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
*args
|
str
|
Column names to use as the property header. |
()
|
Returns:
| Type | Description |
|---|---|
Self
|
The updated diagram element. |
Raises:
| Type | Description |
|---|---|
ValueError
|
If header length does not match the number of values. |
without_property_header ¶
without_property_header() -> Self
Disables the rendering of the header row in the property table.
Returns:
| Type | Description |
|---|---|
Self
|
The updated diagram element. |
add_property ¶
add_property(*args: str) -> Self
Adds a row to the property table.
The number of arguments must match the number of header columns.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
*args
|
str
|
Values for each column in the property row. |
()
|
Returns:
| Type | Description |
|---|---|
Self
|
The updated diagram element. |
Raises:
| Type | Description |
|---|---|
ValueError
|
If the number of values does not match the header length. |
c4.diagrams.component.ComponentDb ¶
Bases: ElementWithTechnology
Represents a component modeled as a database.
Used to depict data storage components in a component diagram.
c4.diagrams.component.ComponentQueue ¶
Bases: ElementWithTechnology
Represents a component modeled as a message queue.
Useful for showing message-based or asynchronous communication paths.
c4.diagrams.component.ComponentExt ¶
Bases: Component
Represents an external component outside the container boundary.
Commonly used to show third-party libraries or external system components.
c4.diagrams.component.ComponentDbExt ¶
Bases: ComponentDb
Represents an external database component.
Used for visualizing data stores not maintained by the system.
c4.diagrams.component.ComponentQueueExt ¶
Bases: ComponentQueue
Represents an external message queue or broker.
Used to show external infrastructure for asynchronous communication.