Video failed to load

Markdown PlantUML Diagrams

1018 words
5 minutes
Markdown PlantUML Diagrams

A Guide to PlantUML Diagrams in Markdown#

PlantUML describes diagrams in plain text. Write a short structured definition to generate sequence, class, use case, activity, and other engineering diagrams.

It is especially useful in technical blogs and project documentation:

  • Version diagrams alongside the article for easier collaboration and review
  • Update diagrams by editing text, making frequent iteration straightforward
  • Integrate seamlessly with Markdown to keep documentation consistent

In Firefly, plantuml code blocks are encoded at build time to generate server SVG URLs. The page switches diagram sources automatically with the light or dark theme and supports zooming, dragging, and fullscreen viewing.

To get started quickly, use this minimal template:

@startuml
Alice -> Bob: Hello
Bob --> Alice: Hi
@enduml

Activity Diagram Example#

@startuml
start
:用户提交订单;
if (库存充足?) then (是)
	:冻结库存;
	:创建支付单;
	if (支付成功?) then (是)
		:生成发货单;
		:通知仓库拣货;
	else (否)
		:取消订单;
		:释放库存;
	endif
else (否)
	:提示缺货;
endif
stop
@enduml

State Diagram Example#

@startuml
[*] --> 草稿

草稿 --> 待审核 : 提交
待审核 --> 草稿 : 驳回
待审核 --> 已发布 : 审核通过
已发布 --> 已归档 : 到期归档
已发布 --> 草稿 : 撤回修改

state 已发布 {
	[*] --> 可见
	可见 --> 隐藏 : 手动隐藏
	隐藏 --> 可见 : 恢复展示
}

已归档 --> [*]
@enduml

Use Case Diagram Example#

@startuml
left to right direction
actor 游客
actor 用户
actor 管理员

rectangle 博客系统 {
	usecase "浏览文章" as UC1
	usecase "搜索内容" as UC2
	usecase "发表评论" as UC3
	usecase "点赞收藏" as UC4
	usecase "审核评论" as UC5
	usec

Component Diagram Example#

@startuml
package "Firefly Site" {
	[Astro App] as App
	[Markdown Parser] as Parser
	[PlantUML Encoder] as Encoder
	[Theme Switcher] as Theme
	[Search Indexer] as Search
}

cloud "PlantUML Server" as

Deployment Diagram Example#

@startuml
node "User Device" {
	artifact "Browser"
}

node "CDN / Edge" {
	artifact "Static Assets"
}

node "Cloudflare Worker" {
	artifact "SSR Handler"
}

node "PlantUML Service" {
	artifact "SVG Re

ER Diagram Example#

@startuml
entity User {
	*id : uuid <<PK>>
	--
	username : varchar
	email : varchar
	created_at : datetime
}

entity Post {
	*id : uuid <<PK>>
	--
	author_id : uuid <<FK>>
	title : varchar
	content :

Sequence Diagram Example: Sign-in and Token Refresh#

@startuml
autonumber
actor User as 用户
participant Web as 前端页面
participant API as 网关接口
participant Auth as 认证服务
database Redis as 会话缓存

用户 -> 前端页面 : 输入账号密码并提交
前端页面 -> 网关接口 : POST /login
网关接口 -> 认证服务 :

C4-style Container Diagram Example#

@startuml
!includeurl https://raw.githubusercontent.com/plantuml-stdlib/C4-PlantUML/master/C4_Container.puml

Person(user, "博客访客", "阅读文章与搜索内容")

System_Boundary(system, "Firefly Blog") {
	Container(we

Support & Share

If this article helped you, please share or support!

Sponsor
Markdown PlantUML Diagrams
https://docs.bingyun.vip/en/posts/markdown-plantuml/
Author
BingYun
Published at
1970-01-04
Profile Image of the Author
BingYun
Hello, I'm BingYun
Tags
Table of Contents