plantuml-stdlib / C4-PlantUML

C4-PlantUML combines the benefits of PlantUML and the C4 model for providing a simple way of describing and communicate software architectures
MIT License
6.41k stars 1.1k forks source link

Extend System() and Person() with [.....] notation #287

Closed kirchsth closed 1 year ago

kirchsth commented 1 year ago

Related to #199 and #282

The C4 basic meta model has container, components and relations with $techn property (which is displayed as [techn]), but no corresponding counterpart for systems and persons (they have only location).

But sometime is it useful to add a technology/type/category/characteristic/... as attribute/property to a system or person too. For now this can be modeled/visualized via sprites (e.g. system with robot sprite), colors, tags, legend ... And if this is possible why shouldn't systems and persons support a "[....]" notation too.

$type=... could be a good argument name (1-already used by Node(); 2-Person and $techn doesn't match; 3-If system is used in an ARC42 business context diagram then $techn sounds wrong for me too)

@Potherca, @mtnpke, @wlfbck: or do you know a better name? As soon the argument name is defined I could finish the implementation.

A first prototype with $type is defined with following extensions:

@startuml
' convert it with additional command line argument -DRELATIVE_INCLUDE="./.." to use locally
!if %variable_exists("RELATIVE_INCLUDE")
  !include %get_variable_value("RELATIVE_INCLUDE")/C4_Container.puml
!else
  !include https://raw.githubusercontent.com/kirchsth/C4-PlantUML/extended/C4_Container.puml
!endif

' e.g. during first discussions no sprites are available but the categories should be displayed in the UI
AddExternalPersonTag("anonymous_ext", $type="anonymous user")
AddPersonTag("customer", $type="aggregated user")
AddPersonTag("admin", $legendText="administration user", $type="administrator")
AddExternalSystemTag("git_repository", $type="web-based Git repository")

Person_Ext(anonymous_user_v1, "Bob", "simplified version during first discussions ($type defines the role), after discussion the $type can be replaced with concrete $sprite", $type="anonymous user")
Person(aggregated_user_v1, "Sam, Ivone", $tags="customer", $type="replaced with customer")
Person(administration_user_v1, "Bernd", $tags="admin")

System(system1, "System 1", $type="new developed system")

System_Ext(github, "GitHub", $tags="git_repository", $type="graphical web-based Git repository")
System_Ext(gitlab, "GitLab", $tags="git_repository")

!define osaPuml https://raw.githubusercontent.com/Crashedmind/PlantUML-opensecurityarchitecture2-icons/master
!include osaPuml/Common.puml
!include osaPuml/User/all.puml

Person_Ext(anonymous_user_v2, "Bob 2", "Update with sprites", $sprite="osa_user_black_hat")
Person(aggregated_user_v2, "Sam, Ivone 2", $tags="customer", $sprite="osa_user_large_group")
Person(administration_user_v2, "Bernd 2", $tags="admin", $sprite="osa_user_audit,color=red")

HIDE_STEREOTYPE()
@enduml

It can be tested with my extended branch

BR Helmut

mtnpke commented 1 year ago

I agree $techn would be too limiting in the intended use, so another name is a good idea. $type has the downside of being extremely generic, though, so it might be easily misinterpreted 🤔 I had some other ideas ($detail, $details, $category) but I guess they aren't too convincing either. What about $trait maybe? In the end, I personally don't have any strong argument against $type.

On another note, I tested your extended branch, and it worked well for the use case that I have 👍 Thanks.