Schema Reference¶
This document describes all JSON schemas used by the Modeling Agent for request parsing, response generation, and inter-component communication. For the WebSocket transport layer, see WebSocket Protocol Reference. For user-facing examples, see Usage.
On this page
Protocol Schemas¶
AssistantRequest (Inbound)¶
The canonical request format after protocol parsing. Raw WebSocket messages are
normalized into this structure by src/protocol/adapters.py.
{
"action": "user_message",
"protocolVersion": "2.0",
"clientMode": "workspace",
"message": "create a User class with id and email",
"diagramType": "ClassDiagram",
"diagramId": "550e8400-e29b-41d4-a716-446655440000",
"context": {
"activeDiagramType": "ClassDiagram",
"activeDiagramId": "550e8400-e29b-41d4-a716-446655440000",
"projectSnapshot": {
"name": "MyProject",
"diagrams": {
"ClassDiagram": [
{ "id": "diag-1", "title": "Main", "model": {} }
]
}
},
"currentDiagramIndices": { "ClassDiagram": 0 }
},
"attachments": [
{
"filename": "model.puml",
"content": "QGN0YXJ0dW1s...",
"mimeType": "text/plain"
}
]
}
Field |
Type |
Description |
|---|---|---|
|
|
Request type: |
|
|
Always |
|
|
Which surface sent the message — |
|
|
Natural language request text |
|
|
Target diagram type (may be empty) |
|
|
UUID of target diagram instance |
|
|
WorkspaceContext object (see below) |
|
|
List of FileAttachment objects |
WorkspaceContext¶
{
"activeDiagramType": "ClassDiagram",
"activeDiagramId": "uuid-string",
"projectSnapshot": {
"name": "MyProject",
"diagrams": {
"ClassDiagram": [
{ "id": "diag-1", "title": "Main", "model": { "elements": {}, "relationships": {} } }
],
"StateMachineDiagram": []
}
},
"diagramSummaries": [
{ "diagramType": "ClassDiagram", "diagramId": "diag-1", "title": "Main" }
],
"currentDiagramIndices": { "ClassDiagram": 0 },
"sessionId": "abc-123",
"pilotParticipant": null
}
Field |
Type |
Description |
|---|---|---|
|
|
Currently active diagram tab. Normalized to |
|
|
UUID of active diagram |
|
|
Deprecated and ignored. The active model is resolved from
|
|
|
Maps each diagram type to an array of tabs
( |
|
|
|
|
|
Active tab index per diagram type (default 0) |
|
|
Optional opt-in study participant label, validated against
|
FileAttachment¶
{
"filename": "model.puml",
"content": "QGN0YXJ0dW1s...",
"mimeType": "text/plain"
}
Response Schemas¶
Important
The agent emits its own simple spec format, not the editor’s Apollon
element/relationship maps. The frontend’s ConverterFactory translates
between them — it generates UUIDs, bounds and Apollon type names. Nothing
below carries editor UUIDs or bounds.
inject_element¶
Returned when a single element is created (e.g., one class, one state).
{
"action": "inject_element",
"diagramType": "ClassDiagram",
"diagramId": "uuid",
"element": {
"className": "User",
"attributes": [
{ "name": "id", "type": "String", "visibility": "public" },
{ "name": "email", "type": "String", "visibility": "private" }
],
"methods": []
},
"message": "Added **User** …"
}
inject_complete_system¶
Returned when a full diagram is generated (e.g., complete class model).
{
"action": "inject_complete_system",
"diagramType": "ClassDiagram",
"diagramId": "uuid",
"replaceExisting": true,
"systemSpec": {
"systemName": "E-commerce System",
"classes": [
{
"className": "User",
"attributes": [ { "name": "id", "type": "String", "visibility": "public" } ],
"methods": []
},
{
"className": "Order",
"attributes": [ { "name": "total", "type": "Float", "visibility": "public" } ],
"methods": []
}
],
"relationships": [
{
"type": "Association",
"source": "User",
"target": "Order",
"sourceMultiplicity": "1",
"targetMultiplicity": "0..*",
"name": "places"
}
]
},
"message": "Built the **E-commerce System** with 2 classes."
}
Each diagram type has its own systemSpec shape — SystemClassSpec,
SystemStateMachineSpec, SystemObjectSpec, SystemAgentSpec,
SystemGUISpec, SystemQuantumCircuitSpec, SystemBPMNSpec,
SystemUserProfileSpec. See Structured Output Schemas (Pydantic).
modify_model¶
Returned when modifying an existing diagram. Single modifications use
modification; batches use modifications.
{
"action": "modify_model",
"diagramType": "ClassDiagram",
"diagramId": "uuid",
"modifications": [
{
"action": "add_attribute",
"target": { "className": "User" },
"changes": { "name": "phone", "type": "String", "visibility": "public" }
},
{
"action": "remove_element",
"target": { "className": "LegacyOrder" }
}
],
"message": "Applied 2 changes."
}
The nested action is a Literal on each diagram’s modification schema —
see WebSocket Protocol Reference for the per-type list.
trigger_generator¶
Returned when code generation is requested.
{
"action": "trigger_generator",
"generatorType": "django",
"config": {
"project_name": "myproject",
"app_name": "myapp",
"containerization": true
},
"diagramType": "ClassDiagram"
}
trigger_export¶
{
"action": "trigger_export",
"format": "json"
}
trigger_deploy¶
{
"action": "trigger_deploy",
"platform": "render",
"config": {},
"message": "Opening the **Deploy to Render** dialog…"
}
trigger_smart_generator¶
Returned when the request needs the LLM-authored generator rather than a BESSER built-in.
{
"action": "trigger_smart_generator",
"instructions": "Rails 7, PostgreSQL via Active Record, Devise auth",
"provider": "anthropic",
"message": "Generating your application from your specs…"
}
An optional mode ("generate") forces a rebuild; see
WebSocket Protocol Reference.
trigger_github_import¶
{
"action": "trigger_github_import",
"owner": "besser-pearl",
"repo": "my-generated-app",
"branch": null,
"message": "Importing **besser-pearl/my-generated-app** from GitHub…"
}
assistant_message¶
Generic text response (help, errors, confirmations).
{
"action": "assistant_message",
"message": "I created a User class with id and email attributes."
}
auto_generate_gui¶
Triggers automatic GUI generation from the ClassDiagram (no LLM). The frontend builds one page per class.
{
"action": "auto_generate_gui",
"diagramType": "GUINoCodeDiagram",
"message": "I created screens for Book, Author and Member.",
"suggestedActions": [
{ "label": "Generate the web app", "prompt": "generate the web app" }
]
}
create_diagram_tab¶
Creates a new tab for a diagram type. Emitted when the user answers a replace/keep confirmation with “new tab”.
{
"action": "create_diagram_tab",
"diagramType": "ClassDiagram"
}
Diagram Element Schemas¶
ClassDiagram Elements¶
Class:
{
"id": "uuid",
"name": "ClassName",
"type": "Class",
"bounds": { "x": 0, "y": 0, "width": 200, "height": 150 },
"attributes": {
"attr-uuid": {
"id": "attr-uuid",
"name": "attributeName",
"type": "ClassAttribute",
"bounds": { "x": 0, "y": 40, "width": 200, "height": 30 }
}
},
"methods": {
"method-uuid": {
"id": "method-uuid",
"name": "methodName()",
"type": "ClassMethod",
"bounds": { "x": 0, "y": 70, "width": 200, "height": 30 }
}
}
}
Relationship types:
Type |
UML Meaning |
|---|---|
|
Association (bidirectional) |
|
Association (unidirectional) |
|
Generalization |
|
Aggregation (hollow diamond); the source is the part, the target the whole |
|
Composition (filled diamond); the source is the part, the target the whole |
|
Dependency (dashed arrow) |
|
Interface realization |
Relationship:
{
"id": "uuid",
"type": "ClassBidirectional",
"source": {
"element": "source-class-uuid",
"multiplicity": "1",
"role": "owner"
},
"target": {
"element": "target-class-uuid",
"multiplicity": "*",
"role": "items"
},
"path": [
{ "x": 200, "y": 75 },
{ "x": 400, "y": 75 }
]
}
StateMachine Elements¶
State:
{
"id": "uuid",
"name": "StateName",
"type": "ObjectActivityNode",
"bounds": { "x": 0, "y": 0, "width": 160, "height": 80 }
}
Special states:
ObjectActivityInitialNode— Initial pseudo-state (filled circle)ObjectActivityFinalNode— Final state (circle with border)
Transition:
{
"id": "uuid",
"type": "ObjectActivityControlFlow",
"name": "event [guard] / action",
"source": { "element": "source-state-uuid" },
"target": { "element": "target-state-uuid" }
}
ObjectDiagram Elements¶
Object (instance):
{
"id": "uuid",
"name": "objectName : ClassName",
"type": "ObjectName",
"bounds": { "x": 0, "y": 0, "width": 200, "height": 120 },
"attributes": {
"attr-uuid": {
"id": "attr-uuid",
"name": "email = \"admin@example.com\"",
"type": "ObjectAttribute"
}
}
}
AgentDiagram Elements¶
The agent handler emits specs (not editor JSON). States and the initial node
get canvas positions from the layout engine; intents and the other components
(LLMs, RAG databases, tools, skills, workspaces, GUIs) go to the editor’s
components section without bounds.
State:
{
"type": "state",
"stateName": "greetingState",
"replies": [
{ "text": "Hello! How can I help you?", "replyType": "text" },
{ "text": "Answer briefly.", "replyType": "llm", "llm_name": "gpt4" }
],
"fallbackBodies": [
{ "text": "Sorry, I did not get that.", "replyType": "text" }
]
}
Each reply carries a replyType (one of the 17 ReplyType values, see
Diagram Handlers) plus the fields that type needs.
Intent:
{
"type": "intent",
"intentName": "HelloIntent",
"intentDescription": "The user greets the agent",
"trainingPhrases": ["hi", "hello", "hey", "good morning"]
}
Initial element:
{
"type": "initial"
}
Transition:
{
"source": "initial",
"target": "greetingState",
"condition": "auto",
"conditionValue": "",
"label": ""
}
condition is when_intent_matched (conditionValue holds the intent
name), when_no_intent_matched, or auto.
Components (in a complete system, one list per type):
{
"llms": [{ "name": "gpt4", "provider": "openai", "num_previous_messages": 3 }],
"ragElements": [{ "name": "faqKB", "llm_name": "gpt4", "k": 4 }],
"tools": [{ "name": "getWeather", "description": "...", "code": "def get_weather(city): ..." }],
"skills": [{ "name": "politeness", "content": "Always greet the user." }],
"workspaces": [{ "name": "docs", "path": "./docs", "writable": false }],
"guis": [{ "gui_id": "orderForm", "is_form": true }]
}
GUINoCodeDiagram Schema (GrapesJS)¶
{
"pages": [
{
"name": "UserManagement",
"component": "<div class='container'>...</div>",
"styles": ".container { padding: 20px; }",
"scripts": ""
}
]
}
QuantumCircuitDiagram Schema (Quirk)¶
{
"cols": [
[1, 1, "H"],
["*", 1, "X"],
["Measure", "Measure", "Measure"]
],
"gates": []
}
Gate notation: Each column is an array of operations per qubit. 1 means
identity (no operation), "H" is Hadamard, "X" is Pauli-X, "*" is a
control qubit, "Measure" is measurement.
Internal Schemas¶
Operation (Request Planner Output)¶
Field names are camelCase and the mode is one of complete_system /
modify_model (ALLOWED_MODEL_MODES in
src/orchestrator/request_planner.py).
{
"type": "model",
"diagramType": "ClassDiagram",
"mode": "complete_system",
"request": "create a bookstore class diagram"
}
{
"type": "generation",
"generatorType": "django",
"config": { "project_name": "myapp" }
}
UnifiedClassification (Router Output)¶
The Pydantic object returned by the single per-message classification call
(src/routing/unified_classifier.py). Every downstream state body reads from it, so
no second LLM call is ever needed to refine routing. See
Intent Recognition for the full field reference.
{
"intent": "generation_intent",
"generation_route": "smart",
"generator_type": null,
"refined_instructions": "Rails 7 with PostgreSQL and Devise auth",
"provider": "anthropic",
"domain_mismatch": false,
"suggested_new_domain": null,
"target_diagram_type": null,
"model_disposition": "reuse_for_generation",
"needs_clarification": false,
"clarifying_question": null,
"pending_flow_action": null,
"pending_flow_answer": null,
"reason": "User named a non-BESSER stack, so the smart route applies."
}
Quality Suggestion¶
{
"suggestions": [
"Consider adding an 'id' attribute to the User class",
"The Customer class has no relationships"
],
"whatsNext": [
"Create object instances to test your class model",
"Add a state machine to model User lifecycle"
]
}
Class Metadata (extracted from ClassDiagram)¶
{
"classes": [
{
"name": "User",
"attributes": [
{ "name": "id", "isNumeric": true, "isString": false },
{ "name": "email", "isNumeric": false, "isString": true },
{ "name": "age", "isNumeric": true, "isString": false }
],
"methods": ["login()", "logout()"],
"associations": ["Order", "Profile"]
}
]
}
Domain Pattern (currently disabled)¶
{
"domain": "ecommerce",
"keywords": ["shop", "store", "order", "cart", "product"],
"core_classes": [
{
"name": "Product",
"attributes": ["name: String", "price: Float", "stock: Integer"]
},
{
"name": "Customer",
"attributes": ["name: String", "email: String"]
}
],
"key_relationships": [
{
"source": "Customer",
"target": "Order",
"type": "association",
"sourceMultiplicity": "1",
"targetMultiplicity": "*"
}
],
"notes": "Include cart management and payment processing"
}
State Pattern (currently disabled)¶
{
"pattern": "order_processing",
"keywords": ["order", "purchase", "checkout"],
"states": [
"Initial",
"PendingPayment",
"PaymentProcessing",
"Confirmed",
"Preparing",
"Shipped",
"Delivered",
"Final"
],
"transitions": [
{ "source": "Initial", "target": "PendingPayment", "trigger": "place_order" },
{ "source": "PendingPayment", "target": "PaymentProcessing", "trigger": "submit_payment" }
]
}
Structured Output Schemas (Pydantic)¶
The Modeling Agent uses OpenAI Structured Outputs
backed by Pydantic models to guarantee valid JSON from the LLM. All schemas
live in src/schemas/ and enforce naming constraints, valid action types,
and enum-safe field values at the schema level.
ClassDiagram Schemas¶
Location: src/schemas/class_diagram.py
Generation schemas:
Schema |
Purpose |
|---|---|
|
One UML class ( |
|
Complete class diagram (list of |
|
Attribute with name (max 50), type, visibility, isDerived, defaultValue, isOptional |
|
Method with name (max 50), returnType, parameters, visibility, implementationType, code |
|
Relationship with Literal type (Association, Inheritance, Composition, Aggregation, Realization, Dependency) |
Modification schemas:
Schema |
Purpose |
|---|---|
|
Wraps a list of |
|
Single modification with a Literal |
Valid modification actions (enforced by Literal type):
add_class, modify_class, add_attribute, modify_attribute,
add_method, modify_method, add_relationship, modify_relationship,
remove_element, extract_class, split_class, merge_classes,
promote_attribute, add_enum, add_ocl_constraint
OCL constraints: SystemClassSpec may carry a constraints list of
OCLConstraintSpec invariants. The agent generates and emits them, but the
frontend converter and the editor’s class-diagram JSON have no slot for them
yet, so they are not persisted. See WebSocket Protocol Reference.
Compact Class Diagram Schema¶
Location: src/schemas/compact_class_diagram.py
A trimmed generation schema — CompactClassSpec,
CompactRelationshipSpec, CompactSystemClassSpec — used instead of the
full SystemClassSpec when BESSER_AGENT_COMPACT_SPEC is enabled (the
default). Fewer tokens on both the prompt and the completion side for the same
diagram.
StateMachine Schemas¶
Location: src/schemas/state_machine.py
Schema |
Purpose |
|---|---|
|
One state ( |
|
Complete state machine (states + transitions + codeBlocks) |
|
Literal actions: |
ObjectDiagram Schemas¶
Location: src/schemas/object_diagram.py
Schema |
Purpose |
|---|---|
|
One object instance ( |
|
Complete object diagram (objects + links) |
|
Literal actions: |
AgentDiagram Schemas¶
Location: src/schemas/agent_diagram.py
Schema |
Purpose |
|---|---|
|
|
|
Shared base with the type-specific action fields: |
|
One state action: |
|
Agent state ( |
|
Intent ( |
|
Component specs (fields listed in Diagram Handlers) |
|
One element: |
|
|
|
Complete agent diagram: |
|
|
|
|
|
15 |
|
|
GUINoCode & QuantumCircuit Schemas¶
Location: src/schemas/gui_diagram.py, src/schemas/quantum_circuit.py
Quantum circuits define SystemQuantumCircuitSpec over
QuantumOperationSpec entries, with SingleQuantumGateSpec for a single
gate and QuantumModificationSpec for edits.
The GUI schemas come in two families:
Typed builders —
SystemGUISpec/GUIPageSpec/GUISectionSpecwithGUIBindSpecdescribing a data-bound widget (kind, source class, columns, rows, sample data), plusGUIStatItem,GUITableRowandGUISampleDataPoint.Authored HTML —
AuthoredSystemGUISpec/AuthoredGUIPageSpec/AuthoredGUISectionSpecplusGUIThemeSpec. Here the LLM writes themed.ds-*markup containing<!--WIDGET:kind-->markers, and the server splices real data-bound widgets into those slots. See Diagram Handlers.
Modifications use GUIModificationSpec / GUIModificationBatchSpec.
BPMN Schemas¶
Location: src/schemas/bpmn.py
Schema |
Purpose |
|---|---|
|
A process node — event, task (with |
|
A flow between two nodes. The agent never sets the flow type; the editor derives message vs. sequence from pool membership. |
|
Participants and the roles within them. Generation-only — the
modification path has no |
|
Complete process: nodes + flows + optional pools/lanes |
|
Literal actions: |
UserProfile Schemas¶
Location: src/schemas/user_profile.py
Schema |
Purpose |
|---|---|
|
One matching criterion: a name, a comparison operator
( |
|
One class-instance box drawn from the bundled metamodel, carrying the
metamodel’s |
|
A link between two boxes |
|
Complete profile: boxes + links |
|
Literal actions: |
Schema Validation Guarantees¶
All schemas enforce:
Name length limits —
max_length=30on element names (classes, states, objects, intents),max_length=50on member names (attributes, methods, parameters, page names). Prevents the LLM from generating absurdly long names.Literal action types — Modification
actionfields useLiteralinstead of barestr, so the LLM cannot hallucinate invalid actions. If it tries, OpenAI Structured Outputs rejects the response and triggers a retry.Literal enum fields — Fields like
relationshipType,implementationType,stateType,condition, andreplyTypein modification schemas useLiteraltypes matching their generation-schema counterparts.
Supported Type Constants¶
# src/protocol/types.py
SUPPORTED_DIAGRAM_TYPES = {
"ClassDiagram",
"ObjectDiagram",
"StateMachineDiagram",
"AgentDiagram",
"GUINoCodeDiagram",
"QuantumCircuitDiagram",
"BPMN",
"UserDiagram",
}
# src/routing/generation_signals.py — keys only; each maps to a
# keyword list. "export" and "deploy" are actions, not generators.
GENERATOR_KEYWORDS.keys() == {
"django", "web_app", "backend", "sqlalchemy", "sql", "python",
"java", "pydantic", "jsonschema", "smartdata", "agent", "qiskit",
"rest_api", "rdf", "export", "deploy",
}
# Required config fields, asked for before trigger_generator is emitted.
GENERATOR_REQUIRED_FIELDS = {
"django": [], "backend": [], "sql": ["dialect"],
"sqlalchemy": ["dbms"], "jsonschema": ["mode"], "smartdata": [],
"qiskit": ["backend", "shots"], "rest_api": [], "rdf": [],
"export": ["format"], "deploy": [],
}
EXPORT_FORMATS = ["json", "buml"]
DIALECT_VALUES = ["sqlite", "postgresql", "mysql", "mssql", "mariadb", "oracle"]
MODE_VALUES = ["regular", "smart_data"]
QISKIT_BACKENDS = ["aer_simulator", "fake_backend", "ibm_quantum"]
# src/diagram_handlers/registry/factory.py — registered handler classes.
# The registry key is each handler's own get_diagram_type() value.
HANDLER_CLASSES = (
ClassDiagramHandler, ObjectDiagramHandler, StateMachineHandler,
AgentDiagramHandler, GUINoCodeDiagramHandler,
QuantumCircuitDiagramHandler, BPMNDiagramHandler,
UserProfileDiagramHandler,
)