Diagram Types for Composition in Diagram-Design: A Complete Guide to UML Class Relationships
Only UML Class Diagrams support the Composition relationship in the diagram-design repository, providing the filled diamond notation required to model strict whole-part hierarchies where child components cannot exist independently of their parent.
The diagram-design repository provides a comprehensive toolkit for visual modeling, but not all diagram types support the same relationship semantics. If you need to represent strong ownership where the destruction of a parent object cascades to its children, understanding which diagram types for composition are available is essential.
UML Class Diagrams: The Only Type Supporting Composition
The UML Class Diagram is the sole diagram type in the diagram-design skill set that explicitly implements the Composition relationship. According to the source code in skills/diagram-design/references/type-uml-class.md, this diagram type defines a complete relationship vocabulary including Composition, Aggregation, Inheritance, Realization, Association, and Dependency【1†L30-L37】.
Composition Notation and Semantics
In UML Class Diagrams, composition represents a strong "part-of" relationship indicated by a filled diamond at the owning side. Unlike aggregation (empty diamond), composition implies that the child component's lifecycle depends entirely on the parent. When the parent is destroyed, the composed children are destroyed as well.
Diagram Types That Do Not Support Composition
All other diagram types in the repository lack the composition relationship in their specifications. Files such as type-flowchart.md, type-tree.md, type-gantt.md, and type-er.md located in the skills/diagram-design/references/ directory focus on different visual grammars—such as process flows, hierarchical trees, timelines, or entity relationships—without exposing a composition arrow.
Creating Composition Relationships in Diagram-Design
To implement composition, you must specify the UML Class diagram type and use the correct Mermaid syntax.
Mermaid Syntax for Composition
The *-- arrow notation renders as a filled diamond at the owning side. Here is a minimal example modeling a Car and its Engine:
classDiagram
class Car {
+engine: Engine
}
class Engine
Car "1" *-- "1" Engine : has
Using the CLI to Export Composition Diagrams
You can generate and export UML Class diagrams using the diagram-design CLI:
# Create a diagram using the UML-class type
diagram-design import-mermaid <<'MERMAID'
classDiagram
class Car {
+engine: Engine
}
class Engine
Car "1" *-- "1" Engine : has
MERMAID
# Export as PNG
diagram-design export-diagram --type uml-class --output car-composition.png
The --type uml-class parameter is mandatory to enable the composition syntax and ensure the filled diamond renders correctly.
Summary
- UML Class Diagrams are the only diagram types for composition in the diagram-design repository, defined in
skills/diagram-design/references/type-uml-class.md. - The filled diamond notation (
*--in Mermaid) distinguishes composition from other relationships. - Flowchart, Tree, Gantt, and ER diagram types lack composition support entirely.
- Use the
--type uml-classCLI flag to generate diagrams with proper composition rendering.
Frequently Asked Questions
Which diagram types support composition relationships in diagram-design?
Only UML Class Diagrams support composition relationships. The source code in skills/diagram-design/references/type-uml-class.md defines this relationship vocabulary, while all other diagram types in the references/ folder focus on alternative visual grammars without composition notation.
How do you write a composition relationship using Mermaid syntax?
Use the *-- arrow between classes, with the filled diamond appearing at the first class. For example: Car "1" *-- "1" Engine : has creates a composition where Car owns Engine. This syntax is only valid when the diagram type is set to UML Class.
What is the difference between composition and aggregation in UML Class Diagrams?
Composition (filled diamond) indicates a strong whole-part relationship where the part cannot exist without the whole. Aggregation (empty diamond) indicates a weaker "has-a" relationship where the part can exist independently. The diagram-design repository supports both notations, but only within UML Class Diagrams.
Where can I find the composition specification in the diagram-design source code?
The composition relationship is documented in skills/diagram-design/references/type-uml-class.md at lines 30-37. This file defines the full set of UML relationships including Composition, Aggregation, Inheritance, Realization, Association, and Dependency.
Have a question about this repo?
These articles cover the highlights, but your codebase questions are specific. Give your agent direct access to the source. Share this with your agent to get started:
curl -s "https://instagit.com/install.md" Maintain an open-source project? Get it listed too →