跳转到主要内容
Chinese, Simplified

对思维导图感兴趣 — 阅读我们关于使用 plantUML 和 ChatGPT 创建很棒的思维导图的博文

继续我之前的帖子,我想专注于 C4 图表模型。 为了不让 ChatGPT 偏离初衷,我从下面的提示开始

提示:展望未来,我希望你充当软件架构师并使用 mermaid.js 构建 C4 图。 保留降价语法的答案,并始终牢记软件功能和非功能方面,包括但不限于可伸缩性、可用性、冗余、容器化、安全性和灾难恢复。
ChatGPT:当然,作为一名软件架构师,我可以帮助您使用 Mermaid.js 创建 C4 图,这些图考虑了功能和非功能方面,例如可扩展性、可用性、冗余、容器化、安全性和灾难恢复。

C4图是表示软件系统架构的一种方式,分为四个主要层次:

  • 上下文级别(Context level),表示与系统交互的外部因素
  • 容器级别(Container level),表示部署单元及其依赖项
  • 组件级别(Component level),代表系统的不同组件
  • 代码层级(Code level),代表了系统的实现细节

好的,让我们开始吧

上下文图(The Context Diagram)

Prompt: Let’s start by creating a context diagram of the services in Wealth Management
ChatGPT: Sure, here’s an example of a context diagram in Mermaid format for a Wealth Management System:

Archietcture

 

在markdown 编辑器中

archietcture

context diagram

此图显示了与财富管理系统交互的主要参与者以及系统提供的主要服务。

  • 用户与账户管理服务、投资组合管理服务、资产管理服务和交易管理服务交互。
  • 金融机构还与账户管理服务、投资组合管理服务、资产管理服务和交易管理服务交互。
  • 市场与市场数据服务交互。
  • 此图概述了参与者和服务之间的主要交互,它可能有助于理解系统的高级架构。

容器图(The Container Diagram)


到目前为止看起来不错。 接下来,让我们为其中一个服务构建一个容器级别的图表

Prompt: Let’s take the Portfolio service and break it down by creating a container diagram for its sub-functionalities
ChatGPT: Sure, here’s an example of a container diagram in Mermaid format for the Portfolio Management Service of a Wealth Management System:

Archietcture

Container diagram

and markdown diagram

Archietcture

此图显示了组成投资组合管理服务的容器及其依赖项。

  • Portfolio Management API 是用户和其他系统与服务交互的入口点。
  • 投资组合管理工作者负责执行后台任务,例如根据市场变化更新投资组合。
  • 投资组合管理数据库存储与投资组合相关的数据,如每个投资组合中持有的资产、它们的当前价值等。
  • 负载均衡器在 Kubernetes 集群中运行的投资组合管理 API 实例之间分配传入流量。
  • Kubernetes 集群负责管理容器的扩展、可用性和部署。

组件图(The Component Diagram)

Prompt: Next lets create the component level diagram for portfolio management api with all relevant details
ChatGPT: Here’s an example of a component diagram in Mermaid format for the Portfolio Management API

Archietcture

and the corresponding mermaid diagram

ArchietctureComponent diagram for Portfolio Management API

这是描述

此图显示了构成 Portfolio Management API 的不同组件及其依赖关系。

  • 投资组合管理 API 的 API 网关组件是传入请求的入口点。
  • 身份验证组件负责对用户进行身份验证。
  • 授权组件负责检查用户的访问权限。
  • Request Validator 组件负责验证传入的请求。
  • 业务逻辑组件负责处理请求和执行业务逻辑。
  • Response Formatter 组件负责在将响应发送回客户端之前格式化响应。
  • 投资组合服务组件负责执行与投资组合管理相关的操作,如创建、读取、更新和删除投资组合,并与投资组合管理数据库通信以保存与投资组合相关的数据。

这看起来棒极了。 大多数细节与我的理解一致。 让我们尝试为 Portfolio Management Worker 构建相同的

Prompt: can we do the same for portfolio management worker container
ChatGPT: Sure, here’s an example of a component diagram in Mermaid format for the Portfolio Management Worker container of a Wealth Management System:

Archietcture

and the mermaid diagram

Archietcture

Component Diagram for PM Worker

此图显示了构成 Portfolio Management Worker 容器的组件及其依赖项。

  • Task Scheduler 组件负责安排更新公文包的后台任务。
  • 投资组合更新器组件负责根据市场变化更新投资组合,它与市场数据服务通信以获取最新的市场数据。
  • 市场数据服务组件负责为投资组合更新程序提供市场数据。
  • 投资组合服务组件负责执行与投资组合管理相关的操作,如创建、读取、更新和删除投资组合,并与投资组合管理数据库通信以持久保存与投资组合相关的数据。

代码图(The Code Diagram)


让我们做最后一点,并为 Portfolio Management API 创建代码图

Prompt: Can you also do the code diagram for Portfolio Management API
ChatGPT: Sure, here’s an example of a code diagram in Mermaid format for the Portfolio Management API of a Wealth Management System:

Archietcture

但是,当我尝试使用 Mermaid.js 在markdown 编辑器中创建它时,它无法指示循环依赖性。 我们在这里需要做的就是删除这些,如下所述

Archietcture

Corrected Code Graph

and the mermaid diagram

Archietcture

Portfolio Management API code packages

此图显示了构成 Portfolio Management API 的不同包及其依赖项。

  • api 包是应用程序的入口点,它定义了路由和中间件。
  • auth 包负责请求的认证和授权。
  • 配置包负责加载配置文件。
  • 控制器包负责处理请求和调用服务。
  • errors 包定义自定义错误。
  • 中间件包负责为处理 CORS、请求验证等请求提供中间件。
  • 模型包定义了数据库实体的 ORM 模型。
  • 服务包负责执行业务逻辑并与数据库通信。
  • utils 包提供实用功能

太棒了,这是一篇描述 ChatGPT 功能的博客文章,尤其是在 C4 图表模型上。

谢谢阅读!

原文地址
https://aruva.medium.com/using-chatgpt-to-build-system-diagrams-part-ii-a17d02f0dcb7
本文地址
Article

微信

知识星球

微信公众号

视频号