Skip to content

Component Diagram

c4.diagrams.component.ComponentDiagram

Bases: Diagram

Represents a C4 Component diagram.

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,
    extensions: ElementExtensions | None = None,
    plantuml: ComponentExtensions | None = None,
    alias: Maybe[str] = MISSING,
) -> None

Parameters:

Name Type Description Default
label Required[str]

Display name for the component. Required.

REQUIRED
description str | None

Optional description of the component's behavior or role.

None
technology str | None

Optional technology used to implement the component.

None
extensions ElementExtensions | None

Backend-specific extension data.

None
plantuml ComponentExtensions | None

PlantUML-specific extension data.

None
alias Maybe[str]

Unique identifier for the component. If not provided, it is autogenerated from the label.

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.

__init__

__init__(
    label: Required[str] = REQUIRED,
    description: str | None = None,
    technology: str | None = None,
    extensions: ElementExtensions | None = None,
    plantuml: ComponentStorageExtensions | None = None,
    alias: Maybe[str] = MISSING,
) -> None

Parameters:

Name Type Description Default
label Required[str]

Display name for the component database. Required.

REQUIRED
description str | None

Optional description text.

None
technology str | None

Optional technology used by the component.

None
extensions ElementExtensions | None

Backend-specific extension data.

None
plantuml ComponentStorageExtensions | None

PlantUML-specific extension data.

None
alias Maybe[str]

Unique identifier for the component database. If not provided, it is autogenerated from the label.

MISSING

c4.diagrams.component.ComponentQueue

Bases: ElementWithTechnology

Represents a component modeled as a message queue.

Useful for showing message-based or asynchronous communication paths.

__init__

__init__(
    label: Required[str] = REQUIRED,
    description: str | None = None,
    technology: str | None = None,
    extensions: ElementExtensions | None = None,
    plantuml: ComponentStorageExtensions | None = None,
    alias: Maybe[str] = MISSING,
) -> None

Parameters:

Name Type Description Default
label Required[str]

Display name for the component queue. Required.

REQUIRED
description str | None

Optional description text.

None
technology str | None

Optional technology used by the component.

None
extensions ElementExtensions | None

Backend-specific extension data.

None
plantuml ComponentStorageExtensions | None

PlantUML-specific extension data.

None
alias Maybe[str]

Unique identifier for the component queue. If not provided, it is autogenerated from the label.

MISSING

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.