Activity Diagram

The UML picture of a process: the steps, the decisions, and the work that runs in parallel. It is a flowchart with exact rules for branching and for doing two things at once.

Overview

An activity diagram shows a process from start to finish: what happens, in what order, where it branches, and where several things happen at the same time. It does not care which object performs each step unless you add swimlanes. Where a sequence diagram asks 'who talks to whom', an activity diagram asks 'what happens next'.

The notation is in clause 15 of UML 2.5.1. A solid circle starts the flow. Rounded rectangles are actions. A diamond either splits the flow on a condition (a decision) or brings alternative paths back together (a merge). A thick bar either splits the flow into parallel paths (a fork) or waits for them all to finish (a join). A solid circle inside a hollow circle ends the whole activity.

In an interview, reach for this diagram when the prompt is a workflow: an order from placement to delivery, a job pipeline, a registration with email verification. It makes the decisions and the parallel work visible, which is where the design questions about failure, retries and timing live.

The symbols

Each symbol has one shape, one meaning and one rule that keeps the diagram honest.

  • Initial node: a solid circle where the flow starts. One token starts on it.
  • Action: a rounded rectangle for one step of work, named with a verb phrase such as 'Validate order'.
  • Decision: a diamond with one way in and several out. It chooses one outgoing path, and every outgoing edge has a guard in brackets.
  • Merge: a diamond with several ways in and one out, where alternative paths rejoin. It does no waiting.
  • Fork: a thick bar with one way in and several out. It starts parallel paths, and all of them run.
  • Join: a thick bar with several ways in and one out. It waits for all parallel paths and continues only when every path has arrived.
  • Activity final: a solid circle inside a hollow circle. The whole activity ends, and every remaining path stops.
  • Flow final: a circle with an X. One path ends, and the other paths continue.
  • Swimlane (partition): a column or row with a name, saying who or what performs the actions inside it. Each lane has one owner.

Interview questions

  • What is the difference between a decision node and a fork node?
  • How do you model parallel execution, and what does it look like in code?
  • When should you use an activity diagram in an interview?
  • How do you show error handling and retries in an activity diagram?
  • How do swimlanes help, and how do they connect to the class or service design?

Sign up free to read the full topic

More Low-Level Design topics

Start free on Cariara · Coding problems · System design studio