Online Shop Use Case Diagram

Before anyone designs classes or services, the team should agree on what the system is for. A UML use case diagram lists the people and outside systems that use the shop (actors) and the goals each of them can reach (use cases), inside a box that marks the system boundary.

It is the one-page scope statement of the project.


1. The Diagram

Online shop: actors and goals Online Shop Browse catalog Search products Manage cart Place order Track order Request refund Manage products Process refund View sales reports Apply discount code Pay for order Log in Customer Admin Payment provider «include» «include» «include» «extend»
  1. Three actors sit outside the boundary: Customer and Admin are people; the Payment provider is another system, drawn on the right because it takes part but does not start these goals.
  2. The customer has six goals, from Browse catalog to Request refund. A plain line means the actor takes part in that use case.
  3. Place order (highlighted) includes Pay for order and Log in: every order always pays and always needs a signed-in user. The dashed arrow points from the base case to the included one.
  4. Track order includes Log in too, so the shared step is written once.
  5. Apply discount code extends Place order: it only happens sometimes. The extend arrow points the other way, from the optional case to the base.
  6. The admin manages products, processes refunds (which also involves the payment provider) and views sales reports.

2. How to Read It

Notation used Actor Use case goal the actor reaches association: actor takes part «include» base always runs the included case «extend» optional add-on, arrow points to base generalization (specialised actor) System boundary

Use case names are short verb phrases written from the actor's point of view. Each ellipse is backed by a written description: preconditions, main steps and alternative flows. The diagram is the index; the text holds the detail.

3. Variant: Actor Generalization and Extension Points

Variant: guests and extension points Online Shop Guest Registered customer Browse catalog Place order extension points: discount code Apply discount code «extend» condition: {code entered} extension point: discount code

A Registered customer can do everything a Guest can, plus place orders; the hollow triangle says the registered customer is a kind of guest and inherits its use cases. The Place order ellipse also names its extension point, and a note gives the condition under which the extension runs.

4. Pros and Cons

Pros

Cons

5. When to Use It

Use it when

Skip it when

6. As Diagrams-as-Code

The main diagram written for PlantUML:

@startuml
left to right direction
actor Customer
actor Admin
actor "Payment provider" as PSP <<system>>
rectangle "Online Shop" {
  usecase "Browse catalog" as UC1
  usecase "Search products" as UC2
  usecase "Manage cart" as UC3
  usecase "Place order" as UC4
  usecase "Track order" as UC5
  usecase "Request refund" as UC6
  usecase "Apply discount code" as UC7
  usecase "Pay for order" as UC8
  usecase "Log in" as UC9
  usecase "Manage products" as UC10
  usecase "Process refund" as UC11
  usecase "View sales reports" as UC12
}
Customer -- UC1
Customer -- UC2
Customer -- UC3
Customer -- UC4
Customer -- UC5
Customer -- UC6
Admin -- UC10
Admin -- UC11
Admin -- UC12
UC8 -- PSP
UC11 -- PSP
UC4 ..> UC8 : <<include>>
UC4 ..> UC9 : <<include>>
UC5 ..> UC9 : <<include>>
UC7 ..> UC4 : <<extend>>
@enduml

left to right direction puts actors on the sides. Mermaid has no use case diagram type, so PlantUML is the usual text choice.