AI Reference
This document is a complete reference for generating Mermaid diagrams that work inside the Apportunity: Mermaid Diagrams app for Confluence and Jira.
Use this document as context when asking an AI assistant (Claude, Gemini, ChatGPT, etc.) to generate diagrams:
Here is the reference: [link to this file]. Create a Mermaid diagram for [your task].
App Overviewβ
The Mermaid Diagrams app is available as two separate Atlassian Marketplace products:
- Apportunity: Mermaid Diagrams Macro for Confluence β insert diagrams as macros on any Confluence page using the Insert (
+) β Mermaid Diagram menu. - Apportunity: Mermaid Diagrams for Jira β view and create diagrams in the Diagrams panel on any Jira Work Item detail view.
Both apps support all 16 diagram types listed in this document. Each diagram is defined entirely as text (Mermaid syntax), with no external tools or image uploads required.
Choosing the Right Diagram Typeβ
Use the table below to match your Atlassian scenario to the best diagram type.
| Scenario | Recommended Diagram |
|---|---|
| Document a process, decision tree, or workflow | flowchart |
| Illustrate API call sequences, authentication flows, or service interactions | sequenceDiagram |
| Plan a sprint, release schedule, or project timeline | gantt |
| Model a codebase's class structure or data schema | classDiagram |
| Document Jira workflow states and transitions | stateDiagram-v2 |
| Model database relationships or data entities | erDiagram |
| Map a user's experience across touchpoints | journey |
| Show percentage breakdown (budget, issues by type, test results) | pie |
| Prioritize initiatives on a 2Γ2 effort/impact matrix | quadrantChart |
| Document system or compliance requirements | requirementDiagram |
| Visualize a Git branching strategy | gitGraph |
| Brainstorm topics or organize knowledge hierarchically | mindmap |
| Show a product or technology history chronologically | timeline |
| Visualize resource or energy flow between categories | sankey-beta |
| Plot bar or line data (KPIs, sprint velocity, metrics) | xychart-beta |
| Lay out system architecture with precise block placement | block-beta |
Diagram Types β Core (Full Reference)β
1. Flowchart (flowchart)β
Best for: Decision trees, process flows, escalation paths, runbooks, onboarding guides.
In Jira: Attach acceptance criteria decision trees, bug triage flows, or escalation processes to a Work Item.
In Confluence: Use in incident response playbooks, process documentation, or onboarding pages.
Syntaxβ
flowchart TD
A[Start] --> B{Is it critical?}
B -->|Yes| C[Escalate to On-Call]
B -->|No| D[Add to Backlog]
C --> E[Create P0 Jira Issue]
D --> F[Triage in Sprint Planning]
Direction options: TD (top-down), LR (left-right), BT (bottom-top), RL (right-left)
Node shapes:
A[Text]β rectangleB(Text)β rounded rectangleC{Text}β diamond (decision)D((Text))β circleE([Text])β stadium / pillF[[Text]]β subroutine
Edge types:
-->β arrow---β open line-->|Label|β labeled arrow-.->β dotted arrow==>β thick arrow
Subgraphs:
flowchart LR
subgraph Team A
A1[Design] --> A2[Build]
end
subgraph Team B
B1[QA] --> B2[Deploy]
end
A2 --> B1
Atlassian Example: Bug escalation processβ
flowchart TD
A[Bug Reported] --> B{Severity?}
B -->|Critical| C[Page On-Call Engineer]
B -->|High| D[Assign to Current Sprint]
B -->|Low| E[Add to Backlog]
C --> F[Create P0 Jira Issue]
D --> G[Assign to Team Lead]
E --> H[Label: needs-triage]
2. Sequence Diagram (sequenceDiagram)β
Best for: API call flows, authentication sequences, microservice interactions, feature design.
In Jira: Attach to feature issues or bug reports to illustrate request/response flows.
In Confluence: Use in technical design documents, API documentation, or architecture decision records (ADRs).
Syntaxβ
sequenceDiagram
participant User
participant Frontend
participant AuthService
participant DB
User->>Frontend: Submit credentials
Frontend->>AuthService: POST /login
AuthService->>DB: Validate user
DB-->>AuthService: User record
AuthService-->>Frontend: JWT token
Frontend-->>User: Redirect to dashboard
Arrow types:
->>β solid arrow (synchronous call)-->>β dashed arrow (return / async response)-)β async message (open arrow)--)β async return
Activation boxes: activate / deactivate
sequenceDiagram
User->>+Server: Request
Server->>+DB: Query
DB-->>-Server: Result
Server-->>-User: Response
Notes:
sequenceDiagram
Note over Alice,Bob: Token expires in 24h
Alice->>Bob: Refresh token
Loop, alt, opt blocks:
sequenceDiagram
loop Every 30s
Client->>Server: Heartbeat
end
alt Token valid
Server-->>Client: 200 OK
else Token expired
Server-->>Client: 401 Unauthorized
end
Atlassian Example: Confluence page creation via APIβ
sequenceDiagram
participant Script as Script Console
participant API as Confluence REST API
participant DB as Confluence Storage
Script->>API: POST /wiki/api/v2/pages
API->>DB: Persist page content
DB-->>API: Page ID
API-->>Script: 200 OK + page object
Script->>Script: console.log(page.id)
3. Gantt Chart (gantt)β
Best for: Sprint planning, release roadmaps, project milestone tracking.
In Confluence: Use in project planning pages, sprint roadmaps, or release schedules.
In Jira: Attach to an Epic or project-level issue to document the planned schedule.
Syntaxβ
gantt
title Q3 Feature Release
dateFormat YYYY-MM-DD
excludes weekends
section Design
UX Research :a1, 2024-07-01, 14d
Wireframes :after a1, 7d
section Development
Backend API :2024-07-15, 21d
Frontend :2024-07-22, 14d
section QA
Testing :2024-08-05, 10d
Bug Fixes :2024-08-15, 7d
Rules:
dateFormatis required β always specify it (YYYY-MM-DDis the most common format).- Task duration: use
Ndfor days,Nwfor weeks,Nhfor hours. - Reference a previous task with
after <taskId>for sequential dependencies. - Mark milestones: append
:milestone,before the date. - Mark tasks as done: prefix with
done,β e.g.,done, a1, 2024-07-01, 14d. - Mark critical tasks: prefix with
crit,.
Atlassian Example: Jira Epic delivery planβ
gantt
title Epic: User Authentication Revamp
dateFormat YYYY-MM-DD
section Discovery
Requirements :done, r1, 2024-06-01, 5d
Tech Design :done, r2, after r1, 5d
section Build
Backend OAuth :b1, 2024-06-14, 10d
Frontend Login UI :b2, after b1, 7d
Token Management :b3, after b1, 5d
section Release
QA & Testing :t1, after b2, 7d
Deploy to Prod :milestone, after t1, 1d
4. Class Diagram (classDiagram)β
Best for: Modeling object-oriented code, database schemas, domain models.
In Confluence: Use in technical design docs, API documentation, or architecture pages.
In Jira: Attach to feature or architecture issues to illustrate data model changes.
Syntaxβ
classDiagram
class User {
+String id
+String email
+String role
+login()
+logout()
}
class Project {
+String id
+String name
+List~Issue~ issues
+addIssue(issue)
}
class Issue {
+String key
+String status
+User assignee
+transition(status)
}
User "1" --> "many" Project : manages
Project "1" *-- "many" Issue : contains
Issue --> User : assigned to
Relationship types:
<|--β inheritance*--β compositiono--β aggregation-->β association..>β dependency..|>β realization
Visibility modifiers: + public, - private, # protected, ~ package
Generic types: List~String~, Map~String, Int~
Atlassian Example: Jira data modelβ
classDiagram
class JiraIssue {
+String key
+String summary
+String status
+String priority
+transition(targetStatus)
}
class JiraUser {
+String accountId
+String displayName
+String email
}
class JiraProject {
+String key
+String name
+List~JiraIssue~ issues
}
JiraProject "1" *-- "many" JiraIssue : contains
JiraIssue --> JiraUser : assigned to
JiraIssue --> JiraUser : reported by
5. State Diagram (stateDiagram-v2)β
Best for: Documenting Jira workflow states and transitions, object lifecycle models (order states, user account states).
In Jira: Document how issues move through workflow states on a project or issue type.
In Confluence: Use in feature specifications, onboarding pages, or technical design documents.
Syntaxβ
stateDiagram-v2
[*] --> ToDo
ToDo --> InProgress : Start work
InProgress --> InReview : Submit for review
InReview --> InProgress : Request changes
InReview --> Done : Approve
Done --> [*]
Composite states (nested):
stateDiagram-v2
[*] --> Active
Active --> Inactive : Suspend
Inactive --> Active : Resume
state Active {
[*] --> Idle
Idle --> Processing : Request received
Processing --> Idle : Done
}
Concurrent states:
stateDiagram-v2
[*] --> Running
state Running {
[*] --> Logging
--
[*] --> Monitoring
}
Notes:
stateDiagram-v2
Pending --> Approved : Manager approves
note right of Approved
Triggers Jira transition
to Done status
end note
Atlassian Example: Jira Service Management ticket lifecycleβ
stateDiagram-v2
[*] --> New
New --> InProgress : Agent picks up
InProgress --> Pending : Waiting on customer
Pending --> InProgress : Customer responds
InProgress --> Resolved : Issue fixed
Resolved --> Closed : Auto-close after 5 days
Resolved --> Reopened : Customer rejects resolution
Reopened --> InProgress : Agent reassigned
Closed --> [*]
Diagram Types β Additionalβ
These diagram types are supported by the app. Use the keyword and minimal example below to prompt AI for diagrams of this type.
Entity Relationship Diagram (erDiagram)β
Cardinality syntax: ||--o{ (one-to-many optional), ||--|{ (one-to-many required), }|..|{ (many-to-many).
erDiagram
CUSTOMER ||--o{ ORDER : places
ORDER ||--|{ LINE-ITEM : contains
CUSTOMER }|..|{ DELIVERY-ADDRESS : uses
Use when: Designing or documenting database schemas, API data models, or domain entities.
User Journey (journey)β
Rate steps from 1 (painful) to 5 (delightful). Multiple actors per step are allowed.
journey
title User onboarding flow
section Sign Up
Visit landing page : 5: User
Complete form : 3: User
Verify email : 2: User
section First Login
Dashboard tour : 4: User, Support
Create first item : 4: User
Use when: Mapping customer or user experience steps, identifying friction points in a product flow.
Pie Chart (pie)β
pie title Issues by Type
"Bug" : 42
"Story" : 35
"Task" : 18
"Epic" : 5
Use when: Showing proportions β sprint issue breakdown, test pass/fail ratio, budget allocation.
Quadrant Chart (quadrantChart)β
Points are placed at [x, y] coordinates between 0.0 and 1.0.
quadrantChart
title Feature Prioritization
x-axis Low Effort --> High Effort
y-axis Low Value --> High Value
quadrant-1 Quick wins
quadrant-2 Major projects
quadrant-3 Fill-ins
quadrant-4 Thankless tasks
Feature A: [0.2, 0.8]
Feature B: [0.7, 0.9]
Feature C: [0.8, 0.3]
Use when: Prioritizing features, risks, or campaigns on a 2Γ2 matrix.
Requirement Diagram (requirementDiagram)β
requirementDiagram
requirement auth_req {
id: REQ-01
text: The system must support SSO via SAML 2.0.
risk: high
verifymethod: test
}
element auth_module {
type: component
}
auth_module - satisfies -> auth_req
Use when: Documenting system, compliance, or product requirements and their traceability.
Gitgraph Diagram (gitGraph)β
gitGraph
commit tag: "v1.0"
branch develop
checkout develop
commit
branch feature/login
checkout feature/login
commit
commit
checkout develop
merge feature/login
checkout main
merge develop tag: "v1.1"
Use when: Explaining Git branching strategies (Git Flow, trunk-based development) in engineering wikis or Confluence ADRs.
Mindmap (mindmap)β
Indentation defines hierarchy. Use root((...)) for the central node.
mindmap
root((Sprint Goal))
Authentication
SSO Integration
MFA Setup
Performance
DB Query Optimization
Caching Layer
Docs
API Reference
Onboarding Guide
Use when: Brainstorming sprint themes, organizing knowledge, or mapping product areas.
Timeline (timeline)β
timeline
title Product Launch History
2022 : MVP Released
2023 : Mobile App
: API v2
2024 : Enterprise Tier
2025 : AI Features
Use when: Showing product history, roadmap milestones, or technology adoption over time.
Sankey Diagram (sankey-beta)β
Format: Source,Destination,Value (one flow per line, comma-separated, no header row).
sankey-beta
Budget,Engineering,500
Budget,Design,150
Budget,Marketing,200
Engineering,Backend,300
Engineering,Frontend,200
Use when: Visualizing resource allocation, data flow, or energy/cost distribution between categories.
XY Chart (xychart-beta)β
xychart-beta
title "Sprint Velocity"
x-axis [S1, S2, S3, S4, S5, S6]
y-axis "Story Points" 0 --> 60
bar [32, 41, 38, 55, 49, 52]
line [32, 41, 38, 55, 49, 52]
Use when: Plotting time-series or categorical data β KPIs, sprint velocity, test coverage trends.
Block Diagram (block-beta)β
Use columns N to define layout width. Useful when automatic flowchart layout produces unwanted placement.
block-beta
columns 3
Frontend["Web App"]
API["REST API"]
DB[("Database")]
Frontend --> API
API --> DB
Use when: Visualizing system architecture where you need precise control over block placement.
Themingβ
Apply a theme using the %%{init}%% directive as the first line of the diagram. This directive is case-sensitive.
Built-in Themesβ
| Theme | Best for |
|---|---|
default | Light-mode Confluence pages |
dark | Dark-mode pages or high-contrast |
forest | Green-accented, nature themes |
neutral | Subtle grayscale, formal docs |
base | Fully customizable baseline |
%%{init: {'theme': 'dark'}}%%
flowchart TD
A[Deploy] --> B[Verify] --> C[Done]
Custom Colorsβ
Use base theme with themeVariables to override individual colors:
%%{init: {'theme': 'base', 'themeVariables': {'primaryColor': '#0052CC', 'primaryTextColor': '#ffffff', 'lineColor': '#172b4d'}}}%%
flowchart LR
A[Jira Issue] --> B[In Review] --> C[Done]
Common themeVariables:
| Variable | Controls |
|---|---|
primaryColor | Node fill color |
primaryTextColor | Text inside nodes |
primaryBorderColor | Node border color |
lineColor | Arrow and edge color |
secondaryColor | Secondary node fill |
tertiaryColor | Subgraph background |
background | Diagram background |
Rules for Generating Good Diagramsβ
-
Output raw Mermaid syntax only. Do not wrap the output in extra prose unless asked. The user pastes the code block directly into the app's editor.
-
No HTML in node labels. The app disables
htmlLabelsfor security. Use plain text inside node labels β no<b>,<br>, or other HTML tags. Use\nfor line breaks where supported. -
No
%%{securityLevel}%%directive. This is ignored by the app. Do not include it. -
Prefer shorter labels. Long labels in nodes make diagrams hard to read. Break content into multiple nodes rather than putting everything in one label.
-
Split large diagrams. Diagrams with hundreds of nodes can render slowly or fail. Suggest breaking complex systems into multiple focused diagrams.
-
Always specify
dateFormatin Gantt charts. Without it the chart will not render.YYYY-MM-DDis the safest choice. -
Use
stateDiagram-v2, notstateDiagram. The v2 variant is the current standard and has better layout support. -
Use
flowchartovergraph. Both work, butflowchartis the current standard keyword with full feature support. -
Validate syntax before providing. Common failure causes: missing closing brackets
]or}, wrong indentation inmindmaportimeline, mismatched subgraphend, or unsupported newer Mermaid features not yet in the app version. -
Use the
%%{init}%%directive only when theming is requested. It adds visual noise when unnecessary. Default rendering already uses a clean theme matching the Atlassian UI.