For AI agents: the complete documentation index is available at https://lazygophers.github.io/pamphlet/llms.txt, the full documentation bundle is available at https://lazygophers.github.io/pamphlet/llms-full.txt, and this page is available as Markdown at https://lazygophers.github.io/pamphlet/write/diagrams/c4.md.
  • 简体中文
  • 系统上下文图(C4)

    这是什么

    站在最外面看:谁在用这个系统,这个系统又依赖谁。C4 模型的第一层。

    什么时候用

    给不懂技术的人讲「这东西在整个链条里的位置」。

    怎么写

    Pamphlet 自己的写法——先列声明、再列关系,十七种图共用这副骨架:

    :::c4[谁在用 Pamphlet]
    actors:
      author = person "作者"
      pf = system "Pamphlet"
      reader = external "读者的浏览器"
    relations:
      author -> pf : pamphlet build
      pf -> reader : 一个自包含的 HTML
    :::

    这种写法在 GitHub 上不会渲染。要 GitHub 也能看,用系统上下文图的 Mermaid 围栏写法,画出来是同一张图。

    出来是什么样

    编译时就画成 SVG 内联进产物,读者那边不下载任何绘图库、也不联网。颜色跟着主题走,可以滚轮缩放、按住拖动、双击复位。

    坑

    • 块名固定是 actors: 和 relations:
    • 角色类型只有三个:person(人)/ system(自家系统)/ external(外部系统),写别的报 DIAG-307
    • 关系写 甲 -> 乙 : 做什么
    • 只到 C4Context 这一层;更细的 C4Container / C4Component 用 Mermaid 围栏