Skip to documentation content

Documentation · Structure

Class diagram

Declare every class with its attributes and operations, then the relations between them. A parent is drawn above what specialises it.

Open Class diagram

When to use it

Model the static structure of an object-oriented system: classes, interfaces and enumerations with their attributes and operations, and how they relate.

Write a generalisation child first (inherit Cat -> Animal) and an aggregation or composition whole first (compose Order -> Line). The parent is drawn above its children.

Working example

Copy this complete example into the Source tab, then press Generate. Change its labels or values to make your first version.

Tingraph source
class "Library System" {
  abstract ITEM "LibraryItem" {
    attr "# id : String"
    attr "# title : String"
    method "+ isAvailable() : Boolean"
  }
  class BOOK "Book" {
    attr "- isbn : String"
    attr "- pages : Integer"
    method "+ getAuthor() : Author"
  }
  class MEMBER "Member" {
    attr "- name : String"
    attr "- email : String"
    method "+ borrow(item : LibraryItem) : Loan"
  }
  class LOAN "Loan" {
    attr "- dueDate : Date"
    method "+ isOverdue() : Boolean"
  }
  interface NOTIFY "Notifiable" {
    method "+ notify(message : String) : void"
  }
  enum STATUS "LoanStatus" {
    value "ACTIVE"
    value "RETURNED"
    value "OVERDUE"
  }

  inherit BOOK -> ITEM
  implement MEMBER -> NOTIFY
  MEMBER "1" -> "0..*" LOAN "makes"
  compose LOAN "1" -> "1" STATUS
  LOAN "0..*" -> "1" ITEM "lends"
}

Syntax reference

The same reference used by the editor and AI briefing. Syntax is notation-specific; use the keywords listed here.

Diagram

SyntaxMeaning
class "Title" {open a UML class diagram

Classifiers

SyntaxMeaning
class ID "Name" { ... }class: name, attributes, operations
abstract ID "Name" { ... }abstract class, «abstract» over the name
interface ID "Name" { ... }interface, «interface» over the name
enum ID "Name" { ... }enumeration, «enumeration» over the name
attr "- name : String"an attribute, inside the block
method "+ save() : void"an operation, inside the block
value "ACTIVE"an enumeration literal, inside the block

Relations

SyntaxMeaning
A -> Bassociation (plain line)
A "1" -> "0..*" B "places"association with multiplicities and a name
navigate A -> Bdirected association (open arrow at B)
inherit A -> Bgeneralisation: A is a kind of B
implement A -> Brealisation: A implements interface B
aggregate A -> Baggregation: A has B (hollow diamond at A)
compose A -> Bcomposition: A owns B (filled diamond at A)
depend A -> Bdependency: A uses B (dashed); also A -.-> B
# commentline comment (also //)

Language rules

  • The file is one class "Title" { ... } block.
  • A classifier is class, abstract, interface or enum, then an ID and its name in quotes. Its block lists attr and method lines (an enum lists value lines); write each member in UML form, e.g. attr "- name : String", method "+ total() : Decimal".
  • Visibility is the first character of a member: + public, - private, # protected, ~ package.
  • Write a generalisation and a realisation child first: inherit Cat -> Animal, implement Repo -> Store. They carry no multiplicity.
  • Write an aggregation and a composition whole first: compose Order -> OrderLine. The diamond is drawn on the whole.
  • A bare A -> B is an association. Multiplicities are quoted on either side of the arrow and the relation's name follows the second class: Customer "1" -> "0..*" Order "places".

Edit on the canvas

  • Move and rename classes on the sheet; members are captions you can retype in place.
  • Choose association, generalisation, realisation, aggregation, composition or dependency from the connector rail.

Generate replaces the drawing from source. Save before generating again if you want to preserve manual finishing touches.

Read Saving & exporting

Write it with an assistant

Tingraph AI already knows this notation. For another assistant, copy the tutorial below, describe your diagram under MY DIAGRAM, then paste the returned source into the editor. This prompt includes every syntax row, rule and working example above.

Read the complete prompt
You are writing Tingraph source. Tingraph is a small text language that draws a UML class diagram. Answer with Tingraph source only.

SYNTAX
Diagram
  class "Title" {             open a UML class diagram

Classifiers
  class ID "Name" { ... }     class: name, attributes, operations
  abstract ID "Name" { ... }  abstract class, «abstract» over the name
  interface ID "Name" { ... }  interface, «interface» over the name
  enum ID "Name" { ... }      enumeration, «enumeration» over the name
  attr "- name : String"      an attribute, inside the block
  method "+ save() : void"    an operation, inside the block
  value "ACTIVE"              an enumeration literal, inside the block

Relations
  A -> B                      association (plain line)
  A "1" -> "0..*" B "places"  association with multiplicities and a name
  navigate A -> B             directed association (open arrow at B)
  inherit A -> B              generalisation: A is a kind of B
  implement A -> B            realisation: A implements interface B
  aggregate A -> B            aggregation: A has B (hollow diamond at A)
  compose A -> B              composition: A owns B (filled diamond at A)
  depend A -> B               dependency: A uses B (dashed); also A -.-> B
  # comment                   line comment (also //)

RULES
- The file is one `class "Title" { ... }` block.
- A classifier is `class`, `abstract`, `interface` or `enum`, then an ID and its name in quotes. Its block lists `attr` and `method` lines (an enum lists `value` lines); write each member in UML form, e.g. `attr "- name : String"`, `method "+ total() : Decimal"`.
- Visibility is the first character of a member: `+` public, `-` private, `#` protected, `~` package.
- Write a generalisation and a realisation child first: `inherit Cat -> Animal`, `implement Repo -> Store`. They carry no multiplicity.
- Write an aggregation and a composition whole first: `compose Order -> OrderLine`. The diamond is drawn on the whole.
- A bare `A -> B` is an association. Multiplicities are quoted on either side of the arrow and the relation's name follows the second class: `Customer "1" -> "0..*" Order "places"`.

WORKED EXAMPLE
class "Library System" {
  abstract ITEM "LibraryItem" {
    attr "# id : String"
    attr "# title : String"
    method "+ isAvailable() : Boolean"
  }
  class BOOK "Book" {
    attr "- isbn : String"
    attr "- pages : Integer"
    method "+ getAuthor() : Author"
  }
  class MEMBER "Member" {
    attr "- name : String"
    attr "- email : String"
    method "+ borrow(item : LibraryItem) : Loan"
  }
  class LOAN "Loan" {
    attr "- dueDate : Date"
    method "+ isOverdue() : Boolean"
  }
  interface NOTIFY "Notifiable" {
    method "+ notify(message : String) : void"
  }
  enum STATUS "LoanStatus" {
    value "ACTIVE"
    value "RETURNED"
    value "OVERDUE"
  }

  inherit BOOK -> ITEM
  implement MEMBER -> NOTIFY
  MEMBER "1" -> "0..*" LOAN "makes"
  compose LOAN "1" -> "1" STATUS
  LOAN "0..*" -> "1" ITEM "lends"
}

OUTPUT
- Reply with one fenced code block and nothing else.
- The block starts with `class "…" {` and ends with `}`.
- Do not invent keywords: use only the ones listed above.
- Keep labels short enough to read inside a box, and keep every ID unique.

MY DIAGRAM
Describe what you want here, then send this message.
How AI requests, attachments and privacy work

Something unclear? Contact support or read the Privacy Policy.