Search Knowledge

© 2026 LIBREUNI PROJECT

UML Design / Behavioral Modeling

Sequence Diagrams

Sequence Diagrams

Sequence diagrams are interaction diagrams that show how objects operate with one another and in what order. They are time-centric, showing the chronological sequence of messages.

1. Key Components

  • Lifelines: Represented by vertical dashed lines. They represent the existence of an object over time.
  • Activations/Execution Bars: Thin rectangles on the lifeline showing when an object is actively processing a request.
  • Actors: Stick figures representing external entities (users, other systems).

2. Message Types

The arrow heads matter significantly:

SymbolMessage TypeDescription
->SynchronousCaller waits for a response before continuing. (Full arrowhead)
->>AsynchronousCaller continues without waiting for response. (Open arrowhead)
-->ReturnResponse sent back to the caller. (Dashed line)
-> (to self)Self-MessageA method call within the same object.

3. Combined Fragments (Logic Control)

Sequence diagrams use “fragments” to handle logic:

  • alt (Alternative): If/else logic. Only one branch executes.
  • opt (Optional): If then. Executes only if condition is true.
  • loop (Iteration): Repeats a sequence of messages.
  • par (Parallel): Messages that happen concurrently.

4. Detailed Example

PlantUML Code:

actor User
participant "Web UI" as UI
participant "Auth Service" as Auth
database DB

User -> UI: Enter Credentials
UI -> Auth: login(user, pass)
activate Auth
  Auth -> DB: findUser(user)
  activate DB
    DB --> Auth: userPayload
  deactivate DB
  
  alt ##90EE90 credentials valid
    Auth --> UI: token
    UI --> User: Dashboard
  else #Pink invalid
    Auth --> UI: error 401
    UI --> User: Show error message
  end
deactivate Auth
Code
actor User
participant "Web UI" as UI
participant "Auth Service" as Auth
database DB

User -> UI: Enter Credentials
UI -> Auth: login(user, pass)
activate Auth
Auth -> DB: findUser(user)
activate DB
  DB --> Auth: userPayload
deactivate DB

alt ##90EE90 credentials valid
  Auth --> UI: token
  UI --> User: Dashboard
else #Pink invalid
  Auth --> UI: error 401
  UI --> User: Show error message
end
deactivate Auth
Auth ServiceDBUserWeb UIAuth ServiceDBUserUserWeb UIWeb UIAuth ServiceAuth ServiceDBDBAuth ServiceDBEnter Credentialslogin(user, pass)findUser(user)userPayloadalt[##90EE90 credentials valid]tokenDashboard[invalid]error 401Show error message

In a sequence diagram, what does a dashed arrow (-->) usually represent?

Previous Module Modeling with PlantUML