PlantUML Cheat Sheet

PlantUML is a tool that allows you to create UML diagrams using a simple and human-readable syntax. Here’s a PlantUML cheat sheet covering some common diagram types and syntax:

Class Diagram

Class Declaration:

class ClassName {
  +publicMethod()
  -privateMethod()
  #protectedMethod()
  ~packagePrivateMethod()
  +field: Type
}

Inheritance:

class ChildClass extends ParentClass

Interface:

interface MyInterface

Association:

class Class1 {
  ---> Class2
}

Activity Diagram

Basic Activity:

start
:First activity;
:Second activity;
:Third activity;
stop

Decision (if-else):

start
if (condition) then (true)
  :True path;
else (false)
  :False path;
endif
stop

Sequence Diagram

Actor and Lifeline:

actor User
participant "System" as System
User -> System: Request

Message Passing:

User -> System: Request
System -> User: Response

Activation Bar:

User -> System: Request
activate System
System -> User: Response
deactivate System

Use Case Diagram

Use Case:

usecase MyUseCase {
  - Main Scenario
  - Alternative Scenario 1
  - Alternative Scenario 2
}

Actor and Association:

actor ActorName
ActorName --> MyUseCase

Component Diagram

Component Declaration:

component MyComponent {
  +publicMethod()
  -privateMethod()
}

Dependency:

MyComponent --> AnotherComponent

Artifact:

artifact MyArtifact

State Diagram

State and Transition:

state "State 1" {
  [*] --> State1
  State1 --> State2 : Transition
  State2 --> State1 : Transition
}

Package Diagram

Package Declaration:

package MyPackage {
  class Class1
  class Class2
}

Dependency:

package Package1 --> Package2

This is a basic PlantUML cheat sheet covering some common diagram types and syntax.