PlantUML auto-detects the diagram type based on the first unique item in the code
Sequence Diagram
Use Case Diagram
Class Diagram
Activity Diagram
UNDER CONSTRUCTION
Sequence diagrams present ordered events that occur between participants (actors) over time (which runs top-to-bottom)
Here is a simple example:
@startuml
title Alice and Bob do a 3-Way TCP Handshake
Alice -> Bob: SYN
Bob --> Alice: SYN+ACK
Alice -> Bob: ACK
@enduml
There are multiple types of participant that can be used to trigger a sequence diagram, as per the types in the example below:
@startuml
title Sequence Participants
' Specify the participants left to right:
participant Participant
actor Actor
boundary Boundary
control Control
entity Entity
database Database
collections Collections
' Specify the events (in order):
group authentication
Actor -> Boundary: Request Logon
Boundary -> Actor: Provide Credentials
Actor -> Boundary: username: actor, password: example123
Boundary -> Actor: Accepted
end
Actor -> Boundary: List all options
Boundary -> Control: List all options (actor)
Control -> Entity: List all options (actor)
@enduml
The order that that participants is declared determines their order left to right in the diagram, and the order of the events is the order top to bottom
Another example showing setting colours etc:
@startuml
Title Another Sequence Diagram Example
skinparam ParticipantBackgroundColor SkyBlue
skinparam ParticipantBorderColor Black
' Set default colours for the horizontal arrows and vertical traces:
skinparam sequence {
ArrowColor blue
LifeLineBorderColor black
}
' disable the bottom boxes for aesthetic reasons:
hide footbox
' Set default colors for notes:
skinparam NoteBackgroundColor Yellow
skinparam NoteBorderColor black
' Participants:
participant “Alice\nin\nWonderland” as alice
participant “Bob\n\n” as bob
participant “Mad\nHatter\n” as hatter
alice -> bob: what this means
note right: Written by Lewis Carroll
bob -[#red]> hatter: this arrow is red
hatter -[#black]> alice: This is all\nnonsense!
@enduml
TBD
Auto detect use case diagram type by TBD
TBD
Auto detect class diagram type by use of line type:
- <|--
- *--
- o--
- ..
- --
TBD
Auto detect activity diagram type by lines that start with : and end with ;