Skip to content

Implement support for relationship!= expressions #378

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

mwz
Copy link

@mwz mwz commented Feb 18, 2025

Hello,

This is my first contribution to Structurizr, and I’d like to take a moment to thank you for building this project. We use it extensively for representing our architecture, and it has been incredibly useful.

We’ve found that some of our system context diagrams can become quite large. To create smaller, more focused views, we’ve been using the following script to remove relationships that are not directly connected to the target system:

!script groovy {
  element = view.getSoftwareSystem();
  view.removeRelationshipsNotConnectedToElement(element);
}

It would be better to achieve this directly using view expressions, so I implemented support for relationship not equals expressions.

This PR introduces:
relationship.source!=
relationship.destination!=
relationship!=

With these expressions, for example:

systemContext mySystem "MySystemContext" {
  include *
  exclude "relationship.source!=mySystem && relationship.destination!=mySystem"
}

one can simplify a complex diagram, such as:

Screenshot-2025-02-18-12 45 00

or

Screenshot-2025-02-18-13 49 44

into a cleaner version that only includes direct relationships to the system, removing relationships between other systems, if not relevant for the view:

Screenshot-2025-02-18-12 45 17

or

Screenshot-2025-02-18-13 48 52

This significantly improves readability and makes it easier to understand direct dependencies for the system in question.

I hope this change can be helpful to others in improving their diagrams. I’m not very familiar with the codebase, so please let me know if I’ve missed anything. Looking forward to your feedback!

@simonbrowndotje
Copy link
Contributor

Thanks for this. I need to get my head around whether this will work for all view types - specifically deployment views where either the software system/container or software system instance/container instance could be specified as the relationship source/destination.

In the meantime, can I offer this as a simpler alternative? (this is available now if you build from source)

include * (greedy)

greedy

include *? (reluctant)

reluctant

@mwz
Copy link
Author

mwz commented Feb 19, 2025

Hi Simon,

Thanks so much—this is definitely a simpler way to achieve what I was aiming for!

I still think “relationship not equals” expressions could be useful beyond my specific use case. If you agree, I’d be more than happy to make any changes needed to include this functionality.

Really appreciate the quick response and the effort you put into implementing this.

Thanks again!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants