Skip to content

How to code Sequence Diagram

Posted on:December 6, 2023 at 02:00 PM

Two Pencils

Developers frequently employ Sequence Diagrams to depict the interactions among micro-services. These diagrams illustrate how diverse services collaborate to accomplish a specific task. As the sequence diagram undergoes modifications with each system design iteration, manually redrawing the diagram becomes laborious and inefficient. To enhance productivity, PlantUML allows developers to articulate service interactions through code. The tool then seamlessly transforms the code into a visual diagram. This approach ensures that any alterations in the initial system design result in minimal changes to the code, facilitating swift updates and diagram regeneration.

Sample Authentication Workflow

How to implement by code

Code:

@startuml
Employee -> LoginService: login(userName, userPass)
LoginService -> AuthService: request_access(userName, userPass)
AuthService --> LoginService: request is rejected
LoginService --> Employee: fail to login
@enduml

Remark:
-> is solid line arrow that represents a request

- -> is dashed line arrow that represents a response

Generate Diagram:
Copy above code into this PlantUML Web Server and click Submit