Class Diagram — Reladraw template

订单领域类图. Copy the source, paste into the official playground, done. No coordinates — every position is stated relative to something else.

Preview

Customer Order OrderItem Product places 1:N contains 1:N refs N:1

Source (.reladraw)

node customer "Customer"
node order "Order"  below customer
node item "OrderItem"  below order  left
node product "Product"  below item
edge customer -> order  "places 1:N"
edge order -> item  "contains 1:N"
edge item -> product  "refs N:1"

How to use

  1. Open the Reladraw playground
  2. Paste the source above — the diagram re-solves live
  3. Export SVG from the playground, or render locally: npx reladraw class-diagram.reladraw -o out.svg

When to use this template

A domain-model class diagram for the same e-commerce shape as the ER template: customers place orders, orders contain items, items reference products. Use it in OOP design discussions and code review docs — the 1:N / N:1 labels double as relationship multiplicity.

How to customize

  1. Add an inheritance. Add node vip "VipCustomer" below customer and edge vip -> customer "extends".
  2. Add attributes. Put them in labels: node order "Order\n+ id\n+ total" — \n breaks the label across lines.
  3. Show an interface. Add node payable "Payable" above order with edge order -> payable "implements".

FAQ

Can Reladraw draw UML class diagrams?

Yes for the common case: classes as nodes, relationships as labeled edges (extends, implements, 1:N). Full UML notation — compartments, visibility markers on every member — works better in dedicated UML tools, but attribute lists fit fine as line-broken labels.

How do I show composition vs aggregation?

In the edge label: contains for composition, has for aggregation. If your audience expects the diamond notation, keep a legend line or export and annotate — the topology stays identical.

What is the difference between this and the ER template?

Same domain, different lens: the ER diagram models stored data and cardinality; the class diagram models behavior-bearing types and inheritance. Architects usually keep both.

Related templates

ETL PipelineLLM Evaluation FlowFeature Store Flow