Mermaid.js rendering for Choreo.ThreatModel graphs.
Produces security-oriented visualization:
- External entities — thick-bordered rectangles
- Processes — circles
- Data stores — cylinders
- Trust boundaries — subgraphs grouping security elements
- Cross-boundary flows — styled with high-scrutiny colors (red/orange)
- Unencrypted flows crossing boundaries — styled as red dashed links
Layout is left-to-right (LR) by default so data flows horizontally.
Summary
Functions
Renders a threat model to a Mermaid flowchart string.
Renders the data flows in a threat model to a Mermaid sequence diagram string.
Functions
@spec to_mermaid( Choreo.ThreatModel.t(), keyword() ) :: String.t()
Renders a threat model to a Mermaid flowchart string.
Options
:theme—:default,:dark,:warm,:forest,:ocean, or aChoreo.Themestruct:direction—:lr(default),:td,:rl,:bt:highlighted_nodes— list of node IDs to highlight:highlighted_edges— list of edge IDs/tuples to highlight
Examples
iex> model = Choreo.ThreatModel.new()
iex> model = model
...> |> Choreo.ThreatModel.add_external_entity(:user, label: "User")
...> |> Choreo.ThreatModel.add_process(:api, label: "API")
...> |> Choreo.ThreatModel.data_flow(:user, :api, label: "HTTPS")
iex> mermaid = Choreo.ThreatModel.Render.Mermaid.to_mermaid(model)
iex> String.contains?(mermaid, "graph LR")
true
iex> String.contains?(mermaid, "User")
true
iex> String.contains?(mermaid, "API")
true
@spec to_sequence( Choreo.ThreatModel.t(), keyword() ) :: String.t()
Renders the data flows in a threat model to a Mermaid sequence diagram string.
Examples
iex> model = Choreo.ThreatModel.new()
iex> model = Choreo.ThreatModel.add_external_entity(model, :user, label: "Customer")
iex> model = Choreo.ThreatModel.add_process(model, :web_api, label: "Web API")
iex> model = Choreo.ThreatModel.data_flow(model, :user, :web_api, label: "HTTPS login")
iex> Choreo.ThreatModel.Render.Mermaid.to_sequence(model)
"sequenceDiagram\n actor user as Customer\n participant web_api as Web API\n user->>web_api: HTTPS login\n"