Skip to content

Commit c947a36

Browse files
committed
add diagrams
1 parent 30afb2b commit c947a36

File tree

13 files changed

+282
-0
lines changed

13 files changed

+282
-0
lines changed

docs/architecture-as-code/README.md

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
# jianmu-architecture-as-code
2+
3+
#### 介绍
4+
建木架构即代码(architecture as code)
5+
6+
#### 使用说明
7+
8+
本项目使用[Structurizr DSL](https://github.com/structurizr/dsl) 的Cli工具来生成C4 Model的架构图
9+
10+
该工具可以输出为PlantUML格式文件
11+
12+
Mac环境下可以使用Homebrew安装该工具
13+
14+
```
15+
brew install structurizr-cli
16+
```
17+
18+
安装完成后,可以使用以下命令来生成.puml文件到c4文件夹下
19+
20+
```
21+
structurizr-cli export -workspace jianmu.dsl -format plantuml -output c4
22+
```
23+
24+
#### 生成效果
25+
26+
*建木容器图*
27+
![容器图](out/c4/structurizr-jianmu-container/structurizr-jianmu-container.png)
28+
29+
*主服务内部组件图*
30+
![组件图](out/c4/structurizr-web-component/structurizr-web-component.png)
31+
32+
*执行器组件图*
33+
![执行器组件图](out/c4/structurizr-worker-component/structurizr-worker-component.png)
34+
35+
*服务部署图*
36+
![部署图](out/c4/structurizr-DevelopmentDeployment/structurizr-DevelopmentDeployment.png)
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
@startuml
2+
title 建木自动化集成平台 - Deployment - dev
3+
4+
!includeurl https://raw.githubusercontent.com/plantuml-stdlib/C4-PlantUML/master/C4.puml
5+
!includeurl https://raw.githubusercontent.com/plantuml-stdlib/C4-PlantUML/master/C4_Context.puml
6+
!includeurl https://raw.githubusercontent.com/plantuml-stdlib/C4-PlantUML/master/C4_Container.puml
7+
!includeurl https://raw.githubusercontent.com/plantuml-stdlib/C4-PlantUML/master/C4_Deployment.puml
8+
LAYOUT_WITH_LEGEND()
9+
10+
Deployment_Node(55, "Docker Container - Worker Server", "Docker") {
11+
Deployment_Node(56, "Worker Server", "Golang") {
12+
Container(57, "docker-worker", "容器化执行环境")
13+
}
14+
15+
}
16+
17+
Deployment_Node(45, "Web Browser", "Chrome, Firefox, Safari, or Edge") {
18+
Container(46, "SPA单页面应用", "TypeScript and Vue 3.0", "Provides all of the Jianmu functionality to customers via their web browser.")
19+
}
20+
21+
Deployment_Node(47, "Docker Container - Web Server", "Docker") {
22+
Deployment_Node(48, "Spring boot", "Spring boot 2.x") {
23+
Container(49, "主服务", "主服务")
24+
}
25+
26+
}
27+
28+
Deployment_Node(51, "Docker Container - Database Server", "Docker") {
29+
Deployment_Node(52, "Database Server", "Mysql 8.0") {
30+
Container(53, "数据库", "Mysql 8.0")
31+
}
32+
33+
}
34+
35+
Rel_D(46, 49, "启动流程或任务", "Rest API")
36+
Rel_D(49, 53, "读写数据", "JDBC/SSL")
37+
Rel_D(57, 49, "获取任务执行", "http/https")
38+
@enduml
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
@startuml
2+
title 建木自动化集成平台 - Containers
3+
4+
!includeurl https://raw.githubusercontent.com/plantuml-stdlib/C4-PlantUML/master/C4.puml
5+
!includeurl https://raw.githubusercontent.com/plantuml-stdlib/C4-PlantUML/master/C4_Context.puml
6+
!includeurl https://raw.githubusercontent.com/plantuml-stdlib/C4-PlantUML/master/C4_Container.puml
7+
LAYOUT_WITH_LEGEND()
8+
9+
Person(1, "用户", "泛指用户")
10+
11+
System_Boundary("2_boundary", "建木自动化集成平台") {
12+
Container(11, "数据库", "Mysql 8.0")
13+
Container(12, "docker-worker", "容器化执行环境")
14+
Container(16, "shell-worker", "非容器化执行环境")
15+
Container(3, "SPA单页面应用", "TypeScript and Vue 3.0", "Provides all of the Jianmu functionality to customers via their web browser.")
16+
Container(4, "主服务", "主服务")
17+
}
18+
19+
Rel_D(1, 3, "操作或查看流程与任务", "Rest API")
20+
Rel_D(4, 11, "读写数据", "JDBC/SSL")
21+
Rel_D(12, 4, "获取任务执行", "http/https")
22+
Rel_D(16, 4, "获取任务执行", "http/https")
23+
Rel_D(3, 4, "启动流程或任务", "Rest API")
24+
@enduml
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
@startuml
2+
title 建木自动化集成平台 - 主服务 - Components
3+
4+
!includeurl https://raw.githubusercontent.com/plantuml-stdlib/C4-PlantUML/master/C4.puml
5+
!includeurl https://raw.githubusercontent.com/plantuml-stdlib/C4-PlantUML/master/C4_Context.puml
6+
!includeurl https://raw.githubusercontent.com/plantuml-stdlib/C4-PlantUML/master/C4_Container.puml
7+
!includeurl https://raw.githubusercontent.com/plantuml-stdlib/C4-PlantUML/master/C4_Component.puml
8+
LAYOUT_WITH_LEGEND()
9+
10+
Container(3, "SPA单页面应用", "TypeScript and Vue 3.0", "Provides all of the Jianmu functionality to customers via their web browser.")
11+
12+
Container_Boundary("4_boundary", "主服务") {
13+
Component(10, "参数管理", "参数上下文")
14+
Component(5, "DSL解析器", "DSL语法解析器")
15+
Component(6, "触发器", "触发器上下文")
16+
Component(7, "流程流转", "流程上下文")
17+
Component(8, "el引擎", "表达式引擎")
18+
Component(9, "任务分发", "任务上下文")
19+
}
20+
21+
Rel_D(3, 6, "启动流程或任务", "Rest API")
22+
Rel_D(3, 5, "提交DSL定义", "Rest API")
23+
Rel_D(5, 7, "保存流程定义", "Java API")
24+
Rel_D(6, 7, "触发流程启动", "Java API")
25+
Rel_D(6, 9, "直接触发任务启动", "Java API")
26+
Rel_D(7, 9, "任务节点激活事件触发任务启动", "Java API")
27+
Rel_D(7, 9, "任务节点中止事件触发任务中止", "Java API")
28+
Rel_D(7, 8, "执行表达式", "Java API")
29+
Rel_D(8, 7, "返回表达式结果", "Java API")
30+
Rel_D(9, 7, "返回任务执行状态", "Java API")
31+
Rel_D(7, 10, "读取参数信息", "Java API")
32+
Rel_D(7, 10, "流程执行结果参数写入", "Java API")
33+
Rel_D(9, 10, "读取参数信息", "Java API")
34+
Rel_D(9, 10, "任务执行结果参数写入", "Java API")
35+
@enduml
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
@startuml
2+
title 建木自动化集成平台 - docker-worker - Components
3+
4+
!includeurl https://raw.githubusercontent.com/plantuml-stdlib/C4-PlantUML/master/C4.puml
5+
!includeurl https://raw.githubusercontent.com/plantuml-stdlib/C4-PlantUML/master/C4_Context.puml
6+
!includeurl https://raw.githubusercontent.com/plantuml-stdlib/C4-PlantUML/master/C4_Container.puml
7+
!includeurl https://raw.githubusercontent.com/plantuml-stdlib/C4-PlantUML/master/C4_Component.puml
8+
LAYOUT_WITH_LEGEND()
9+
10+
Container(4, "主服务", "主服务")
11+
12+
Container_Boundary("12_boundary", "docker-worker") {
13+
Component(13, "daemon", "worker守护容器")
14+
Component(14, "代码编译", "任务运行容器")
15+
Component(15, "Ansible执行", "任务运行容器")
16+
}
17+
18+
Rel_D(13, 4, "获取任务执行", "http/https")
19+
Rel_D(13, 4, "返回执行结果", "http/https")
20+
Rel_D(13, 14, "启动容器", "Docker API")
21+
Rel_D(13, 15, "启动容器", "Docker API")
22+
@enduml
Loading
Loading

docs/architecture-as-code/jianmu.dsl

Lines changed: 93 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,93 @@
1+
workspace "Jianmu" "建木自动化集成平台" {
2+
model {
3+
user = person "用户" "泛指用户"
4+
jianmu = softwareSystem "建木自动化集成平台" "建木自动化集成平台" {
5+
singlePageApplication = container "SPA单页面应用" "Provides all of the Jianmu functionality to customers via their web browser." "TypeScript and Vue 3.0" "Web Browser"
6+
web = container "主服务" "主服务" {
7+
dsl = component "DSL解析器" "DSL语法解析器"
8+
trigger = component "触发器" "触发器上下文"
9+
workflow = component "流程流转" "流程上下文"
10+
el = component "el引擎" "表达式引擎"
11+
task = component "任务分发" "任务上下文"
12+
parameter = component "参数管理" "参数上下文"
13+
}
14+
database = container "数据库" "Mysql 8.0"
15+
worker1 = container "docker-worker" "容器化执行环境" {
16+
daemon = component "daemon" "worker守护容器"
17+
runner1 = component "代码编译" "任务运行容器"
18+
runner2 = component "Ansible执行" "任务运行容器"
19+
}
20+
worker2 = container "shell-worker" "非容器化执行环境" {
21+
daemon_process = component "daemon-process" "worker守护进程"
22+
runner_process = component "runner-process" "任务运行进程"
23+
}
24+
}
25+
# 容器之间关联关系
26+
user -> singlePageApplication "操作或查看流程与任务" "Rest API"
27+
web -> database "读写数据" "JDBC/SSL"
28+
daemon -> web "获取任务执行" "http/https"
29+
daemon_process -> web "获取任务执行" "http/https"
30+
daemon -> web "返回执行结果" "http/https"
31+
daemon_process -> web "返回执行结果" "http/https"
32+
33+
# worker内部组件关系
34+
daemon -> runner1 "启动容器" "Docker API"
35+
daemon -> runner2 "启动容器" "Docker API"
36+
37+
# 主服务内部组件关系
38+
singlePageApplication -> trigger "启动流程或任务" "Rest API"
39+
singlePageApplication -> dsl "提交DSL定义" "Rest API"
40+
dsl -> workflow "保存流程定义" "Java API"
41+
trigger -> workflow "触发流程启动" "Java API"
42+
trigger -> task "直接触发任务启动" "Java API"
43+
workflow -> task "任务节点激活事件触发任务启动" "Java API"
44+
workflow -> task "任务节点中止事件触发任务中止" "Java API"
45+
workflow -> el "执行表达式" "Java API"
46+
el -> workflow "返回表达式结果" "Java API"
47+
task -> workflow "返回任务执行状态" "Java API"
48+
workflow -> parameter "读取参数信息" "Java API"
49+
workflow -> parameter "流程执行结果参数写入" "Java API"
50+
task -> parameter "读取参数信息" "Java API"
51+
task -> parameter "任务执行结果参数写入" "Java API"
52+
53+
deploymentEnvironment "dev" {
54+
deploymentNode "Web Browser" "" "Chrome, Firefox, Safari, or Edge" {
55+
developerSinglePageApplicationInstance = containerInstance singlePageApplication
56+
}
57+
deploymentNode "Docker Container - Web Server" "" "Docker" {
58+
deploymentNode "Spring boot" "" "Spring boot 2.x" {
59+
developerWebApplicationInstance = containerInstance web
60+
}
61+
}
62+
deploymentNode "Docker Container - Database Server" "" "Docker" {
63+
deploymentNode "Database Server" "" "Mysql 8.0" {
64+
developerDatabaseInstance = containerInstance database
65+
}
66+
}
67+
deploymentNode "Docker Container - Worker Server" "" "Docker" {
68+
deploymentNode "Worker Server" "" "Golang" {
69+
developerWorkerInstance = containerInstance worker1
70+
}
71+
}
72+
}
73+
}
74+
75+
views {
76+
container jianmu "jianmu-container" "建木容器图" {
77+
include *
78+
autoLayout
79+
}
80+
component web "web-component" "主服务组件图" {
81+
include *
82+
autoLayout lr 400
83+
}
84+
component worker1 "worker-component" "执行器组件图" {
85+
include *
86+
autoLayout lr
87+
}
88+
deployment jianmu "dev" "DevelopmentDeployment" {
89+
include *
90+
autoLayout
91+
}
92+
}
93+
}

0 commit comments

Comments
 (0)