classDiagram
使いどころ
Use a クラス when…
01
Object-oriented domain modeling
02
API client/server contracts
03
Inheritance and composition diagrams
構文の基本
The minimal syntax
Copy this and you have a working クラス. Build from here.
class.mmd
classDiagram class User { +UUID id +string email +login() +logout() } class Org { +UUID id +string name } class Session { +string token +revoke() } User class="code-str">"1" -- class="code-str">"*" Session : owns Org class="code-str">"1" -- class="code-str">"*" User : employs
よく使うパターン
Patterns worth memorizing
Visibility prefixes
`+` public, `-` private, `#` protected, `~` package — exactly like UML.
Cardinality
`User "1" -- "*" Post : writes` — quoted multiplicities flank the relation.
Generics
`class List~T~` renders the angle brackets; useful for typed collections.
ハマりどころ
The things that will trip you up
Mermaid silently ignores misspellings — these are the failures we see most.
- 01
Method bodies aren't supported — only signatures.
- 02
The relation arrow direction matters: `<|--` is inheritance pointing to the parent.
- 03
Notes attach to a class with `note for ClassName "text"`.
関連する図