State Machine Diagram
A state machine diagram models the different states an object can be in and the events that trigger transitions between them. Developers use it to design order systems, workflows, or any entity with a defined lifecycle. Tip: mark the initial and final states clearly so the diagram's boundaries are unambiguous.
The prompt behind this diagram
Create a UML state machine diagram for an order lifecycle. Include states Created, Pending Payment, Paid, Processing, Shipped, Delivered, and Cancelled. Show transitions: Created to Pending Payment on submit order, Pending Payment to Paid on payment confirmed, Paid to Processing on inventory reserved, Processing to Shipped on package dispatched, Shipped to Delivered on delivery confirmed, and Cancelled reachable from Created, Pending Payment, and Processing on cancel request. Include an initial state marker and a final state marker.
Paste your own description (or Terraform / docker-compose / SQL schema) into draft1 and get a diagram like this for your exact system.
What this diagram shows
A state machine diagram illustrates how an entity progresses through a finite set of discrete states based on triggering events or conditions. It maps all possible states an object can occupy and the transitions between them, each triggered by specific events, guards, or actions. The diagram shows the flow from an initial state through intermediate states to one or more final states, making explicit the legal pathways and impossible transitions. This representation clarifies behaviour that would be difficult to express in prose or pseudocode, especially when multiple conditions govern state changes.
Key components
- Initial State — The starting point where the entity begins, represented as a filled circle with an arrow pointing to the first active state.
- State — A named condition or mode the entity occupies, drawn as a rounded rectangle, where the system remains until an event triggers a transition.
- Transition — A directed arrow connecting two states, labelled with the event, guard condition, and optional action that causes the state change.
- Event — A trigger such as a user action, signal, or message that initiates a potential state transition when conditions allow.
- Guard Condition — A boolean expression enclosed in square brackets that must evaluate to true for a transition to fire, even if its event occurs.
- Action — An optional operation executed during a transition, written after a forward slash on the transition label to represent side effects.
- Final State — An end state represented as a filled circle inside a larger circle, indicating termination or completion of the state machine's execution.
When to use it
Use a state machine diagram when you need to specify behaviour that depends on the current state and cannot be expressed with simple sequential flow. It is essential for modelling workflow states (draft, submitted, approved, published), device operation modes (idle, processing, error), game entities with distinct behaviours, authentication flows, or any system where illegal state transitions must be prevented. This diagram becomes particularly valuable when documenting complex user interactions or protocol requirements where the order and conditions of state changes are critical to correctness.
Common mistakes
- Omitting guard conditions or showing all transitions as equally valid, which masks the actual constraints and makes the diagram less useful for implementation or validation.
- Creating states at inconsistent levels of abstraction, mixing high-level phases (payment processing) with low-level technical states (network retry), which obscures the real control logic.
- Forgetting to mark the initial and final states explicitly, forcing readers to infer entry and exit points instead of making the state machine's scope unambiguous.
Adapting it to your system
Replace the generic state names with the actual states relevant to your domain: for order processing, use states like pending, payment authorized, packed, shipped, delivered. Name events after real triggers: submit order, payment received, inventory depleted. Specify guard conditions based on actual business rules, such as [quantity in stock] or [user has admin role]. Add actions that reflect what your system must do, such as send email notification or update database. Ensure transitions cover all realistic pathways but explicitly exclude impossible or forbidden transitions to make the diagram a true specification of legal behaviour.
More templates
System Architecture Diagram
Generate a clear system architecture diagram online and export an editable draw.io file in seconds with AI.
Network Topology Diagram
Draw a network topology diagram instantly with AI and download it as an editable draw.io file for your documentation.
Aktivitätsdiagramm Für Eine Java-Methode Erstellen
Erstellen Sie ein UML-Aktivitätsdiagramm für Java-Methoden mit KI und exportieren Sie es als editierbare draw.io-Datei
Diagram Przypadków Użycia UML
Wygeneruj diagram przypadków użycia UML online za pomocą AI i pobierz edytowalny plik draw.io.
Cloud Architecture Diagram
Create a cloud architecture diagram with AI and export it instantly as an editable draw.io file.
Cloud Infrastructure Diagram
Generate a detailed cloud infrastructure diagram online using AI and export it as an editable draw.io diagram.
Business Process Flowchart With Decision Points
Build a business process flowchart with decision points using AI and download an editable draw.io file.