คลังเทมเพลต PlantUML
รวม 30 โค้ดตัวอย่าง แบ่งหมวด คลิก “Copy” แล้วนำไปวางในเอดิเตอร์ได้ทันที
พื้นฐาน
10บล็อกพื้นฐานของ UML สำหรับเริ่มไว
sequence
@startuml title Sample Sequence actor User participant Browser participant Server User -> Browser: type diagram Browser -> Server: POST /render Server --> Browser: SVG/PNG note right: Hello PlantUML! @enduml
core
ลองเลย! →
sequence-alt
@startuml title Sequence with alt/else Alice -> Bob: request alt OK Bob --> Alice: 200 OK else Error Bob --> Alice: 400 Error end @enduml
core
ลองเลย! →
sequence-async
@startuml title Async Interaction actor Client participant API Client -> API ++ : fire & forget ... processing ... API --> Client -- : callback (optional) @enduml
core
ลองเลย! →
class
@startuml
title Sample Class
class User {
+id: int
+name: string
+login()
}
class Session {
+token: string
+expiresAt: DateTime
}
User "1" -- "0..*" Session : owns >
@enduml
core
ลองเลย! →
object
@startuml
title Object Diagram
object "User #1" as U1 {
id = 1
name = "Alice"
}
object "Session A" as S1 { token = "abc..." }
U1 -- S1 : has
@enduml
core
ลองเลย! →
package
@startuml
title Package Diagram
package "Core" { class A
class B }
package "Feature" { class C }
A --> B
B --> C
@enduml
core
ลองเลย! →
activity
@startuml title Sample Activity start :Input text; if (Valid?) then (yes) :Encode; :Render; else (no) :Show error; endif stop @enduml
core
ลองเลย! →
state
@startuml title Sample State [*] --> Editing Editing --> Preview : click Render Preview --> Editing : modify Preview --> [*] : export @enduml
core
ลองเลย! →
usecase
@startuml
title Sample Use Case
left to right direction
actor User
rectangle System {
usecase "Create Diagram" as UC1
usecase "Export PNG/SVG" as UC2
}
User --> UC1
User --> UC2
@enduml
core
ลองเลย! →
er
@startuml
title Sample ER Model
entity "User" as U {
* id : int <<PK>>
--
name : varchar
}
entity "Session" as S {
* token : varchar <<PK>>
--
user_id : int <<FK>>
}
U ||--o{ S : has
@enduml
core
ลองเลย! →
ขั้นสูง
8ซีเควนซ์ คอมโพเนนต์ และโฟลว์สำหรับระบบจริง
sequence-rest
@startuml title REST Request/Response participant Client participant API database DB Client -> API: GET /items API -> DB: SELECT * FROM items DB --> API: rows API --> Client: 200 OK (JSON) @enduml
advanced
ลองเลย! →
class-advanced
@startuml
title Advanced Class
interface AuthService
class JwtAuth implements AuthService
class Repository<T>
class UserRepo extends Repository<User>
class User { +id: int +email: string +login() }
AuthService <|.. JwtAuth
Repository <|-- UserRepo
UserRepo --> User
@enduml
advanced
ลองเลย! →
activity-swimlane
@startuml title Activity with Swimlanes |User| start :Fill form; |System| :Validate; if (OK?) then (yes) |User| :Confirm; else (no) |System| :Show error; endif stop @enduml
advanced
ลองเลย! →
component-interfaces
@startuml title Component with Interface interface "HTTP" as IHTTP component "Web UI" as UI component "API" as API UI - IHTTP IHTTP - API @enduml
advanced
ลองเลย! →
deployment
@startuml
title Deployment Diagram
node "Client" { artifact "Browser" }
node "Server" {
component "Web"
component "API"
}
"Browser" --> "Web"
"Web" --> "API"
@enduml
advanced
ลองเลย! →
state-nested
@startuml
title Nested State
[*] --> Auth
state Auth {
[*] --> Login
Login --> TwoFA : success
TwoFA --> [*] : ok
}
Auth --> Dashboard
Dashboard --> [*]
@enduml
advanced
ลองเลย! →
timing
@startuml title Timing Diagram robust "Client" as C robust "Server" as S @0 C is Idle S is Idle @10 C is Sending @20 S is Processing @30 C is Idle S is Idle @enduml
advanced
ลองเลย! →
communication
@startuml title Communication object Client object Service object Cache Client -> Service : request Service -> Cache : get(key) Cache --> Service : value/miss Service --> Client : response @enduml
advanced
ลองเลย! →
การจัดการโครงการ/เอกสาร
6Mindmap, WBS, Gantt และ mockup UI สำหรับงานเอกสาร
mindmap
@startmindmap * Project ** Backend *** API *** Database ** Frontend *** Web *** Mobile @endmindmap
pm
ลองเลย! →
wbs
@startwbs * Launch ** Design *** UX *** UI ** Build *** Backend *** Frontend ** QA *** Unit *** E2E @endwbs
pm
ลองเลย! →
gantt
@startgantt Project starts 2025-09-01 [Design] lasts 5 days [Build] starts at [Design]'s end and lasts 10 days [Test] starts at [Build]'s end and lasts 4 days @endgantt
pm
ลองเลย! →
salt-login
@startsalt
{+
"Login"
Username | [__________]
Password | [__________]
{ "" | [ Login ] }
}
@endsalt
pm
ลองเลย! →
json
@startjson
{
"user": {
"id": 1,
"name": "Alice",
"roles": ["admin","editor"]
}
}
@endjson
pm
ลองเลย! →
โครงสร้างพื้นฐาน
3คลาวด์, C4 แบบย่อ และคิว/เวิร์กเกอร์
deployment-cloud
@startuml
title Cloud Deployment
node "Client" { artifact "Browser" }
cloud "Internet"
node "Kubernetes" {
node "Pod" {
artifact "web"
artifact "api"
}
}
"Browser" --> "Internet"
"Internet" --> "web"
"web" --> "api"
@enduml
devops
ลองเลย! →
c4-container-lite
@startuml title C4 Container (Lite) ' https://c4model.com (simplified) Person(user, "User") Container(web, "Web App", "Next.js") Container(api, "API", "Node.js") ContainerDb(db, "DB", "PostgreSQL") Rel(user, web, "Uses") Rel(web, api, "HTTP") Rel(api, db, "SQL") @enduml
devops
ลองเลย! →
queue-worker
@startuml title Queue & Worker actor Producer queue "Job Queue" as Q participant Worker Producer -> Q ++ : enqueue(job) Q --> Worker : job Worker --> Producer : result @enduml
devops
ลองเลย! →
ข้อมูล/อินทิเกรชัน
3ETL, sharding และสถาปัตยกรรม event-driven
db-sharding
@startuml title DB Sharding database "Router" as R database "Shard A" as A database "Shard B" as B R --> A : key in range A R --> B : key in range B @enduml
data
ลองเลย! →
etl-pipeline
@startuml title ETL Pipeline rectangle Extract rectangle Transform database Load as L Extract --> Transform Transform --> L : upsert @enduml
data
ลองเลย! →
event-driven
@startuml title Event-driven actor Producer queue "Kafka Topic" as T participant Consumer Producer -> T ++ : publish(event) T --> Consumer : consume @enduml
data
ลองเลย! →