← Back to Education
Education digital-technologies year-9

Algorithm Flowcharts with Mermaid

A practical guide to mapping program logic with Mermaid before translating it into code.

Published Updated Type guide

Use Mermaid to sketch decision logic before coding. A clear flowchart reduces guessing and makes Python conditions easier to implement.

Quick Workflow

  1. define the program goal in one sentence
  2. list inputs and expected outputs
  3. map decision points (if/elif/else) as branches
  4. check every decision has a path for invalid input
  5. translate each branch into Python code

Mermaid Starter Template

flowchart TD
  A[Start] --> B[Collect Input]
  B --> C{Valid?}
  C -->|Yes| D[Process]
  C -->|No| E[Show Error]
  E --> B
  D --> F[Output Result]
  F --> G[End]

🧠 Mermaid.live – Building an Algorithm flow chart

Mermaid turns diagram code into a flowchart. You write the structure. Mermaid builds the shapes.

🚀 Step 1: Open Mermaid.live

https://mermaid.live

Left = code editor
Right = diagram preview

🎯 What this example models

This example shows how a while loop works:

  1. Start
  2. Ask for a number
  3. Check if number is < 5
  4. If yes → add 1 and repeat
  5. If no → end

The arrow that goes back to the decision creates repetition.

🔷 Shape Guide

([ ]) → Start / End
[ ] → Process
{ } → Decision
[/ /] → Input / Output

🖼 Example Flow chart

Mermaid Live Example Diagram

Notice how the decision has two labelled paths and one returns back to repeat.

⌨ Step 2: Paste This Code

Show/Hide Mermaid Code
flowchart TD
    A([Start]) --> B[/Enter a number/]
    B --> C{Is number < 5?}
    C -- Yes --> D[Add 1 to number]
    D --> C
    C -- No --> E([End])
Checkpoint: Your diagram should show a loop returning to the decision box.

🛠 Assessment Practice Challenge – Booking Validation

Now design your own algorithm flow chart. 

Create a flowchart for a booking system that:

• Asks for the user’s name
• Asks what type of pet they have (cat or dog)
• Repeats the question if the input is invalid
• Assigns a price based on the pet type
• Displays a confirmation message
• Ends
Think carefully:
Where is the loop?
What controls it?
Where is the price set?
Are all decision paths labelled?