Diagrams

See the Mermaid Documentation for more examples.

Graph

1```mermaid
2graph TD;
3    A-->B;
4    A-->C;
5    B-->D;
6    C-->D;
7```
graph TD;
    A-->B;
    A-->C;
    B-->D;
    C-->D;

State

 1```mermaid
 2---
 3title: Simple sample
 4---
 5stateDiagram-v2
 6    [*] --> Still
 7    Still --> [*]
 8
 9    Still --> Moving
10    Moving --> Still
11    Moving --> Crash
12    Crash --> [*]
13```
---
title: Simple sample
---
stateDiagram-v2
    [*] --> Still
    Still --> [*]

    Still --> Moving
    Moving --> Still
    Moving --> Crash
    Crash --> [*]

FlowChart

 1```mermaid
 2flowchart LR
 3  subgraph TOP
 4    direction TB
 5    subgraph B1
 6        direction RL
 7        i1 -->f1
 8    end
 9    subgraph B2
10        direction BT
11        i2 -->f2
12    end
13  end
14  A --> TOP --> B
15  B1 --> B2
16
17```
flowchart LR
  subgraph TOP
    direction TB
    subgraph B1
        direction RL
        i1 -->f1
    end
    subgraph B2
        direction BT
        i2 -->f2
    end
  end
  A --> TOP --> B
  B1 --> B2

Entity Relationship

 1```mermaid
 2---
 3title: Order example
 4---
 5erDiagram
 6    CUSTOMER ||--o{ ORDER : places
 7    ORDER ||--|{ LINE-ITEM : contains
 8    CUSTOMER }|..|{ DELIVERY-ADDRESS : uses
 9
10```
---
title: Order example
---
erDiagram
    CUSTOMER ||--o{ ORDER : places
    ORDER ||--|{ LINE-ITEM : contains
    CUSTOMER }|..|{ DELIVERY-ADDRESS : uses

Sequence

1```mermaid
2sequenceDiagram
3    participant A as Alice
4    participant J as John
5    A->>J: Hello John, how are you?
6    J->>A: Great!
7```
sequenceDiagram
    participant A as Alice
    participant J as John
    A->>J: Hello John, how are you?
    J->>A: Great!

Class

 1```mermaid
 2---
 3title: Animal example
 4---
 5classDiagram
 6    note "From Duck till Zebra"
 7    Animal <|-- Duck
 8    note for Duck "can fly\ncan swim\ncan dive\ncan help in debugging"
 9    Animal <|-- Fish
10    Animal <|-- Zebra
11    Animal : +int age
12    Animal : +String gender
13    Animal: +isMammal()
14    Animal: +mate()
15    class Duck{
16        +String beakColor
17        +swim()
18        +quack()
19    }
20    class Fish{
21        -int sizeInFeet
22        -canEat()
23    }
24    class Zebra{
25        +bool is_wild
26        +run()
27    }
28```
---
title: Animal example
---
classDiagram
    note "From Duck till Zebra"
    Animal <|-- Duck
    note for Duck "can fly\ncan swim\ncan dive\ncan help in debugging"
    Animal <|-- Fish
    Animal <|-- Zebra
    Animal : +int age
    Animal : +String gender
    Animal: +isMammal()
    Animal: +mate()
    class Duck{
        +String beakColor
        +swim()
        +quack()
    }
    class Fish{
        -int sizeInFeet
        -canEat()
    }
    class Zebra{
        +bool is_wild
        +run()
    }