Midnighter / structurizr-python

A Python 3 port of Simon Brown's Structurizr diagrams-as-code architecture description tool.
https://structurizr.com/
Apache License 2.0
66 stars 16 forks source link

Automatic addition of implied relationships #42

Closed yt-ms closed 3 years ago

yt-ms commented 3 years ago

Checklist

Is your feature related to a problem? Please describe it.

When building a model programmatically using Python, a common situation is that you need to create relationships between parent entities that mirror those of children. For example, assume you have system A with container A1 and system B with container B1, then adding a relationship A1 -> B1 usually implies you also have relationships A1 -> B, A -> B and A -> B1 (for example if you are drawing a container view of A then you would want to see the relationship from A1 ->B, or if you are drawing a system context view then you'd want to see A -> B).

Describe the solution you would like.

In Java, this is handled through setting an ImpliedRelationshipStrategy on the Model with three strategies supported out of the box:

We should mirror this structure in Python.

It is also possible to prevent invoking the strategy when adding a single relationship by passing createImpliedRelationships=false on Model.addRelationship(). In Python, this would need to be added in Element.add_relationship() which would then pass through to Model.add_relationship().

Describe alternatives you considered

A simpler solution would be to reproduce the earlier Model.addImplicitRelationships() from Java which you call explicitly after adding a relationship, but it would be better to match the newer Java strategy implementation.

Midnighter commented 3 years ago

Not sure what's going on. Should have been closed automatically.