System Context Diagram¶
c4.diagrams.system_context.SystemContextDiagram ¶
Bases: Diagram
Represents a C4 System Context Diagram.
Source code in c4/diagrams/system_context.py
15 16 17 18 19 20 | |
__init__ ¶
__init__(
title: str | None = None,
default_renderer: BaseRenderer[Diagram] | None = None,
render_options: RenderOptions | None = None,
) -> None
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
title
|
str | None
|
Optional title to label the diagram. |
None
|
default_renderer
|
BaseRenderer[Diagram] | None
|
Optional default renderer to use for rendering. |
None
|
render_options
|
RenderOptions | None
|
Optional renderer-specific options. |
None
|
Source code in c4/diagrams/core.py
1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 | |
base_elements
property
¶
base_elements: list[BaseDiagramElement]
Returns a list of base elements of the diagram that should be rendered in a strict order.
relationships
property
¶
relationships: list[Relationship]
Returns all relationships defined in the diagram.
as_plantuml ¶
as_plantuml(**kwargs: Any) -> str
Render the diagram using the built-in PlantUML renderer.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
**kwargs
|
Any
|
Optional keyword arguments passed to the PlantUML renderer. |
{}
|
Returns:
| Type | Description |
|---|---|
str
|
The rendered PlantUML code. |
Source code in c4/diagrams/core.py
1514 1515 1516 1517 1518 1519 1520 1521 1522 1523 1524 1525 1526 1527 | |
render ¶
render(
renderer: BaseRenderer[Diagram] | None = None,
) -> str
Render the diagram to a string using the given or default renderer.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
renderer
|
BaseRenderer[Diagram] | None
|
Optional renderer to override the default. |
None
|
Returns:
| Type | Description |
|---|---|
str
|
The rendered diagram output. |
Raises:
| Type | Description |
|---|---|
ValueError
|
If no renderer is provided and no default renderer is set. |
Source code in c4/diagrams/core.py
1554 1555 1556 1557 1558 1559 1560 1561 1562 1563 1564 1565 1566 1567 1568 1569 1570 1571 1572 | |
save ¶
save(
path: str | Path,
renderer: BaseRenderer[Diagram] | None = None,
) -> None
Render and save the diagram to a file.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
path
|
str | Path
|
Target path to save the rendered output. |
required |
renderer
|
BaseRenderer[Diagram] | None
|
Optional renderer to override the default. |
None
|
Source code in c4/diagrams/core.py
1574 1575 1576 1577 1578 1579 1580 1581 1582 1583 1584 1585 1586 1587 1588 1589 1590 1591 1592 | |
save_as_plantuml ¶
save_as_plantuml(path: str | Path, **kwargs: Any) -> None
Render and save the diagram using the PlantUML renderer.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
path
|
str | Path
|
Target file path. |
required |
**kwargs
|
Any
|
Optional kwargs passed to the PlantUML renderer. |
{}
|
Source code in c4/diagrams/core.py
1594 1595 1596 1597 1598 1599 1600 1601 1602 1603 1604 1605 | |
c4.diagrams.system_context.SystemLandscapeDiagram ¶
Bases: Diagram
Represents a C4 System Landscape Diagram.
Source code in c4/diagrams/system_context.py
23 24 25 26 27 28 | |
__init__ ¶
__init__(
title: str | None = None,
default_renderer: BaseRenderer[Diagram] | None = None,
render_options: RenderOptions | None = None,
) -> None
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
title
|
str | None
|
Optional title to label the diagram. |
None
|
default_renderer
|
BaseRenderer[Diagram] | None
|
Optional default renderer to use for rendering. |
None
|
render_options
|
RenderOptions | None
|
Optional renderer-specific options. |
None
|
Source code in c4/diagrams/core.py
1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 | |
base_elements
property
¶
base_elements: list[BaseDiagramElement]
Returns a list of base elements of the diagram that should be rendered in a strict order.
relationships
property
¶
relationships: list[Relationship]
Returns all relationships defined in the diagram.
as_plantuml ¶
as_plantuml(**kwargs: Any) -> str
Render the diagram using the built-in PlantUML renderer.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
**kwargs
|
Any
|
Optional keyword arguments passed to the PlantUML renderer. |
{}
|
Returns:
| Type | Description |
|---|---|
str
|
The rendered PlantUML code. |
Source code in c4/diagrams/core.py
1514 1515 1516 1517 1518 1519 1520 1521 1522 1523 1524 1525 1526 1527 | |
render ¶
render(
renderer: BaseRenderer[Diagram] | None = None,
) -> str
Render the diagram to a string using the given or default renderer.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
renderer
|
BaseRenderer[Diagram] | None
|
Optional renderer to override the default. |
None
|
Returns:
| Type | Description |
|---|---|
str
|
The rendered diagram output. |
Raises:
| Type | Description |
|---|---|
ValueError
|
If no renderer is provided and no default renderer is set. |
Source code in c4/diagrams/core.py
1554 1555 1556 1557 1558 1559 1560 1561 1562 1563 1564 1565 1566 1567 1568 1569 1570 1571 1572 | |
save ¶
save(
path: str | Path,
renderer: BaseRenderer[Diagram] | None = None,
) -> None
Render and save the diagram to a file.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
path
|
str | Path
|
Target path to save the rendered output. |
required |
renderer
|
BaseRenderer[Diagram] | None
|
Optional renderer to override the default. |
None
|
Source code in c4/diagrams/core.py
1574 1575 1576 1577 1578 1579 1580 1581 1582 1583 1584 1585 1586 1587 1588 1589 1590 1591 1592 | |
save_as_plantuml ¶
save_as_plantuml(path: str | Path, **kwargs: Any) -> None
Render and save the diagram using the PlantUML renderer.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
path
|
str | Path
|
Target file path. |
required |
**kwargs
|
Any
|
Optional kwargs passed to the PlantUML renderer. |
{}
|
Source code in c4/diagrams/core.py
1594 1595 1596 1597 1598 1599 1600 1601 1602 1603 1604 1605 | |
c4.diagrams.system_context.Person ¶
Bases: Element
Represents a person (actor) interacting with the system.
__init__ ¶
__init__(
label: Required[str] = REQUIRED,
description: str | None = None,
sprite: str | None = None,
tags: list[str] | None = None,
link: str | None = None,
type_: str | None = None,
alias: Maybe[str] = MISSING,
) -> None
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
label
|
Required[str]
|
Display name for the element. Required. |
REQUIRED
|
description
|
str | None
|
Optional description text. |
None
|
sprite
|
str | None
|
Optional sprite/icon reference for rendering. |
None
|
tags
|
list[str] | None
|
Optional tags for styling or grouping. |
None
|
link
|
str | None
|
Optional URL associated with the element. |
None
|
type_
|
str | None
|
Optional custom type or stereotype label. |
None
|
alias
|
Maybe[str]
|
Unique identifier for the element. If not provided, it is autogenerated from the label. |
MISSING
|
Raises:
| Type | Description |
|---|---|
ValueError
|
If |
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.system_context.PersonExt ¶
c4.diagrams.system_context.System ¶
Bases: Element
Represents a software system in the C4 model.
__init__ ¶
__init__(
label: Required[str] = REQUIRED,
description: str | None = None,
sprite: str | None = None,
tags: list[str] | None = None,
link: str | None = None,
type_: str | None = None,
base_shape: str | None = None,
alias: Maybe[str] = MISSING,
) -> None
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
label
|
Required[str]
|
Human-readable name. |
REQUIRED
|
description
|
str | None
|
Optional description for the system. |
None
|
sprite
|
str | None
|
Optional icon or sprite. |
None
|
tags
|
list[str] | None
|
Optional tags for styling or grouping. |
None
|
link
|
str | None
|
Optional hyperlink associated with the element. |
None
|
type_
|
str | None
|
Custom type/stereotype string. |
None
|
base_shape
|
str | None
|
Optional override for visual shape. |
None
|
alias
|
Maybe[str]
|
Unique identifier for the system. |
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.system_context.SystemExt ¶
c4.diagrams.system_context.SystemDb ¶
c4.diagrams.system_context.SystemQueue ¶
c4.diagrams.system_context.SystemQueueExt ¶
c4.diagrams.system_context.SystemBoundary ¶
Bases: Boundary
Represents the boundary around a specific system.
Used to group containers or components that belong to a single system.
__init__ ¶
__init__(
label: Required[str] = REQUIRED,
description: str | None = None,
tags: list[str] | None = None,
link: str | None = None,
alias: Maybe[str] = MISSING,
) -> None
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
label
|
Required[str]
|
Display name. |
REQUIRED
|
description
|
str | None
|
Optional description. |
None
|
tags
|
list[str] | None
|
Optional tags for styling or grouping. |
None
|
link
|
str | None
|
Optional hyperlink. |
None
|
alias
|
Maybe[str]
|
Unique identifier for the boundary. |
MISSING
|
c4.diagrams.system_context.EnterpriseBoundary ¶
Bases: Boundary
Represents an enterprise boundary in a system landscape or context diagram.
Used to group systems and actors that belong to the same organizational unit.
__init__ ¶
__init__(
label: Required[str] = REQUIRED,
description: str | None = None,
tags: list[str] | None = None,
link: str | None = None,
alias: Maybe[str] = MISSING,
) -> None
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
label
|
Required[str]
|
Display name. |
REQUIRED
|
description
|
str | None
|
Optional description. |
None
|
tags
|
list[str] | None
|
Optional tags for styling or grouping. |
None
|
link
|
str | None
|
Optional hyperlink. |
None
|
alias
|
Maybe[str]
|
Unique identifier for the boundary. |
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. |