Flowchart diagrams
Overview
Flowchart diagrams in Sirena represent directed graphs showing process flows, decision trees, and relationships between nodes. Flowcharts are one of the most versatile diagram types, supporting various node shapes, edge types, and layout directions.
Flowcharts are useful for:
-
Documenting business processes and workflows
-
Visualizing algorithms and decision logic
-
Creating system architecture diagrams
-
Showing data flow between components
-
Mapping user interaction flows
Syntax specification
Diagram declaration
Flowcharts can be declared using either graph or flowchart keywords:
graph <direction>
<diagram-content>
Or:
flowchart <direction>
<diagram-content>
Where <direction> specifies the layout direction:
-
TDorTB- Top to bottom (default) -
BT- Bottom to top -
LR- Left to right -
RL- Right to left
Node definitions
Nodes can be defined with various shapes using different bracket styles:
| Syntax | Shape | Description |
|---|---|---|
|
Rectangle |
Standard rectangular node |
|
Rounded rectangle |
Rectangle with rounded corners |
|
Stadium |
Pill-shaped node |
Subroutine |
Rectangle with double vertical lines |
|
|
Cylindrical |
Database or storage shape |
|
Circle |
Circular node |
|
Asymmetric |
Flag or banner shape |
|
Diamond |
Decision or conditional node |
|
Hexagon |
Process or preparation node |
|
Parallelogram |
Input/output operation |
|
Parallelogram (alt) |
Alternative input/output syntax |
|
Trapezoid |
Manual operation |
|
Trapezoid (inverted) |
Inverted manual operation |
Edge definitions
Edges connect nodes and can have different styles:
| Syntax | Style | Description |
|---|---|---|
|
Arrow |
Solid line with arrowhead |
|
Open link |
Solid line without arrowhead |
|
Dotted arrow |
Dotted line with arrowhead |
|
Dotted link |
Dotted line without arrowhead |
|
Thick arrow |
Thick solid line with arrowhead |
|
Thick link |
Thick solid line without arrowhead |
|
Circle edge |
Line ending with a circle |
|
Cross edge |
Line ending with a cross |
|
Bidirectional arrow |
Arrow pointing both ways |
|
Bidirectional circle |
Circles on both ends |
|
Bidirectional cross |
Crosses on both ends |
Examples
Basic flowchart
graph TD
Start --> End
This creates a simple flowchart with two rectangular nodes connected by an arrow.
Flowchart with different node shapes
graph TD
Start[Start Process] --> Input[Receive Input]
Input --> Validate{Valid Input?}
Validate -->|Yes| Process[Process Data]
Validate -->|No| Error[Show Error]
Error --> Input
Process --> End[End Process]
This example demonstrates:
-
Rectangle nodes for process steps
-
Diamond node for decision points
-
Labeled edges showing decision outcomes
-
Loop back from error to input
Complex workflow with subgraphs and multiple shapes
graph TD
Start[Start Process] --> Input[Receive Input]
Input --> Validate{Valid Input?}
Validate -->|Yes| Process[Process Data]
Validate -->|No| Error[Show Error]
Error --> Input
Process --> Calculate[Calculate Result]
Calculate --> Output[Generate Output]
Output --> Save{Save to Database?}
Save -->|Yes| DB[(Database)]
Save -->|No| Display[Display Result]
DB --> Display
Display --> End[End Process]
This example shows:
-
Multiple decision points (diamond nodes)
-
Database node using cylindrical shape
[(Database)] -
Branching and merging flows
-
Conditional paths with labels
Left-to-right flowchart
graph LR
A[Client] --> B[Load Balancer]
B --> C[Server 1]
B --> D[Server 2]
B --> E[Server 3]
C --> F[(Database)]
D --> F
E --> F
This demonstrates:
-
Left-to-right layout using
LRdirection -
Multiple parallel paths from one node
-
Convergence of multiple paths to a single node
-
Database representation
Flowchart with various edge styles
graph TD
A[Start] --> B[Process]
B -.-> C[Optional Step]
C ==> D[Important Step]
D --> E{Decision}
E -->|Yes| F[Action 1]
E -->|No| G[Action 2]
F --> H[End]
G --> H
This shows:
-
Solid arrow for normal flow
-
Dotted arrow for optional or conditional flow
-
Thick arrow for emphasized flow
-
Labeled decision branches
Subgraph example
graph TB
A[Start] --> B[Authenticate]
subgraph Authentication
B --> C{Valid Credentials?}
C -->|Yes| D[Grant Access]
C -->|No| E[Deny Access]
end
D --> F[Main Application]
E --> G[Login Screen]
G --> B
F --> H[End]
This demonstrates:
-
Grouping related nodes in a subgraph
-
Connections between nodes inside and outside subgraphs
-
Clear visual organization of workflow sections
Features
Node identifiers
Node identifiers can contain letters, numbers, and underscores:
graph TD
node_1[First Node]
node_2[Second Node]
node_1 --> node_2
Multi-word labels
Labels can contain spaces and special characters:
graph TD
A[This is a multi-word label!]
B[Special chars: @#$%]
A --> B
Long text in nodes
Text in nodes automatically wraps:
graph TD
A[This is a very long text that will be wrapped automatically to fit within the node boundaries]
Limitations
Best practices
Keep it simple
Avoid creating overly complex diagrams. If a flowchart becomes too large:
-
Split into multiple diagrams
-
Use subgraphs to organize related sections
-
Consider using different diagram types for different aspects
Use meaningful labels
Use clear, descriptive labels for nodes and edges:
graph TD
%% Good
ValidateInput{Input Valid?} -->|Yes| ProcessData[Process Data]
%% Less clear
A{?} --> B