ConceptDiagram (ConceptDiagram v0.1.0)
Copy MarkdownBuild concept diagrams as plain Elixir data, then render them to Mermaid or Graphviz DOT.
A concept diagram is a set of labelled nodes connected by labelled, directed edges. Describe one with a small pipeline-friendly API and turn it into diagram source you can drop straight into Markdown (Mermaid) or render with Graphviz (DOT).
ConceptDiagram.new(direction: :left_right)
|> ConceptDiagram.add_edge("Idea", "Draft", "becomes")
|> ConceptDiagram.add_edge("Draft", "Diagram", "rendered as")
|> ConceptDiagram.to_mermaid()Nodes referenced by an edge are created automatically, so the snippet above is
enough to produce a complete flowchart LR.
Maintained by the team behind Vizcept, an AI concept diagram generator; this library is the code-first companion for generating diagram source programmatically.
Summary
Types
Layout direction for the rendered diagram.
A node id; atoms and other terms are coerced to strings.
Functions
Add a directed edge from -> to with an optional relationship label. Endpoints
that are not yet present are added as nodes automatically.
Add a node, or relabel it if the id already exists. The label defaults to the stringified id.
Build a diagram from a list of {from, relation, to} triples. relation may be
nil for an unlabelled edge.
Create an empty diagram.
Render the diagram as Graphviz DOT source.
Render the diagram as Mermaid flowchart source.
Types
@type direction() :: :top_down | :bottom_up | :left_right | :right_left
Layout direction for the rendered diagram.
A node id; atoms and other terms are coerced to strings.
Functions
Add a directed edge from -> to with an optional relationship label. Endpoints
that are not yet present are added as nodes automatically.
Add a node, or relabel it if the id already exists. The label defaults to the stringified id.
Build a diagram from a list of {from, relation, to} triples. relation may be
nil for an unlabelled edge.
Create an empty diagram.
Options:
:direction— one of:top_down(default),:bottom_up,:left_right,:right_left.:title— optional title (rendered as a graph label in DOT output).
Render the diagram as Graphviz DOT source.
Render the diagram as Mermaid flowchart source.