Skip to main content

Diagram - plantuml

Sequence Diagram

Creating sequence diagrams with PlantUML is remarkably straightforward. This ease of use is largely attributed to the user-friendly nature of its syntax, designed to be both intuitive and easy to remember.

Example 1

```plantuml
Alice -> Bob: Authentication Request
Bob --> Alice: Authentication Response

Alice -> Bob: Another authentication Request
Alice <-- Bob: Another authentication Response
```

AliceAliceBobBobAuthentication RequestAuthentication ResponseAnother authentication RequestAnother authentication Response

Example 2

```plantuml
participant Participant as Foo
actor Actor as Foo1
boundary Boundary as Foo2
control Control as Foo3
entity Entity as Foo4
database Database as Foo5
collections Collections as Foo6
queue Queue as Foo7
Foo -> Foo1 : To actor
Foo -> Foo2 : To boundary
Foo -> Foo3 : To control
Foo -> Foo4 : To entity
Foo -> Foo5 : To database
Foo -> Foo6 : To collections
Foo -> Foo7: To queue
```

ParticipantParticipantActorActorBoundaryBoundaryControlControlEntityEntityDatabaseDatabaseCollectionsCollectionsQueueQueueTo actorTo boundaryTo controlTo entityTo databaseTo collectionsTo queue

Example 3

You can also change the background color of actor or participant.

```plantuml
actor Bob #red
' The only difference between actor
'and participant is the drawing
participant Alice
participant "I have a really\nlong name" as L #99FF99
/' You can also declare:
participant L as "I have a really\nlong name" #99FF99
'/

Alice->Bob: Authentication Request
Bob->Alice: Authentication Response
Bob->L: Log transaction
```

BobBobAliceAliceI have a reallylong nameI have a reallylong nameAuthentication RequestAuthentication ResponseLog transaction

```plantuml
@startuml
actor User
User -> Sales: ProcessOrder
activate Sales #FFBBBB
Sales -> Warehouse: << packOrder >>
activate Warehouse #gold
Warehouse -> Picker: GetProducts
activate Picker #005500
Picker --> Warehouse: ProductsCollected
deactivate Picker
Warehouse --> Sales: OrderPacked
deactivate Warehouse
Sales -> Sales: SendOrder
Sales -> User: OrderSent
deactivate Sales
@enduml
```

UserUserSalesSalesWarehouseWarehousePickerPickerProcessOrder«packOrder»GetProductsProductsCollectedOrderPackedSendOrderOrderSent

```plantuml
Alice -> Bob: Authentication Request

alt successful case

Bob -> Alice: Authentication Accepted

else some kind of failure

Bob -> Alice: Authentication Failure
group My own label
Alice -> Log : Log attack start
loop 1000 times
Alice -> Bob: DNS Attack
end
Alice -> Log : Log attack end
end

else Another type of failure

Bob -> Alice: Please repeat

end
```

AliceAliceBobBobLogLogAuthentication Requestalt[successful case]Authentication Accepted[some kind of failure]Authentication FailureMy own labelLog attack startloop[1000 times]DNS AttackLog attack end[Another type of failure]Please repeat

Usecase

```plantuml
left to right direction
actor Guest as g
package Professional {
actor Chef as c
actor "Food Critic" as fc
}
package Restaurant {
usecase "Eat Food" as UC1
usecase "Pay for Food" as UC2
usecase "Drink" as UC3
usecase "Review" as UC4
}
fc --> UC4
g --> UC1
g --> UC2
g --> UC3
```

ProfessionalRestaurantChefFood CriticEat FoodPay for FoodDrinkReviewGuest

Class diagram

```plantuml
abstract abstract
abstract class "abstract class"
annotation annotation
circle circle
() circle_short_form
class class
class class_stereo <<stereotype>>
diamond diamond
<> diamond_short_form
entity entity
enum enum
exception exception
interface interface
metaclass metaclass
protocol protocol
stereotype stereotype
struct struct
```

abstractabstract classannotationcirclecircle_short_formclass«stereotype»class_stereoentityenumexceptioninterfacemetaclassprotocolstereotypestruct

Relations between classes

Relations between classes are defined using the following symbols. It is possible to replace -- by .. to have a dotted line. Knowing those rules, it is possible to draw the following drawings:

```plantuml
Class01 <|-- Class02
Class03 *-- Class04
Class05 o-- Class06
Class07 .. Class08
Class09 -- Class10
```

Class01Class02Class03Class04Class05Class06Class07Class08Class09Class10

```plantuml
Class11 <|.. Class12
Class13 --> Class14
Class15 ..> Class16
Class17 ..|> Class18
Class19 <--* Class20
```

Class11Class12Class13Class14Class15Class16Class17Class18Class19Class20

```plantuml
Class21 #-- Class22
Class23 x-- Class24
Class25 }-- Class26
Class27 +-- Class28
Class29 ^-- Class30
```

Class21Class22Class23Class24Class25Class26Class27Class28Class29Class30

Label on relations

It is possible to add a label on the relation, using :, followed by the text of the label.

For cardinality, you can use double-quotes "" on each side of the relation.

```plantuml
Class01 "1" *-- "many" Class02 : contains
Class03 o-- Class04 : aggregation
Class05 --> "1" Class06
```

Class01Class02Class03Class04Class05Class06contains1manyaggregation1

```plantuml
class Dummy {
String data
void methods()
}

class Flight {
flightNumber : Integer
departureTime : Date
}
```

DummyString datavoid methods()FlightflightNumber : IntegerdepartureTime : Date

Definition Visibility

When you define methods or fields, you can use characters to define the visibility of the corresponding item:

CharacterIcon for fieldIcon for methodVisibility
-imgimgprivate
#imgimgprotected
~imgimgpackage private
+imgimgpublic
```plantuml
class Dummy {
-field1
#field2
~method1()
+method2()
}
```

Dummyfield1field2method1()method2()

Deployment Digram

A Deployment Diagram is a type of diagram that visualizes the architecture of systems, showcasing how software components are deployed onto hardware. It provides a clear picture of the distribution of components across various nodes, such as servers, workstations, and devices.

With PlantUML, creating deployment diagrams becomes a breeze. The platform offers a simple and intuitive way to design these diagrams using plain text, ensuring rapid iterations and easy version control. Moreover, the PlantUML forum provides a vibrant community where users can seek help, share ideas, and collaborate on diagramming challenges. One of the key advantages of PlantUML is its ability to integrate seamlessly with various tools and platforms, making it a preferred choice for professionals and enthusiasts alike.

```plantuml
action action
actor actor
actor/ "actor/"
agent agent
artifact artifact
boundary boundary
card card
circle circle
cloud cloud
collections collections
component component
control control
database database
entity entity
file file
folder folder
frame frame
hexagon hexagon
interface interface
label label
node node
package package
person person
process process
queue queue
rectangle rectangle
stack stack
storage storage
usecase usecase
usecase/ "usecase/"
```

actionactoractor/agentartifactboundarycardcirclecloudcollectionscomponentcontroldatabaseentityfilefolderframehexagoninterfacelabelnodepackagepersonprocessqueuerectanglestackstorageusecaseusecase/

```plantuml
@startsalt
{
Just plain text
[This is my button]
() Unchecked radio
(X) Checked radio
[] Unchecked box
[X] Checked box
"Enter text here "
^This is a droplist^
}
@endsalt
```

Just plain textThis is my buttonUnchecked radioChecked radioUnchecked boxChecked boxEnter text hereThis is a droplist

Mindmap Example

```plantuml
@startmindmap
+ OS
++ Ubuntu
+++ Linux Mint
+++ Kubuntu
+++ Lubuntu
+++ KDE Neon
++ LMDE
++ SolydXK
++ SteamOS
++ Raspbian
-- Windows 95
-- Windows 98
-- Windows NT
--- Windows 8
--- Windows 10
@endmindmap
```

OSUbuntuLinux MintKubuntuLubuntuKDE NeonLMDESolydXKSteamOSRaspbianWindows 95Windows 98Windows NTWindows 8Windows 10

```plantuml
@startmindmap
+[#Orange] Colors
++[#lightgreen] Green
++[#FFBBCC] Rose
--[#lightblue] Blue
@endmindmap
```

ColorsGreenRoseBlue

Display JSON

```plantuml
@startjson
{
"fruit":"Apple",
"size":"Large",
"color": ["Red", "Green"]
}
@endjson
```

fruitApplesizeLargecolor   RedGreen

```plantuml
@startjson
{
"firstName": "John",
"lastName": "Smith",
"isAlive": true,
"age": 27,
"address": {
"streetAddress": "21 2nd Street",
"city": "New York",
"state": "NY",
"postalCode": "10021-3100"
},
"phoneNumbers": [
{
"type": "home",
"number": "212 555-1234"
},
{
"type": "office",
"number": "646 555-4567"
}
],
"children": [],
"spouse": null
}
@endjson
```

firstNameJohnlastNameSmithisAlive☑ trueage27address   phoneNumbers   children   spousestreetAddress21 2nd StreetcityNew YorkstateNYpostalCode10021-3100      typehomenumber212 555-1234typeofficenumber646 555-4567

```plantuml
@startjson
#highlight "lastName"
#highlight "address" / "city"
#highlight "phoneNumbers" / "0" / "number"
{
"firstName": "John",
"lastName": "Smith",
"isAlive": true,
"age": 28,
"address": {
"streetAddress": "21 2nd Street",
"city": "New York",
"state": "NY",
"postalCode": "10021-3100"
},
"phoneNumbers": [
{
"type": "home",
"number": "212 555-1234"
},
{
"type": "office",
"number": "646 555-4567"
}
],
"children": [],
"spouse": null
}
@endjson
```

firstNameJohnlastNameSmithisAlive☑ trueage28address   phoneNumbers   children   spousestreetAddress21 2nd StreetcityNew YorkstateNYpostalCode10021-3100      typehomenumber212 555-1234typeofficenumber646 555-4567

C4 Architecture Diagram

```plantuml
@startuml
!include C4_Container.puml

LAYOUT_TOP_DOWN()
LAYOUT_WITH_LEGEND()

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 registraion information, hased auth credentials, access logs, etc.")
Container(backend_api, "API Application", "Java, Docker Container", "Provides Internet banking functionality via API")
}

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")
Rel(mobile_app, backend_api, "Uses", "async, JSON/HTTPS")
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")
@enduml
```

Container diagram for Internet Banking SystemInternet Banking[System]Web Application[Java, Spring MVC] Delivers the static contentand the Internet bankingSPASingle-Page App[JavaScript, Angular] Provides all the Internetbanking functionality tocutomers via their webbrowserMobile App[C#, Xamarin] Provides a limited subset ofthe Internet bankingfunctionality to customers viatheir mobile deviceDatabase[SQL Database] Stores user registraioninformation, hased authcredentials, access logs, etc.API Application[Java, Docker Container] Provides Internet bankingfunctionality via APICustomer A customer of the bank, withpersonal bank accountsE-Mail System The internal MicrosoftExchange systemMainframe BankingSystem Stores all of the corebanking information aboutcustomers, accounts,transactions, etc.Uses[HTTPS]Uses[HTTPS]UsesDeliversUses[async, JSON/HTTPS]Uses[async, JSON/HTTPS]Reads from andwrites to[sync, JDBC]Sends e-mails toSends e-mails using[sync, SMTP]Uses[sync/async,XML/HTTPS]Legend personsystemcontainerexternal personexternal systemexternal container