From 362c9801fb1b1aaf3437f8c6450c4aa03907c5c2 Mon Sep 17 00:00:00 2001 From: Adrian Lupu Date: Sat, 28 Dec 2019 17:32:34 +0200 Subject: [PATCH] #27 Add deployment and dynamic diagrams support #34https://github.com/RicardoNiepel/C4-PlantUML/pull/34 --- C4_Dynamic.puml | 218 ++++++++++++++++++ ...4_Dynamic Diagram Sample - bigbankplc.puml | 20 ++ ..._Dynamic Diagram Sample - message bus.puml | 39 ++++ 3 files changed, 277 insertions(+) create mode 100644 C4_Dynamic.puml create mode 100644 samples/C4_Dynamic Diagram Sample - bigbankplc.puml create mode 100644 samples/C4_Dynamic Diagram Sample - message bus.puml diff --git a/C4_Dynamic.puml b/C4_Dynamic.puml new file mode 100644 index 0000000..c8e6c06 --- /dev/null +++ b/C4_Dynamic.puml @@ -0,0 +1,218 @@ +' !include https://raw.githubusercontent.com/adrianvlupu/C4-PlantUML/latest/C4_Conmponent.puml +' uncomment the following line and comment the first to use locally +!include C4_Component.puml + +' Scope: Interactions in an enterprise, software system or container. +' Primary and supporting elements: Depends on the diagram scope - +' enterprise - people and software systems Related to the enterprise in scope +' software system - see system context or container diagrams, +' container - see component diagram. +' Intended audience: Technical and non-technical people, inside and outside of the software development team. + +' Dynamic diagram introduces (automatically) numbered interactions: +' SetIndex(): set the next index, +' GetIndex(): get the index and automatically increase index + +' Index +' ################################## + +!$index=1 + +!function increment($step=1) +!$index = $index + $step +!endfunction + +!function setIndex($new_index) +!$index=$new_index +!endfunction + +' Relationship override +' ################################## + +' Relationship +' ################################## + +!unquoted function Rel_($e_index, $alias1, $alias2, $label, $direction="") +$alias1 $direction $alias2 : **$e_index: $label** +!endfunction +!unquoted function Rel_($e_index, $alias1, $alias2, $label, $techn, $direction="") +$alias1 $direction $alias2 : **$e_index: $label**\n//[$techn]// +!endfunction + +!unquoted function Rel($from, $to, $label) +Rel_($index, $from, $to, $label, "-->>") +increment() +!endfunction +!unquoted function Rel($from, $to, $label, $techn) +Rel_($index, $from, $to, $label, $techn, "-->>") +increment() +!endfunction +!unquoted function RelIndex($e_index, $from, $to, $label) +Rel_($e_index, $from, $to, $label, "-->>") +!endfunction +!unquoted function RelIndex($e_index, $from, $to, $label, $tech) +Rel_($e_index, $from, $to, $label, $tech, "-->>") +!endfunction + +!unquoted function Rel_Back($from, $to, $label) +Rel_($index, $from, $to, $label, "<<--") +increment() +!endfunction +!unquoted function Rel_Back($from, $to, $label, $techn) +Rel_($index, $from, $to, $label, $techn, "<<--") +increment() +!endfunction +!unquoted function RelIndex_Back($e_index, $from, $to, $label) +Rel_($e_index, $from, $to, $label, "<<--") +!endfunction +!unquoted function RelIndex_Back($e_index, $from, $to, $label, $techn) +Rel_($e_index, $from, $to, $label, $techn, "<<--") +!endfunction + +!unquoted function Rel_Neighbor($from, $to, $label) +Rel_($index, $from, $to, $label, "->>") +increment() +!endfunction +!unquoted function Rel_Neighbor($from, $to, $label, $techn) +Rel_($index, $from, $to, $label, $techn, "->>") +increment() +!endfunction +!unquoted function RelIndex_Neighbor($e_index, $from, $to, $label) +Rel_($e_index, $from, $to, $label, "->>") +!endfunction +!unquoted function RelIndex_Neighbor($e_index, $from, $to, $label, $techn) +Rel_($e_index, $from, $to, $label, $techn, "->>") +!endfunction + +!unquoted function Rel_Back_Neighbor($from, $to, $label) +Rel_($index, $from, $to, $label, "<<-") +increment() +!endfunction +!unquoted function Rel_Back_Neighbor($from, $to, $label, $techn) +Rel_($index, $from, $to, $label, $techn, "<<-") +increment() +!endfunction +!unquoted function RelIndex_Back_Neighbor($e_index, $from, $to, $label) +Rel_($e_index, $from, $to, $label, "<<-") +!endfunction +!unquoted function RelIndex_Back_Neighbor($e_index, $from, $to, $label, $techn) +Rel_($e_index, $from, $to, $label, $techn, "<<-") +!endfunction + +!unquoted function Rel_D($from, $to, $label) +Rel_($index, $from, $to, $label, "-DOWN->>") +increment() +!endfunction +!unquoted function Rel_D($from, $to, $label, $techn) +Rel_($index, $from, $to, $label, $techn, "-DOWN->>") +increment() +!endfunction +!unquoted function Rel_Down($from, $to, $label) +Rel_($index, $from, $to, $label, "-DOWN->>") +increment() +!endfunction +!unquoted function Rel_Down($from, $to, $label, $techn) +Rel_($index, $from, $to, $label, $techn, "-DOWN->>") +increment() +!endfunction +!unquoted function RelIndex_D($e_index, $from, $to, $label) +Rel_($e_index, $from, $to, $label, "-DOWN->>") +!endfunction +!unquoted function RelIndex_D($e_index, $from, $to, $label, $techn) +Rel_($e_index, $from, $to, $label, $techn, "-DOWN->>") +!endfunction +!unquoted function RelIndex_Down($e_index, $from, $to, $label) +Rel_($e_index, $from, $to, $label, "-DOWN->>") +!endfunction +!unquoted function RelIndex_Down($e_index, $from, $to, $label, $techn) +Rel_($e_index, $from, $to, $label, $techn, "-DOWN->>") +!endfunction + +!unquoted function Rel_U($from, $to, $label) +Rel_($index, $from, $to, $label, "-UP->>") +increment() +!endfunction +!unquoted function Rel_U($from, $to, $label, $techn) +Rel_($index, $from, $to, $label, $techn, "-UP->>") +increment() +!endfunction +!unquoted function Rel_Up($from, $to, $label) +Rel_($index, $from, $to, $label, "-UP->>") +increment() +!endfunction +!unquoted function Rel_Up($from, $to, $label, $techn) +Rel_($index, $from, $to, $label, $techn, "-UP->>") +increment() +!endfunction +!unquoted function RelIndex_U($e_index, $from, $to, $label) +Rel_($e_index, $from, $to, $label, "-UP->>") +!endfunction +!unquoted function RelIndex_U($e_index, $from, $to, $label, $techn) +Rel_($e_index, $from, $to, $label, $techn, "-UP->>") +!endfunction +!unquoted function RelIndex_Up($e_index, $from, $to, $label) +Rel_($e_index, $from, $to, $label, "-UP->>") +!endfunction +!unquoted function RelIndex_Up($e_index, $from, $to, $label, $techn) +Rel_($e_index, $from, $to, $label, $techn, "-UP->>") +!endfunction + +!unquoted function Rel_L($from, $to, $label) +Rel_($index, $from, $to, $label, "-LEFT->>") +increment() +!endfunction +!unquoted function Rel_L($from, $to, $label, $techn) +Rel_($index, $from, $to, $label, $techn, "-LEFT->>") +increment() +!endfunction +!unquoted function Rel_Left($from, $to, $label) +Rel_($index, $from, $to, $label, "-LEFT->>") +increment() +!endfunction +!unquoted function Rel_Left($from, $to, $label, $techn) +Rel_($index, $from, $to, $label, $techn, "-LEFT->>") +increment() +!endfunction +!unquoted function RelIndex_L($e_index, $from, $to, $label) +Rel_($e_index, $from, $to, $label, "-LEFT->>") +!endfunction +!unquoted function RelIndex_L($e_index, $from, $to, $label, $techn) +Rel_($e_index, $from, $to, $label, $techn, "-LEFT->>") +!endfunction +!unquoted function RelIndex_Left($e_index, $from, $to, $label) +Rel_($e_index, $from, $to, $label, "-LEFT->>") +!endfunction +!unquoted function RelIndex_Left($e_index, $from, $to, $label, $techn) +Rel_($e_index, $from, $to, $label, $techn, "-LEFT->>") +!endfunction + +!unquoted function Rel_R($from, $to, $label) +Rel_($index, $from, $to, $label, "-RIGHT->>") +increment() +!endfunction +!unquoted function Rel_R($from, $to, $label, $techn) +Rel_($index, $from, $to, $label, $techn, "-RIGHT->>") +increment() +!endfunction +!unquoted function Rel_Right($from, $to, $label) +Rel_($index, $from, $to, $label, "-RIGHT->>") +increment() +!endfunction +!unquoted function Rel_Right($from, $to, $label, $techn) +Rel_($index, $from, $to, $label, $techn, "-RIGHT->>") +increment() +!endfunction +!unquoted function RelIndex_R($e_index, $from, $to, $label) +Rel_($e_index, $from, $to, $label, "-RIGHT->>") +!endfunction +!unquoted function RelIndex_R($e_index, $from, $to, $label, $techn) +Rel_($e_index, $from, $to, $label, $techn, "-RIGHT->>") +!endfunction +!unquoted function RelIndex_Right($e_index, $from, $to, $label) +Rel_($e_index, $from, $to, $label, "-RIGHT->>") +!endfunction +!unquoted function RelIndex_Right($e_index, $from, $to, $label, $techn) +Rel_($e_index, $from, $to, $label, $techn, "-RIGHT->>") +!endfunction + + diff --git a/samples/C4_Dynamic Diagram Sample - bigbankplc.puml b/samples/C4_Dynamic Diagram Sample - bigbankplc.puml new file mode 100644 index 0000000..9090ca7 --- /dev/null +++ b/samples/C4_Dynamic Diagram Sample - bigbankplc.puml @@ -0,0 +1,20 @@ +@startuml +!include https://raw.githubusercontent.com/adrianvlupu/C4-PlantUML/latest/C4_Dynamic.puml +' uncomment the following line and comment the first to use locally +' !include C4_Dynamic.puml + +' Structurizr.DynamicView: SignIn +title API Application - Dynamic + +LAYOUT_WITH_LEGEND() + +ContainerDb(InternetBankingSystem__Database__1edef6c, "Database", "Relational Database Schema", "Stores user registration information, hashed authentication credentials, access logs, etc.") +Container(InternetBankingSystem__SinglePageApplication__23f6823, "Single-Page Application", "JavaScript and Angular", "Provides all of the Internet banking functionality to customers via their web browser.") +Container_Boundary(InternetBankingSystem__APIApplication__31f1f25, "API Application") { + Component(InternetBankingSystem__APIApplication__SecurityComponent__10c9772, "Security Component", "Spring Bean", "Provides functionality Related to signing in, changing passwords, etc.") + Component(InternetBankingSystem__APIApplication__SignInController__1fa4f18, "Sign In Controller", "Spring MVC Rest Controller", "Allows users to sign in to the Internet Banking System.") +} +Rel_R(InternetBankingSystem__SinglePageApplication__23f6823, InternetBankingSystem__APIApplication__SignInController__1fa4f18, "Submits credentials to", "JSON/HTTPS") +Rel(InternetBankingSystem__APIApplication__SignInController__1fa4f18, InternetBankingSystem__APIApplication__SecurityComponent__10c9772, "Calls isAuthenticated() on") +Rel_R(InternetBankingSystem__APIApplication__SecurityComponent__10c9772, InternetBankingSystem__Database__1edef6c, "select * from users where username = ?", "JDBC") +@enduml \ No newline at end of file diff --git a/samples/C4_Dynamic Diagram Sample - message bus.puml b/samples/C4_Dynamic Diagram Sample - message bus.puml new file mode 100644 index 0000000..c6a687c --- /dev/null +++ b/samples/C4_Dynamic Diagram Sample - message bus.puml @@ -0,0 +1,39 @@ +@startuml +!include https://raw.githubusercontent.com/adrianvlupu/C4-PlantUML/latest/C4_Dynamic.puml +' uncomment the following line and comment the first to use locally +' !include C4_Dynamic.puml + +LAYOUT_TOP_DOWN() +' LAYOUT_AS_SKETCH() +LAYOUT_WITH_LEGEND() + +Person(customer, Customer, "A customer") +System_Boundary(c1, "Customer Information") { + Container(app, "Customer Application", "Javascript, Angular", "Allows customers to manage their profile") + Container(customer_service, "Customer Service", "Java, Spring Boot", "The point of access for customer information") + Container(message_bus, "Message Bus", "RabbitMQ", "Transport for business events") + Container(reporting_service, "Reporting Service", "Ruby", "Creates normalised data for reporting purposes") + Container(audit_service, "Audit Service", "C#/.NET", "Provides organisation-wide auditing facilities") + ContainerDb(customer_db, "Customer Database", "Oracle 12c", "Stores customer information") + ContainerDb(reporting_db, "Reporting Database", "MySQL", "Stores a normalized version of all business data for ad hoc reporting purposes") + Container(audit_store, "Audit Store", "Event Store", "Stores information about events that have happened") +} + +'simple order with Rel +Rel(customer, app, "Updates his profile using", "HTTPS") +Rel(app, customer_service, "Updates customer information using", "JSON/HTTPS") +Rel(customer_service, customer_db, "Stores data in", "JDBC") + +RelIndex($index-1, customer_service, message_bus, "Sends customer update events to", "async") +RelIndex($index-2, customer_service, app, "Confirm update to", "async") +increment() + +RelIndex($index-1, message_bus, reporting_service, "Sends customer update events to", "async") +increment() +RelIndex($index-1, reporting_service, reporting_db, "Stores data in") + +setIndex(5) +RelIndex($index-2, message_bus, audit_service, "Sends customer update events to", "async") +increment() +RelIndex($index-2, audit_service, audit_store, "Stores events in") +@enduml \ No newline at end of file