Assisted generation turns text into a diagram. The framework ships a deterministic, offline assistant and a provider-agnostic contract so a cloud or local model can be plugged in without changing the editor.

Provider Contract

public interface IDiagramAssistant
{
    string Name { get; }
    DiagramSuggestion Generate(DiagramRequest request);
}

A DiagramSuggestion carries a DiagramDto that loads straight into the canvas, plus an explanation and any warnings. Because it produces the same DTO the serializer uses, generated diagrams can be edited, saved and executed like any other.

Flowchart DSL

The built-in assistant understands a compact description. Nodes are created on first mention, types are inferred or declared, and edges carry optional labels:

Start(start) "Start" -> Receive "Receive order" -> Valid(decision) "Valid?"
Valid -> Pay "Process payment" : yes
Valid -> Notify "Notify customer" : no
Pay -> Ship "Ship order" -> End(end) "End"
Notify -> End
  • Types: start, end, process, decision, io, document, data, delay, manual, subprocess and more.
  • Start/End are inferred from the node name when no type is given.
  • Lines starting with # or // are comments.
  • The result is laid out top-down by rank, with branches spread across rows.

Mind-Map Outlines

Indentation is all a mind map needs — the first line is the central topic and each level of indentation becomes a ring of the radial layout:

Product strategy
  Customers
    Personas
    Feedback
  Pricing
  Roadmap

Provider Registry

DiagramAssistantRegistry tries providers in order and falls back, so an LLM assistant can be tried first and the offline rule-based assistant guarantees a result:

var registry = new DiagramAssistantRegistry();          // rule-based assistant by default
registry.Register(new MyLlmAssistant(), priority: 0);   // tried first

var suggestion = registry.Generate(new DiagramRequest
{
    Prompt = "Start -> Validate \"Check input\" -> End",
    MaxNodes = 40
});

manager.LoadFromDto(suggestion.Diagram);
Bounded input. The parsers cap nesting depth and node counts, and the expression engine rejects over-large expressions, so a hostile or accidentally huge description produces a clear error rather than exhausting the process.

DSL and Assistant Types

The offline assistant parses a small DSL into a graph and then materializes components. These types are the parser surface, useful for validation and tooling.

RuleBasedDiagramAssistant

Offline, deterministic diagram assistant. Understands the flowchart DSL (see FlowchartDslParser) and indentation-based mind-map outlines (see MindMapDslParser), lays the result out, and produces a DiagramDto ready for DrawingManager.LoadFromDto.

MemberKindDescription
string NamePropertyGets or sets the name.
DiagramSuggestion Generate(DiagramRequest request)Method

FlowchartDslParser

Parses a compact flowchart DSL into a graph and lays it out top-down. Grammar (one statement per line): node ["(type)"] ["title"] ["->" node ...] [": edge label"] Examples: Start(start) "Start" -> Receive "Receive order" -> Valid(decision) "Valid?" Valid -> Process "Process payment" : yes Valid -> Notify "Notify customer" : no Process -> End(end) "End" Lines starting with # or // are comments. Node names are case-insensitive; a node is created on first mention and reused afterwards.

MemberKindDescription
static DslGraph Parse(string text, int maxNodes = 60)MethodParses DSL text into a graph and applies the top-down layout.
static void Layout(DslGraph graph)MethodAssigns ranks (top-down depth) and row/column positions.

DslGraph

Parsed graph of nodes and edges with warnings.

MemberKindDescription
List<DslNode> NodesPropertyGets or sets the nodes.
List<DslEdge> EdgesPropertyGets or sets the edges.
List<string> WarningsPropertyGets or sets the warnings.
DslNode Find(string name)Method

DslNode

A parsed DSL node with layout geometry.

MemberKindDescription
string NamePropertyGets or sets the name.
string TypeKeywordPropertyGets or sets the type keyword.
string ClassNamePropertyResolved component class name (e.g. ProcessNode, DecisionNode).
string TitlePropertyGets or sets the title.
int RankPropertyGets or sets the rank.
float XPropertyGets or sets the x.
float YPropertyGets or sets the y.
float WidthPropertyGets or sets the width.
float HeightPropertyGets or sets the height.

DslEdge

A parsed DSL edge.

MemberKindDescription
string FromPropertyGets or sets the from.
string ToPropertyGets or sets the to.
string LabelPropertyGets or sets the label.

MindMapDslParser

Parses an indentation-based outline into a mind-map tree and lays it out radially. Tabs count as four spaces. Blank lines are ignored; lines starting with # or // are comments.

MemberKindDescription
static MindMapDslNode Parse(string text, out List<string> warnings, int maxNodes = 60)MethodParses an outline and applies the radial layout.
const int MaxOutlineDepth = 100ConstantMaximum outline nesting depth. The radial layout walks the tree recursively, so deeper outlines are flattened onto the deepest allowed level instead of overflowing the stack.
static MindMapDslNode ParseTree(string text, List<string> warnings = null, int maxNodes = 60)MethodParses the outline without laying it out.
static void Layout(MindMapDslNode root, List<string> warnings = null)MethodAssigns radial positions (root at the center, children on expanding arcs).

MindMapDslNode

A parsed mind-map node with radial layout geometry.

MemberKindDescription
string TitlePropertyGets or sets the title.
int DepthPropertyGets or sets the depth.
List<MindMapDslNode> ChildrenPropertyGets or sets the children.
float XPropertyGets or sets the x.
float YPropertyGets or sets the y.
float WidthPropertyGets or sets the width.
float HeightPropertyGets or sets the height.
string TypeKeywordPropertyType keyword: central (depth 0), topic (depth 1), subtopic (depth 2+).
override string ToString()Method