1616"""
1717Provide a 'Big Bank' example.
1818
19- Illustrate how to create a software architecture diagram using code.
19+ Illustrate how to create a software architecture diagram using code, based on
20+ https://github.com/structurizr/dsl/blob/master/examples/big-bank-plc.dsl.
2021"""
2122
2223
2728from structurizr .view import ElementStyle , PaperSize , RelationshipStyle , Shape
2829
2930
30- def main ():
31+ def create_big_bank ():
3132 """Create the big bank example."""
3233
3334 workspace = Workspace (
@@ -55,6 +56,7 @@ def main():
5556 location = Location .External ,
5657 name = "Personal Banking Customer" ,
5758 description = "A customer of the bank, with personal bank accounts." ,
59+ id = "customer" ,
5860 )
5961
6062 internet_banking_system = model .add_software_system (
@@ -64,8 +66,11 @@ def main():
6466 "Allows customers to view information about "
6567 "their bank accounts, and make payments."
6668 ),
69+ id = "internetBankingSystem" ,
70+ )
71+ customer .uses (
72+ internet_banking_system , "Views account balances, and makes payments using"
6773 )
68- customer .uses (internet_banking_system , "Uses" )
6974
7075 mainframe_banking_system = model .add_software_system (
7176 location = Location .Internal ,
@@ -74,14 +79,19 @@ def main():
7479 "Stores all of the core banking information "
7580 "about customers, accounts, transactions, etc."
7681 ),
82+ id = "mainframe" ,
7783 )
7884 mainframe_banking_system .tags .add (existing_system_tag )
79- internet_banking_system .uses (mainframe_banking_system , "Uses" )
85+ internet_banking_system .uses (
86+ mainframe_banking_system ,
87+ "Gets account information from, and makes payments using" ,
88+ )
8089
8190 email_system = model .add_software_system (
8291 location = Location .Internal ,
8392 name = "E-mail System" ,
8493 description = "The internal Microsoft Exchange e-mail system." ,
94+ id = "email" ,
8595 )
8696 internet_banking_system .uses (
8797 destination = email_system ,
@@ -97,6 +107,7 @@ def main():
97107 location = Location .Internal ,
98108 name = "ATM" ,
99109 description = "Allows customers to withdraw cash." ,
110+ id = "atm" ,
100111 )
101112 atm .tags .add (existing_system_tag )
102113 atm .uses (mainframe_banking_system , "Uses" )
@@ -106,6 +117,7 @@ def main():
106117 location = Location .Internal ,
107118 name = "Customer Service Staff" ,
108119 description = "Customer service staff within the bank." ,
120+ id = "supportStaff" ,
109121 )
110122 customer_service_staff .tags .add (bank_staff_tag )
111123 customer_service_staff .uses (mainframe_banking_system , "Uses" )
@@ -117,6 +129,7 @@ def main():
117129 location = Location .Internal ,
118130 name = "Back Office Staff" ,
119131 description = "Administration and support staff within the bank." ,
132+ id = "backoffice" ,
120133 )
121134 backOfficeStaff .tags .add (bank_staff_tag )
122135 backOfficeStaff .uses (mainframe_banking_system , "Uses" )
@@ -129,28 +142,33 @@ def main():
129142 "to customers via their web browser."
130143 ),
131144 "JavaScript and Angular" ,
145+ id = "singlePageApplication" ,
132146 )
133147 single_page_application .tags .add (web_browser_tag )
134148 mobile_app = internet_banking_system .add_container (
135149 "Mobile App" ,
136150 "Provides a limited subset of the Internet banking functionality to customers via their mobile device." ,
137151 "Xamarin" ,
152+ id = "mobileApp" ,
138153 )
139154 mobile_app .tags .add (mobile_app_tag )
140155 web_application = internet_banking_system .add_container (
141156 "Web Application" ,
142157 "Delivers the static content and the Internet banking single page application." ,
143158 "Java and Spring MVC" ,
159+ id = "webApplication" ,
144160 )
145161 api_application = internet_banking_system .add_container (
146162 "API Application" ,
147163 "Provides Internet banking functionality via a JSON/HTTPS API." ,
148164 "Java and Spring MVC" ,
165+ id = "apiApplication" ,
149166 )
150167 database = internet_banking_system .add_container (
151168 "Database" ,
152169 "Stores user registration information, hashed authentication credentials, access logs, etc." ,
153170 "Relational Database Schema" ,
171+ id = "database" ,
154172 )
155173 database .tags .add (database_tag )
156174
@@ -172,31 +190,37 @@ def main():
172190 name = "Sign In Controller" ,
173191 description = "Allows users to sign in to the Internet Banking System." ,
174192 technology = "Spring MVC Rest Controller" ,
193+ id = "signinController" ,
175194 )
176195 accounts_summary_controller = api_application .add_component (
177196 name = "Accounts Summary Controller" ,
178197 description = "Provides customers with a summary of their bank accounts." ,
179198 technology = "Spring MVC Rest Controller" ,
199+ id = "accountsSummaryController" ,
180200 )
181201 reset_password_controller = api_application .add_component (
182202 name = "Reset Password Controller" ,
183203 description = "Allows users to reset their passwords with a single use URL." ,
184204 technology = "Spring MVC Rest Controller" ,
205+ id = "resetPasswordController" ,
185206 )
186207 security_component = api_application .add_component (
187208 name = "Security Component" ,
188209 description = "Provides functionality related to signing in, changing passwords, etc." ,
189210 technology = "Spring Bean" ,
211+ id = "securityComponent" ,
190212 )
191213 mainframe_banking_systemFacade = api_application .add_component (
192214 name = "Mainframe Banking System Facade" ,
193215 description = "A facade onto the mainframe banking system." ,
194216 technology = "Spring Bean" ,
217+ id = "mainframeBankingSystemFacade" ,
195218 )
196219 email_component = api_application .add_component (
197220 name = "E-mail Component" ,
198221 description = "Sends e-mails to users." ,
199222 technology = "Spring Bean" ,
223+ id = "emailComponent" ,
200224 )
201225
202226 for component in api_application .components :
@@ -440,4 +464,4 @@ def main():
440464
441465if __name__ == "__main__" :
442466 logging .basicConfig (level = "INFO" )
443- main ()
467+ create_big_bank ()
0 commit comments