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

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

A food delivery order, drawn

Mermaid has no activity diagram type, so the picture below is a flowchart in the same shape. The forks and joins are drawn as yellow boxes where UML would draw bars, the start is a small circle (UML fills it solid), the end is a double circle, and the swimlanes are subgraphs.

Decision versus fork, merge versus join

These two pairs look alike and are the most common mistake. A diamond is about choice; a bar is about parallelism.

  • Paths taken — exactly one — all of them
  • Labels — a guard on each edge: [yes], [amount > 100] — none
  • Question it answers — which way? — what can happen at the same time?
  • Waits? — no; continues as soon as any path arrives — yes; continues only when every path has arrived
  • Pairs with — a decision — a fork
  • Mistake it prevents — none — handing food to a courier who has not arrived

Swimlanes

A swimlane, which UML calls an activity partition, groups actions by who performs them: a role, a team, a system. Lanes turn a process diagram into a responsibility map and are the bridge to a class or service design, because each lane tends to become a component.

  • Customer — place order, receive notification — the app and its API
  • Order system — validate, take payment, fork, join — OrderService, PaymentService
  • Restaurant — accept, prepare food — a kitchen display and RestaurantService
  • Dispatch — assign courier, track travel — DispatchService

Activity, sequence and state: which to draw

  • the steps and decisions of a process, with parallel work — activity diagram
  • which objects exchange which messages, in order — sequence diagram
  • the states one object can be in and what moves it — state machine diagram

What you will be able to do

  • Draw a process with the right symbol for start, action, decision, merge, fork, join and end.
  • Explain the difference between a decision and a fork, and between a merge and a join.
  • Use swimlanes to show who owns each step and to find the components of a design.
  • Turn a fork and join into code that really runs the two branches at the same time.

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