background
FIG Status: the status of all objects, events, and process based on the state of change;
activity diagram: Example of a workflow;
deployment diagram: the physical architecture of the hardware and software system;
State diagram
The basic syntax
element | grammar | Explanation |
---|---|---|
Start and end states | [*] | Identify the start and end state |
arrow | --> | Add arrows |
Hide description area | hide empty description | Hide description area |
Synthesis of state | state-synthesized state names {} syntax definition zengcheng | FIG state can be nested |
State declaration | state state name: Remarks | Declare state |
fork,join | state state name
|
Separately, the combined state |
Concurrent state | - or or double pipe | The state is complicated by changes |
Direction arrow | top down left right | You can control the direction of the arrow |
Single-line comments | note bearing the name of the state: single-line comments | Single-line comments |
Multi-line comments | note the orientation state of Wrap name End note wrap a single line comment | Multi-line comments |
Log in state diagram
@startuml
hide empty description
left to right direction
[*]-->NotLogin:首次打开app
state NotLogin: 没有登录
state LoginSuccess: 登录成功
state LoginFail: 登录失败
NotLogin -->LoginSuccess: 登录
NotLogin -->LoginFail:登录
state LoginFail {
state 用户不存在: ta校验
state saas注册失败:注册saas
state 登记用户信息失败: 登记到tiananUser
state 参数校验失败 :校验参数
}
state join_state <<join>>
LoginSuccess-->join_state:组装响应参数
LoginFail-->join_state:组装响应参数
join_state -->[*]:返回JSON数据到客户端
@enduml
Integral state diagram
@startuml
scale 350 width
left to right direction
hide empty description
state noPointRecord : 没有积分记录
state pointZero : 积分为0
state pointOk : 有积分
[*] --> noPointRecord: 增加积分
noPointRecord --> pointZero: 初始化
pointZero --> pointOk: 增加/消耗积分
pointOk --> [*]
@enduml
Activity Diagram
The basic syntax
element | grammar | Explanation |
---|---|---|
start end | start stop | Start End Activities |
activity | :Event name; | Defining activities |
Conditional statements | if (condition?) then (yes) under wraps activity else (no) endif | Conditional branch |
loop statement | repeat Wrap activities wrap repeatwhile (conditions?) | Performed first and then judge |
loop statement | while (the establishment of conditions?) Wrap activities wrap endwhile (not true condition Miao Xu) | First condition determination cycle |
Shape change activities | : Activities> <]} / vertical | Respectively different shapes |
Parallel Processing | fork fork again end fork | Parallel Processing |
combination | FIG active partition group name syntax {} | Group activities |
Lanes | Surrounded by two vertical lines | Lanes |
Separate | detach | Remove arrow |
Log in activity diagram
@startuml
header 登录接口活动图
footer 登录接口活动图
|tomcat|
start
:参数校验]
if (参数校验通过 ?) then (yes)
elseif (字符串为空) then (no)
stop
else (其它校验错误)
stop
endif
|TA服务端|
:用户code远程校验;
|LX Saas|
:saas注册登录;
|mysql|
:登记到saasUser;
|redis|
:保存令牌到Redis;
|tomcat|
:组装响应参数;
stop
@enduml
Increased integration activity diagram
@startuml
header 改变用户积分接口活动图
footer 改变用户积分接口活动图
|tomcat|
start
:登录态检查;
if(令牌非法 ?) then (yes)
:返回未登录;
stop
else (合法)
endif
:接受参数,point , event ;
if(参数检查 ?) then(合法)
else(非法)
:返回参数错误;
stop
endif
|mysql|
:插入积分增加详细纪录;
|tomcat|
:得到记录Id;
|redis|
:按照userId查询得到用户积分的表记录Id;
|tomcat|
if(记录id不存在 ?)then(yes)
|mysql|
:插入用户的积分记录得到id;
:更新用户的总积分;
else(id存在)
:更新用户的总积分;
endif
|redis|
:删除用户总积分的缓存;
:删除用户积分总条数的缓存;
:删除用户积分明细分页记录的缓存;
|tomcat|
:得到明细记录的id,返回;
:返回客户端;
stop
@enduml
Query integral activity diagram
@startuml
|tomcat|
start
#gold:接受参数,pageNum,pageSize|
:参数校验;
if (参数校验通过 ?) then(通过)
else (不通过)
#red:报错 401 X 参数校验不通过;
stop
endif
|redis|
:从Redis缓存中查询得到记录的总数]
|tomcat|
if(总数不存在)then (不存在)
|mysql|
:从数据库中查询得到积分详细纪录的总数;
|redis|
:设置到redis缓存中;
else
endif
|tomcat|
:得到纪录的总条数;
if(总数是否大于0 ?)then
-[#red]->总数大于0;
fork
|redis|
:从Redis缓存分页查询得到列表;
|tomcat|
if (redis中获取不到数据 ?) then( 获取不到)
|mysql|
:从数据库中获取得到列表;
|redis|
:设置到redis缓存中;
else (获取到了)
endif
|tomcat|
:得到分页查询的列表;
fork again
|redis|
:从Redis缓存中查询得到用户总积分;
|tomcat|
if (redis中获取不到数据 ?) then( 获取不到)
|mysql|
:从数据库中获取得到用户总积分;
|redis|
:设置到redis缓存中;
else (获取到了)
endif
|tomcat|
:得到用户总积分;
end fork
else
|tomcat|
-[#green]->总数等于0;
#green:分页列表为空;
#green:总积分为0;
endif
|tomcat|
:组装响应参数\n分页列表数据\n用户总积分;
stop;
@enduml
Deployment diagrams
FIG deployment shows the hardware and software installed on the system hardware, and middleware for the connection between heterogeneous computers. The deployment diagram is generally considered a network diagram or physical architecture diagram.
grammar
element | grammar | Explanation |
---|---|---|
Roles | actor TaUser as taUser | Affirming a role |
proxy | agent agent | Declare a proxy |
Package | artifact artifact | Declare a package |
boundary myBoundary | ||
card card | ||
cloud | cloud cloud | It represents a private or public cloud |
component myComponent | ||
control myControl | ||
database | database mydatabase | It represents the database |
entity entity | ||
file | file file | It represents a file server |
folder folder | ||
frame frame | ||
interface interface | ||
node | node node | It represents a physical structure |
package package | ||
queue | queue queue | message queue |
Stack | stack stack | |
rectangle rectangle | ||
storage | storage storage | |
usecase usercase | ||
Callout text | [Text Memo] | Remarks on the text components |
Connection and arrow | -- .. == --> | Connecting two elements |
package | Element name} {affirm element syntax | Inclusion relation |
Deployment diagram
@startuml
header TA项目物理架构图
footer TA项目物理架构图
left to right direction
actor TaUser as taUser
node TaApp as taApp {
agent LxSDK as lxsdk
agent TaClient as taClient
}
folder tiananuser_folder{
cloud tiananuserCluster
node tomcat1_tiananuser
node tomcat2_tiananuser
node tomcat3_tiananuser
tiananuserCluster -down-> tomcat1_tiananuser
tiananuserCluster -down-> tomcat2_tiananuser
tiananuserCluster -down-> tomcat3_tiananuser
}
folder tianansp_folder{
cloud tiananspCluster
node tomcat1_tianansp
node tomcat2_tianansp
node tomcat3_tianansp
tiananspCluster -down-> tomcat1_tianansp
tiananspCluster -down-> tomcat2_tianansp
tiananspCluster -down-> tomcat3_tianansp
}
node Nginx as nginx
nginx --> tiananuserCluster:负载均衡/路由
nginx --> tiananspCluster:负载均衡/路由
taUser --> taApp : 访问
taApp --> nginx:http/https
database tiananuser_database[
用户登录数据库
]
database tianansp_database[
运营活动数据库
]
database redis[
redis缓存
]
tiananuser_folder -down-> tiananuser_database
tianansp_folder -right-> tianansp_database
tiananuser_folder -down-> redis
tianansp_folder -up-> redis
node zk [
zookeeper注册中心
dubbo的消费者跟生产者通信中间件
定时任务elasticjob的配置中间件
]
tiananuser_folder -down-> zk
tianansp_folder -up-> zk
node apollo [
apollo配置中心
]
queue kafka[
kafka集群
]
tiananuser_folder -down-> apollo
tianansp_folder -up-> apollo
tiananuser_folder -down-> kafka
tianansp_folder -up-> kafka
file fileCDN [
七牛云或者阿里云存储
]
tiananuser_folder -down-> fileCDN
tianansp_folder -up-> fileCDN
cloud ELK {
node elsticSearch
node filebeat
node kibana
}
node kubernetes{
node healmcharts[
交付服务
]
node harbor[
harbor监控管理kubernetes对象
]
}
tiananuser_folder -down-> ELK:日志写入
tianansp_folder -up-> ELK:日志写入
tiananuser_folder -down-> kubernetes:发布和管控docker节点
tianansp_folder -up-> kubernetes:发布和管控docker节点
@enduml
summary
- Activity diagram (Figure lane) is actually a sort of code flow, before coding recommendations, first painting activity diagram;
- State diagram include events for all state changes, to prevent miss out on some cases of change;
- Deployment diagram is actually a physical architecture diagram, drawing does not look good, but it can effectively guide the operation and maintenance at the time of on-line;
The original is not easy, please indicate the source.