2020import logging
2121
2222from structurizr import Workspace
23- from structurizr .model import InteractionStyle
23+ from structurizr .model import InteractionStyle , Tags
24+ from structurizr .view import Border , ElementStyle , RelationshipStyle , Shape
2425
2526
2627TAG_ALERT = "Alert"
2728
2829
29- def main ():
30+ def main () -> Workspace :
3031 """Create the financial risk system example."""
32+
33+ ALERT_TAG = "Alert"
34+
3135 workspace = Workspace (
3236 name = "Financial Risk System" ,
3337 description = "This is a simple (incomplete) example C4 model based upon the "
@@ -39,14 +43,14 @@ def main():
3943
4044 financial_risk_system = model .add_software_system (
4145 name = "Financial Risk System" ,
42- description = "Calculates the bank's exposure to risk for product X." ,
46+ description = "Calculates the banks exposure to risk for product X." ,
4347 )
4448
4549 business_user = model .add_person (
4650 name = "Business User" , description = "A regular business user."
4751 )
4852 business_user .uses (
49- destination = financial_risk_system , description = "View reports using"
53+ destination = financial_risk_system , description = "Views reports using"
5054 )
5155
5256 configuration_user = model .add_person (
@@ -80,13 +84,13 @@ def main():
8084 description = "Manages reference data for all counterparties the bank interacts "
8185 "with." ,
8286 )
83- reference_data_system_v2 .add_tags ("Future State" )
87+ reference_data_system_v2 .tags . add ("Future State" )
8488 financial_risk_system .uses (
8589 destination = reference_data_system_v2 , description = "Gets counterparty data from"
86- ).add_tags ("Future State" )
90+ ).tags . add ("Future State" )
8791
8892 email_system = model .add_software_system (
89- name = "E-mail system" , description = "The bank's Microsoft Exchange system."
93+ name = "E-mail system" , description = "The banks Microsoft Exchange system."
9094 )
9195 financial_risk_system .uses (
9296 destination = email_system ,
@@ -101,24 +105,66 @@ def main():
101105
102106 central_monitoring_service = model .add_software_system (
103107 name = "Central Monitoring Service" ,
104- description = "The bank's central monitoring and alerting dashboard." ,
108+ description = "The banks central monitoring and alerting dashboard." ,
105109 )
106110 financial_risk_system .uses (
107111 destination = central_monitoring_service ,
108112 description = "Sends critical failure alerts to" ,
109113 technology = "SNMP" ,
110114 interaction_style = InteractionStyle .Asynchronous ,
111- ).add_tags ( TAG_ALERT )
115+ ).tags . add ( ALERT_TAG )
112116
113117 active_directory = model .add_software_system (
114118 name = "Active Directory" ,
115- description = "The bank's authentication and authorisation system." ,
119+ description = "The banks authentication and authorisation system." ,
116120 )
117121 financial_risk_system .uses (
118122 destination = active_directory ,
119123 description = "Uses for user authentication and authorisation" ,
120124 )
121125
126+ views = workspace .views
127+ contextView = views .create_system_context_view (
128+ software_system = financial_risk_system ,
129+ key = "Context" ,
130+ description = "An example System Context diagram for the Financial Risk System architecture kata." ,
131+ )
132+ contextView .add_all_software_systems ()
133+ contextView .add_all_people ()
134+
135+ styles = views .configuration .styles
136+ financial_risk_system .tags .add ("Risk System" )
137+
138+ styles .add (ElementStyle (tag = Tags .ELEMENT , color = "#ffffff" , font_size = 34 ))
139+ styles .add (ElementStyle (tag = "Risk System" , background = "#550000" , color = "#ffffff" ))
140+ styles .add (
141+ ElementStyle (
142+ tag = Tags .SOFTWARE_SYSTEM ,
143+ width = 650 ,
144+ height = 400 ,
145+ background = "#801515" ,
146+ shape = Shape .RoundedBox ,
147+ )
148+ )
149+ styles .add (
150+ ElementStyle (
151+ tag = Tags .PERSON , width = 550 , background = "#d46a6a" , shape = Shape .Person
152+ )
153+ )
154+
155+ styles .add (
156+ RelationshipStyle (
157+ tag = Tags .RELATIONSHIP , thickness = 4 , dashed = False , font_size = 32 , width = 400
158+ )
159+ )
160+ styles .add (RelationshipStyle (tag = Tags .SYNCHRONOUS , dashed = False ))
161+ styles .add (RelationshipStyle (tag = Tags .ASYNCHRONOUS , dashed = True ))
162+ styles .add (RelationshipStyle (tag = ALERT_TAG , color = "#ff0000" ))
163+ styles .add (ElementStyle (tag = "Future State" , opacity = 30 , border = Border .Dashed ))
164+ styles .add (RelationshipStyle (tag = "Future State" , opacity = 30 , dashed = True ))
165+
166+ return workspace
167+
122168
123169if __name__ == "__main__" :
124170 logging .basicConfig (level = "INFO" )
0 commit comments