Lab 04Model by conversation with the Modeling Assistant
A clinic appointment model with a class diagram, an OCL constraint and a state machine, built and checked entirely through the Modeling Assistant chat.
- Time
- 35 min
- Level
- Beginner
- Runs with
- Browser
- Do first
- Nothing
You'll learn to
- Start a project in the Describe it (agentic) interface
- Create a class diagram from a plain-language description
- Refine a model with follow-up prompts and revert an assistant edit
- Verify what the assistant changed on the canvas and with Quality Check
- Add a state machine and trigger a code generator from the chat
You'll need
- A modern desktop browser (Chrome, Edge or Firefox)
- No modeling experience (the lab explains what you see on the canvas)
This is the lab to start with if you want to build software with BESSER without learning modeling first. The Web Modeling Editor has an agentic interface: you describe what you want in plain words, and the Modeling Assistant creates and edits the diagrams for you on a live canvas. Those diagrams are the model BESSER generates code from, so you only need to read them, not draw them. If you later want to draw them yourself, Lab 1 shows how, and you can switch between chatting and drawing at any time.
In this lab you model a small clinic: patients book appointments with doctors. You build the class diagram by conversation, refine it, add a rule, add a state machine for the appointment lifecycle, and generate a PostgreSQL schema, all from the chat. Throughout, you check the result yourself instead of trusting the reply.
Start a project in Describe it mode
- Open https://editor.besser-pearl.org. On a first visit the editor asks how you want to build.
- On the Describe it card, click Start describing.

- The Create A Project form opens with Agentic already selected under View. Enter the name
Clinic Appointmentsand click Create Project. The editor stores it asClinic_Appointments.

- The assistant workspace fills the screen with the question “What would you like to create today?” and a composer that reads “Describe what you want to create or modify…”. Next to the subtitle a dot shows the connection state.

Describe the clinic and let the assistant build the class diagram
- Click into the composer, type the following prompt exactly, and press Enter:
Create a class diagram for a clinic appointment system with the classes Patient, Doctor and Appointment. A patient can book many appointments, and each appointment is with exactly one doctor. Give each class a few attributes.
- Wait for the reply. It usually arrives within 20 to 30 seconds. The assistant marks it with a System created badge, summarises what it built (“Your ClinicAppointmentSystem spec is ready — it captures Patient, Doctor, Appointment, with 2 relationship(s) linking them.”) and offers three quick-action chips under it: Generate application, Explain the specs and Review the model.

Switch to the canvas and verify what the assistant built
The assistant edits the model you see on the canvas. Look at the canvas after every change.
- Click the Review the model chip. It does not send a message; it closes the assistant workspace so you see the canvas. You can also click the See the Specs tab at the bottom of the workspace, or press Esc.
- The Class editor shows the new diagram. Check:
- There are three classes:
Patient,DoctorandAppointment, each with several typed attributes. - There is an association between
PatientandAppointmentwith a many end (*or0..*) on the Appointment side. - There is an association between
AppointmentandDoctorwith multiplicity1on the Doctor side.
- There are three classes:
- Double-click an association to open its properties and read the exact multiplicities. The automatic layout sometimes draws two association ends on top of each other, so their role names overlap; drag a class to separate them.

- To return to the chat, click the Describe your app tab at the top of the canvas. The conversation is still there. In the low-code view the same assistant is also available from the round assistant button in the bottom-right corner (Open assistant); both share one conversation.
- In the workspace’s bottom bar, click Your model. It opens a recap of the data model and its relationships, derived from the project. Click it again to close it.
Refine the model with follow-up prompts
Small, specific prompts work best. Name the class and the attribute, and say what must stay unchanged.
- Send:
Add an integer attribute named duration_minutes to the Appointment class.
- Send:
Rename the Doctor class to Physician.
Each edit gets a Modified badge and a one-line reply, for example “Added attribute to Appointment.” or “Updated Doctor.”
3. Close the workspace and check both edits on the canvas: Appointment has + duration_minutes: int, and the class formerly called Doctor is now Physician, still connected to Appointment. If the class already had a durationMinutes attribute, the assistant may rename that one instead of adding a second (“Updated attribute in attribute durationMinutes from Appointment.”), or leave it unchanged. Make sure Appointment ends up with exactly one duration attribute, named duration_minutes; if not, ask for it again by name.
4. Revert the rename. Ctrl+Z on the canvas undoes your own canvas edits, but it does not undo changes the assistant made, so ask for the reverse change instead:
Rename the Physician class back to Doctor.
The reply reads “Updated Physician.” Check on the canvas that the class is called Doctor again and that both associations are still there.
5. Add a rule. The assistant only writes OCL when you ask for a constraint explicitly:
Add a constraint that the duration_minutes of an Appointment must be greater than 0.
- The reply reads “Added OCL constraint on Appointment.” On the canvas, an OCL constraint box marked
«inv»is attached toAppointmentby a dashed line. The box shows only the start of the expression (context Appointment ...); double-click it to read the whole text. It should be equivalent tocontext Appointment inv: self.duration_minutes > 0. In one run it readcontext Appointment inv duration_must_be_positive: self.duration_minutes > 0; the constraint name and exact formatting may differ.

Ask the assistant to explain the model
The assistant can describe the current model in words. This is a quick way to spot a misunderstanding, but it is a summary, not a check.
- Send:
Describe my current model.
- Compare the description with the canvas. The reply is headed “Current model” and lists each class with its attributes, the two associations and their role names, and usually the new constraint. It also summarises the other diagrams in the project (for example “GUI Diagram: A Home page with no sections.”). It may mention “an association from ocl_… to Appointment”: that is the dashed line linking the constraint box to its class, not an extra relationship. If the description and the canvas disagree, the canvas is the truth: the description is generated text, the canvas is the model that generators read.
- The Explain the specs chip (shown after a model is created) sends a similar request for a plain-language overview.
Add a state machine by chat
The assistant can add a diagram of another type to the same project. Here you model the lifecycle of an appointment.
- Send:
Create a state machine for the appointment lifecycle with the states Requested, Confirmed, Completed and Cancelled.
- The reply has a System created badge and reads like “Built the AppointmentLifecycle state machine with 6 state(s): Requested, Confirmed, Completed, Cancelled, connected by 13 transition(s).” The six states include an initial and a final node; the number of transitions varies between runs. The assistant adds a State Machine Diagram and switches the canvas to it. Close the workspace: the State editor is now highlighted in the left sidebar.
- Check that the four states exist, that there is an initial state, and that the transitions make sense (for example Requested to Confirmed, Confirmed to Completed, and transitions to Cancelled). The assistant also gives each state
entry,doandexitactions and writes guards on the transitions. Transition names are chosen by the assistant and vary, and long transition labels often overlap; drag the states apart or zoom in to read them. - If a state is missing, ask for it by name, for example
Add a NoShow state to the state machine, reachable from Confirmed.

Validate the model and generate code from the chat
- Click Class in the left sidebar so the class diagram is active.
- Click Quality Check (the check-mark button in the top bar). Resolve any reported errors before you generate. Because the model has a constraint, a message titled “Valid Constraints:” lists it (for example
[Appointment inv duration_must_be_positive] 'context Appointment inv duration_must_be_positive: self.duration_minutes > 0') and stays open until you close it; a second, short-lived message reads “Diagram is valid”. Quality Check validates the model; it says nothing about generated code. - Open the chat again and send:
Generate SQL schema for PostgreSQL
- The assistant runs the same SQL DDL generator as Generate > Database > SQL DDL, with the PostgreSQL dialect taken from your sentence. Within about 15 seconds a compact result card appears: Generated deterministically ·
sql· 0 tokens, with Show steps and a Download button, followed by “Your code is generated and ready to download.” The deterministic generators need no API key, use no language-model tokens, and give the same output for the same model. - Click Download. Nothing is saved until you click; the browser then saves
tables.sqland the button changes to Download again. - Open
tables.sqlin a text editor. It starts with-- Generated by BESSER 8.0.1. Check that it contains aCREATE TABLEstatement for each class (patient,doctor,appointment), aduration_minutes INTEGER NOT NULLcolumn, and the foreign keysFOREIGN KEY(doctor_id) REFERENCES doctor (id)andFOREIGN KEY(patient_id) REFERENCES patient (id)in the appointment table. If your model has an enumeration such asAppointmentStatus, PostgreSQL gets aCREATE TYPE ... AS ENUMstatement for it.

Exercise: extend the clinic by conversation
Show a solution
Two short prompts work better than one long one: first create the class and its association, then add the constraint. On the canvas, check that the association end on the Prescription side is many and on the Appointment side is 1. A constraint such as context Prescription inv: self.dosage <> '' is one valid form.
Show a solution
Layout is not part of the B-UML export, so any difference you find in the files is a modeling decision. Typical differences are attribute types (str versus date for a date), an extra identifier attribute, and the role names on association ends.