Assisted Generation
Turning a description into a diagram, offline or through an LLM
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.
Table of Contents
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,subprocessand more. Start/Endare 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);
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.
| Member | Kind | Description |
|---|---|---|
string Name | Property | Gets 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.
| Member | Kind | Description |
|---|---|---|
static DslGraph Parse(string text, int maxNodes = 60) | Method | Parses DSL text into a graph and applies the top-down layout. |
static void Layout(DslGraph graph) | Method | Assigns ranks (top-down depth) and row/column positions. |
DslGraph
Parsed graph of nodes and edges with warnings.
| Member | Kind | Description |
|---|---|---|
List<DslNode> Nodes | Property | Gets or sets the nodes. |
List<DslEdge> Edges | Property | Gets or sets the edges. |
List<string> Warnings | Property | Gets or sets the warnings. |
DslNode Find(string name) | Method |
DslNode
A parsed DSL node with layout geometry.
| Member | Kind | Description |
|---|---|---|
string Name | Property | Gets or sets the name. |
string TypeKeyword | Property | Gets or sets the type keyword. |
string ClassName | Property | Resolved component class name (e.g. ProcessNode, DecisionNode). |
string Title | Property | Gets or sets the title. |
int Rank | Property | Gets or sets the rank. |
float X | Property | Gets or sets the x. |
float Y | Property | Gets or sets the y. |
float Width | Property | Gets or sets the width. |
float Height | Property | Gets or sets the height. |
DslEdge
A parsed DSL edge.
| Member | Kind | Description |
|---|---|---|
string From | Property | Gets or sets the from. |
string To | Property | Gets or sets the to. |
string Label | Property | Gets 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.
| Member | Kind | Description |
|---|---|---|
static MindMapDslNode Parse(string text, out List<string> warnings, int maxNodes = 60) | Method | Parses an outline and applies the radial layout. |
const int MaxOutlineDepth = 100 | Constant | Maximum 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) | Method | Parses the outline without laying it out. |
static void Layout(MindMapDslNode root, List<string> warnings = null) | Method | Assigns radial positions (root at the center, children on expanding arcs). |
MindMapDslNode
A parsed mind-map node with radial layout geometry.
| Member | Kind | Description |
|---|---|---|
string Title | Property | Gets or sets the title. |
int Depth | Property | Gets or sets the depth. |
List<MindMapDslNode> Children | Property | Gets or sets the children. |
float X | Property | Gets or sets the x. |
float Y | Property | Gets or sets the y. |
float Width | Property | Gets or sets the width. |
float Height | Property | Gets or sets the height. |
string TypeKeyword | Property | Type keyword: central (depth 0), topic (depth 1), subtopic (depth 2+). |
override string ToString() | Method |