# Diagram Examples ## Basic sequence diagram UML ```plantuml Bob -> Alice ``` ## Not so Basic sequence diagram UML ```plantuml header Architecture Blob footer Nonsense Dept title Order Flow actor "Web User" as Webuser participant "Web Frontend" as Frontend participant "Gateway" as Gateway participant "Identity Service" as Identity #Yellow participant "Rest API" as RestApi database Orders autonumber Webuser -> Frontend ++ : request connection group Step: Token lifecycle Frontend -> Gateway ++ : request authentication Gateway -> Identity ++ : sends token Identity --> Identity : verify ID Identity -[#green]> Gateway -- : token authenticated autonumber 5.1 else Request Failed Identity -[#red]> Gateway : Token not valid Gateway -[#red]> Frontend : Connection Refused Frontend -[#red]> Webuser : Authentication Failed note left : authentication failed end autonumber 6 Gateway -[#green]> Frontend : Connecton Established Frontend -[#green]> Webuser -- : response OK note left : authentication successful group Call Orders API Gateway -> RestApi ++ : GET api/v1/orders RestApi --> RestApi : Internal Processing group Database Interactions RestApi -> Orders ++ : Query Orders DB Orders -> RestApi -- : Orders end end ``` ## UML diagram with AWS objects ```plantuml !define AWSPuml https://raw.githubusercontent.com/awslabs/aws-icons-for-plantuml/v11.1/dist !include AWSPuml/AWSCommon.puml ' Uncomment the following line to create simplified view ' !includeurl AWSPuml/AWSSimplified.puml !includeurl AWSPuml/General/Users.puml !includeurl AWSPuml/ApplicationIntegration/APIGateway.puml !includeurl AWSPuml/SecurityIdentityCompliance/Cognito.puml !includeurl AWSPuml/Compute/Lambda.puml !includeurl AWSPuml/Database/DynamoDB.puml left to right direction Users(sources, "Events", "millions of users") APIGateway(votingAPI, "Voting API", "user votes") Cognito(userAuth, "User Authentication", "jwt to submit votes") Lambda(generateToken, "User Credentials", "return jwt") Lambda(recordVote, "Record Vote", "enter or update vote per user") DynamoDB(voteDb, "Vote Database", "one entry per user") sources --> userAuth sources --> votingAPI : sticazzi userAuth <--> generateToken votingAPI --> recordVote recordVote --> voteDb ``` ## UML sequence diagram with AWS objects ```plantuml !define AWSPuml https://raw.githubusercontent.com/awslabs/aws-icons-for-plantuml/v11.1/dist !includeurl AWSPuml/AWSCommon.puml !includeurl AWSPuml/Compute/all.puml !includeurl AWSPuml/ApplicationIntegration/APIGateway.puml !includeurl AWSPuml/General/Internetalt1.puml !includeurl AWSPuml/Database/DynamoDB.puml actor User as user APIGatewayParticipant(api, Credit Card System, All methods are POST) LambdaParticipant(lambda,AuthorizeCard,) DynamoDBParticipant(db, PaymentTransactions, sortkey=transaction_id+token) Internetalt1Participant(processor, Authorizer, Returns status and token) user -> api: Process transaction\nPOST /prod/process api -> lambda: Invokes lambda with cardholder details lambda -> processor: Submit via API token\ncard number, expiry, CID processor -> processor: Validate and create token processor -> lambda: Returns status code and token lambda -> db: PUT transaction id, token lambda -> api: Returns\nstatus code, transaction id api -> user: Returns status code ``` ## C4 PlantUML ```plantuml !include https://raw.githubusercontent.com/plantuml-stdlib/C4-PlantUML/master/C4_Container.puml SHOW_PERSON_OUTLINE() AddElementTag("backendContainer", $fontColor=$ELEMENT_FONT_COLOR, $bgColor="#335DA5", $shape=EightSidedShape(), $legendText="backend container (eight sided)") AddRelTag("async", $textColor=$ARROW_COLOR, $lineColor=$ARROW_COLOR, $lineStyle=DashedLine()) AddRelTag("sync/async", $textColor=$ARROW_COLOR, $lineColor=$ARROW_COLOR, $lineStyle=DottedLine()) title Container diagram for Internet Banking System Person(customer, Customer, "A customer of the bank, with personal bank accounts") System_Boundary(c1, "Internet Banking") { Container(web_app, "Web Application", "Java, Spring MVC", "Delivers the static content and the Internet banking SPA") Container(spa, "Single-Page App", "JavaScript, Angular", "Provides all the Internet banking functionality to cutomers via their web browser") Container(mobile_app, "Mobile App", "C#, Xamarin", "Provides a limited subset of the Internet banking functionality to customers via their mobile device") ContainerDb(database, "Database", "SQL Database", "Stores user registration information, hashed auth credentials, access logs, etc.") Container(backend_api, "API Application", "Java, Docker Container", "Provides Internet banking functionality via API", $tags="backendContainer") } System_Ext(email_system, "E-Mail System", "The internal Microsoft Exchange system") System_Ext(banking_system, "Mainframe Banking System", "Stores all of the core banking information about customers, accounts, transactions, etc.") Rel(customer, web_app, "Uses", "HTTPS") Rel(customer, spa, "Uses", "HTTPS") Rel(customer, mobile_app, "Uses") Rel_Neighbor(web_app, spa, "Delivers") Rel(spa, backend_api, "Uses", "async, JSON/HTTPS", $tags="async") Rel(mobile_app, backend_api, "Uses", "async, JSON/HTTPS", $tags="async") Rel_Back_Neighbor(database, backend_api, "Reads from and writes to", "sync, JDBC") Rel_Back(customer, email_system, "Sends e-mails to") Rel_Back(email_system, backend_api, "Sends e-mails using", "sync, SMTP") Rel_Neighbor(backend_api, banking_system, "Uses", "sync/async, XML/HTTPS", $tags="sync/async") SHOW_LEGEND() ``` ## UML Sequence with vertical phases ```plantuml actor Administrator == Create some Audit settings == Administrator -> Watcher : create new Audit Template (i.e. Audit settings : goal, scope, ...) Watcher -> Watcher : save Audit Template in database Administrator <-- Watcher : Audit Template UUID == Launch a new Audit == Administrator -> Watcher : launch new Audit of the Openstack infrastructure resources\nwith a previously created Audit Template Administrator <-- Watcher : Audit UUID Administrator -> Watcher : get the Audit state Administrator <-- Watcher : ONGOING Watcher -> Watcher : compute a solution to achieve optimization goal Administrator -> Watcher : get the Audit state Administrator <-- Watcher : SUCCEEDED == Get the result of the Audit == Administrator -> Watcher : get Action Plan Administrator <-- Watcher : recommended Action Plan and estimated efficacy Administrator -> Administrator : verify the recommended actions\nand evaluate the estimated gain vs aggressiveness of the solution == Launch the recommended Action Plan == Administrator -> Watcher : launch the Action Plan Administrator <-- Watcher : Action Plan has been launched Watcher -> Watcher : trigger Actions on Openstack services Administrator -> Watcher : get the Action Plan state Administrator <-- Watcher : ONGOING Administrator -> Watcher : get the Action Plan state Administrator <-- Watcher : SUCCEEDED @enduml ```