PlantUML Reference

PlantUML diagramming. Sequence, class, component, activity, state, and deployment diagrams with UML semantics.

Sequence Diagrams

Basic sequence with participants and messages
@startuml
participant Client as C
participant "API Server" as S
database "PostgreSQL" as DB

C -> S: POST /login
activate S
S -> DB: SELECT user
activate DB
DB --> S: user row
deactivate DB
alt valid
    S --> C: 200 + JWT
else invalid
    S --> C: 401
end
deactivate S
@enduml

Arrow types: solid, -→ dashed, →> thin, →x lost message.

Class Diagrams

Class hierarchy with attributes and methods
@startuml
abstract class Device {
    - hostname: String
    - ip: String
    + connect(): bool
    + {abstract} backup(): void
}

class Switch extends Device {
    - vlan_count: int
    + show_vlans(): List
}

class Router extends Device {
    - protocol: String
    + show_routes(): List
}

Device "1" *-- "many" Interface
@enduml

Visibility: + public, - private, # protected, ~ package.

Component Diagrams

System architecture with components and interfaces
@startuml
package "Frontend" {
    [Web App] as web
}
package "Backend" {
    [API Gateway] as gw
    [Auth Service] as auth
    [Data Service] as data
}
database "PostgreSQL" as db

web --> gw: HTTPS
gw --> auth: verify JWT
gw --> data: REST
data --> db: SQL
@enduml

Activity Diagrams

Workflow with conditions and forks
@startuml
start
:Receive request;
if (Authenticated?) then (yes)
    :Process request;
    fork
        :Log to SIEM;
    fork again
        :Send response;
    end fork
else (no)
    :Return 401;
endif
stop
@enduml

State Diagrams

State machine with transitions and guards
@startuml
[*] --> Idle
Idle --> Authenticating: credentials received
Authenticating --> Authorized: valid
Authenticating --> Denied: invalid [attempts < 3]
Authenticating --> Locked: invalid [attempts >= 3]
Authorized --> Idle: logout
Denied --> Authenticating: retry
Locked --> [*]
@enduml

Deployment Diagrams

Infrastructure deployment layout
@startuml
node "DMZ" {
    [Firewall] as fw
    [Load Balancer] as lb
}
node "Application" {
    [API Server] as api
    [Worker] as wrk
}
node "Data" {
    database "Primary DB" as pdb
    database "Replica DB" as rdb
}
fw --> lb
lb --> api
api --> wrk
api --> pdb
pdb --> rdb: replication
@enduml

Theming

Catppuccin Mocha theme
@startuml
!theme plain
skinparam backgroundColor #1e1e2e
skinparam defaultFontColor #cdd6f4
skinparam defaultFontName Helvetica
skinparam ArrowColor #a6adc8
skinparam BoxBorderColor #585b70
skinparam ParticipantBackgroundColor #313244
skinparam ParticipantBorderColor #89b4fa
skinparam NoteBackgroundColor #313244
skinparam NoteBorderColor #f5c2e7

participant "Client" as C
participant "Server" as S
C -> S: request
S --> C: response
@enduml

Kroki Integration

PlantUML in AsciiDoc via Kroki
[plantuml,target=auth-sequence,format=svg]
....
@startuml
Client -> Server: Login
Server --> Client: Token
@enduml
....

CLI Usage

Render locally with PlantUML jar
java -jar plantuml.jar diagram.puml           # PNG output
java -jar plantuml.jar -tsvg diagram.puml     # SVG output
java -jar plantuml.jar -tpdf diagram.puml     # PDF output
Render via Kroki API
curl -s http://localhost:8000/plantuml/svg \
  -H "Content-Type: text/plain" \
  -d '@startuml
A -> B: hello
@enduml' > diagram.svg

See Also