Profile diagrams: stereotypes and metadata

Profile diagrams: stereotypes and metadata

puml.online

简介 / Introduction

Stereotypes extend class diagram elements with semantic labels, distinguishing roles like “interface”, “service”, “entity”, and “enum” within the same diagram. Both PlantUML and Mermaid support <<stereotype>> notation, but with different details. This post compares syntax and rendering output.

PlantUML version

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
@startuml
skinparam classAttributeIconSize 0

profile UserProfile {
stereotype Entity <<entity>>
stereotype Service <<service>>
stereotype Interface <<interface>>
}

class User as "用户" <<entity>>
class AuthService as "认证服务" <<service>>
interface IUserRepo as "用户仓库" <<interface>>

User -- IUserRepo
AuthService ..> IUserRepo
@enduml

PlantUML’s profile block declares a namespace for stereotypes, and < <type> > annotations follow the class name directly. Common stereotypes like <<entity>>, <<service>>, and <<interface>> can be styled via skinparam directives.

Mermaid version

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
classDiagram
class User {
<<entity>>
+String name
+int id
}
class AuthService {
<<service>>
+login()
+logout()
}
class IUserRepo {
<<interface>>
+findById()
+save()
}
User --> IUserRepo
AuthService ..> IUserRepo

In Mermaid, <<stereotype>> appears as the first line inside a class block, equivalent to PlantUML’s < <type> > annotation. The classDiagram notation supports <<interface>>, <<abstract>>, <<service>>, and other common stereotypes.

对比 / Side-by-side

Feature PlantUML Mermaid
Declaration position After class name as < <type> > Inside class block as first line <<type>>
Profile block Supported via profile {} Not supported
skinparam styling Full control over font/color Themed via CSS
Relationship arrows --, ..>, `< –`

小结 / Wrap-up

Both engines share the same core concept — <<type>> denotes a stereotype — but PlantUML adds profile declarations and skinparam fine-tuning for complex enterprise建模. Mermaid wins on lightweight, Markdown-friendly authoring for inline documentation.

  • Title: Profile diagrams: stereotypes and metadata
  • Author: puml.online
  • Created at : 2026-10-21 09:00:00
  • Updated at : 2026-10-21 01:07:06
  • Link: https://puml.online/blog/profile-diagram-stereotypes-en/
  • License: This work is licensed under CC BY-NC-SA 4.0.