Skip to content

Mermaid ADR approval and site implementation - #834

Merged
MGibson1 merged 13 commits into
mainfrom
arch/adr/documentation-standards
Jul 23, 2026
Merged

Mermaid ADR approval and site implementation#834
MGibson1 merged 13 commits into
mainfrom
arch/adr/documentation-standards

Conversation

@MGibson1

@MGibson1 MGibson1 commented Jul 20, 2026

Copy link
Copy Markdown
Member

📔 Objective

Adopts a Bitwarden-wide diagram standard: Mermaid source in Markdown, one diagram per audience/intent/scope, sources living beside the docs they illustrate.

Motivation (from ADR 0033 in this PR):

  • Architecture diagrams are scattered across tools and formats — Draw.io XML, Lucidchart embeds, ad hoc Mermaid, images committed without source. The same system is drawn differently in different places, there is no mechanism to keep representations consistent, and diagrams rot because nothing connects them to the systems they describe.
  • AppSec's Engagement Model needs system representations that today are rebuilt from scratch per review.
  • The Structurizr PoC was deprioritized: SecOps flagged its maintenance posture and missing compliance documentation, hosting a separate platform added operational overhead, and the one-model-many-views promise required substantial rework per audience in practice.

What this PR contains:

  1. The living diagram standard ADR 0033 (Standardize technical diagrams at Bitwarden #835) points to.
  2. Docusaurus wiring for the Mermaid theme (with an icon pack) and removal of the Kroki plugin.
  3. Direct-translation conversion of existing PlantUML/Kroki diagrams to Mermaid across the contributing site.
  4. A simplified EDD state-machine diagram, replacing the JPG asset (and the associated .drawio / .png / .gif files) with inline Mermaid.

Suggested Review Guidelines

This is a big PR, I know. Please read the ADR and Diagram Standard carefully. They're concise and important. Everything else is updating diagrams to comply with these standards (with the exception writing perspectives).

Use the below link table to review diagram updates for accuracy. Meaningful changes have been made to EDD and push notifications, please give those added attention.

📸 Screenshots

Old vs. new for each converted or adjusted page.

Diagrams New (preview) Original (production)
Clients — data model (1) preview prod
Clients — overview / State Service (1) preview prod
Clients — package diagram (1) preview prod
Clients — service implementation (4) preview prod
SDK — architecture overview (1) preview prod
SDK — crate structure (1) preview prod
SDK — data models (1) preview prod
SDK — Secrets Manager (1) preview prod
Deep dive — IPC (4) preview prod
Deep dive — passkeys FIDO2 overview (1) preview prod
Deep dive — passkeys browser extension (1) preview prod
Deep dive — push notifications, mobile (4) preview prod
Deep dive — push notifications, non-mobile (2) preview prod
Deep dive — autofill messaging API (1) preview prod
Deep dive — autofill collect page details (6) preview prod
Contributing — Angular component diagrams (2) preview prod
Contributing — EDD refactoring phases (1, redrawn) preview prod
Diagram standard — example perspective diagram (1, new page) preview — (new page)

@github-actions github-actions Bot added the adr label Jul 20, 2026

@withinfocus withinfocus left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's split the ADR and plan from the application.

Comment thread docs/architecture/adr/0033-adopt-the-diagram-standard.md Outdated
Comment thread docs/architecture/adr/0033-adopt-the-diagram-standard.md Outdated
@MGibson1
MGibson1 marked this pull request as ready for review July 20, 2026 19:17
@MGibson1
MGibson1 requested review from a team as code owners July 20, 2026 19:17
@github-actions

github-actions Bot commented Jul 20, 2026

Copy link
Copy Markdown
Contributor

🤖 Bitwarden Claude Code Review

Overall Assessment: APPROVE

Reviewed the Mermaid diagram-standard adoption: ADR 0033 acceptance, the new Contributing › Diagrams standard page, Docusaurus wiring (theme-mermaid, ELK layout, an inline bw icon pack), removal of the Kroki plugin, and the bulk conversion of PlantUML/Kroki diagrams to Mermaid across the site. Verified the substantive content changes (EDD state machine, batched backfill script, and push-notification sequences) for correctness and confirmed the Kroki removal is complete with no orphaned references or code blocks.

Code Review Details

No new findings. Notes on prior review threads (already resolved by the author):

  • The infinite-loop risk in the EDD transition backfill is fixed — the batched WHILE loop now guards with WHERE email IS NULL AND username IS NOT NULL.
  • The orphaned types/remark-kroki.d.ts shim was removed, and docusaurus.config.js no longer references remark-kroki.
  • AppSec review for the new @docusaurus/theme-mermaid and @mermaid-js/layout-elk dependencies was confirmed by a maintainer in an existing thread (reviewed, approved, no VULN task required).

Verified independently:

  • No remaining kroki type=plantuml / @startuml blocks in docs/, and no lingering remark-kroki/kroki references outside the lock file — the conversion and removal are complete.
  • package.json and package-lock.json are consistent; @mermaid-js/layout-elk is pinned to an exact 0.1.9.
  • The new docs/contributing/diagrams.md is picked up by the autogenerated contributing sidebar, so no sidebars.js change is needed.

Dependency Changes

Package Change Ecosystem
@docusaurus/theme-mermaid New (3.10.1) npm
@mermaid-js/layout-elk New (0.1.9) npm
remark-kroki Removed npm

@MGibson1

Copy link
Copy Markdown
Member Author

Let's split the ADR and plan from the application.

not sure what you mean by this. Are you saying to split the diagram updates from the ADR?

Comment thread docs/architecture/clients/services/implementation.md Outdated
@withinfocus

Copy link
Copy Markdown
Contributor

Let's split the ADR and plan from the application.

not sure what you mean by this. Are you saying to split the diagram updates from the ADR?

Yes. We want to merge the ADR in a Proposed status before Council.

@MGibson1
MGibson1 marked this pull request as draft July 20, 2026 20:19
@MGibson1
MGibson1 force-pushed the arch/adr/documentation-standards branch from 8b5e95b to 465befb Compare July 20, 2026 20:54
@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented Jul 20, 2026

Copy link
Copy Markdown

Deploying contributing-docs with  Cloudflare Pages  Cloudflare Pages

Latest commit: ff92bac
Status:⚡️  Build in progress...

View logs

@theMickster theMickster left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A couple improvements requested and one question. great start!

Comment thread package.json Outdated
Comment thread docs/architecture/adr/0033-adopt-mermaid-diagram-standard.md
Comment thread package.json
Comment thread docs/contributing/database-migrations/edd.mdx
Comment thread docs/architecture/clients/services/implementation.md Outdated
Comment thread docs/contributing/diagrams.md
MGibson1 added 4 commits July 22, 2026 07:38
This is a toy example where, presumably, `username` had a NOT NULL constraint as the real `email` column does, but this makes it explicit that these are concerns for these kinds of migrations.

@withinfocus withinfocus left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Still a draft technically, but saw a few tweaks.

Comment on lines +5 to +14
# Diagram standard

**Audience:** Bitwarden engineers, contributors, and AI agents authoring or reading diagrams
anywhere Bitwarden documents its systems.

## Notation

- The keywords MUST, MUST NOT, SHOULD, SHOULD NOT, and MAY are to be interpreted as described in
[RFC 2119](https://www.rfc-editor.org/rfc/rfc2119).

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⛏️ This is rather "official" to me and comes off as a bit too formal. It's a bit AI-like too, as if it's instructions with the all-caps language. We aren't writing a spec here as I see it.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The notation section also has a single bullet point that renders awkwardly.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Both of these things hint at an upcoming documentation standard I have drafted, but split this out of for speed.

Adopting a well known standard for communication is in line with our standards best practices, RFCs do this for a reason to be explicit about what is allowed or required. This phrasing is basically the same as the RFC it references.

Removing the single bullet feels fine, it's a holdover from when there were more and because the draft documentation standard does have multiple

sidebar_position: 2
---

# Diagram standard

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🎨 I think this can just be "Diagrams".

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's called that because it's referenced as a standard in the ADR and I'd like it to be seen as one. things that go against this doc go against "the standard"

@MGibson1
MGibson1 marked this pull request as ready for review July 22, 2026 16:43
@MGibson1
MGibson1 requested a review from withinfocus July 22, 2026 20:05
@withinfocus withinfocus added the ai-review Request a Claude code review label Jul 22, 2026
Comment thread docs/architecture/adr/0033-adopt-mermaid-diagram-standard.md Outdated
Comment thread package.json
Comment on lines +37 to +39
"@docusaurus/theme-mermaid": "3.10.1",
"@mdx-js/react": "3.1.0",
"@mermaid-js/layout-elk": "0.1.9",

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

QUESTION: Was AppSec approval obtained for the new @docusaurus/theme-mermaid and @mermaid-js/layout-elk dependencies?

Context

These are net-new dependencies (replacing remark-kroki). Bitwarden's Dependency Review and Approval process asks that new dependencies go through AppSec review before integration, and the PR description does not reference a VULN task or approval. Both are first-party official packages (MIT-licensed per the lockfile), so this is likely low-risk — just confirming the process was followed or intentionally waived for this internal docs site.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ran this through a security review directly. Low risk on the two direct packages.

Direct packages (both green):

  • @docusaurus/theme-mermaid@3.10.1 — MIT, first-party Docusaurus org, version-locked to @docusaurus/core@3.10.1 already in the tree. No install scripts.
  • @mermaid-js/layout-elk@0.1.9 — MIT, official Mermaid-JS org. Note it's pre-1.0 (0.x), so API stability isn't guaranteed.

Licensing: layout-elk pulls in elkjs@0.9.3, which is EPL-2.0 (Eclipse Public License, weak copyleft), not MIT. For a docs site consuming the unmodified npm package at build time this is fine, but it's a different license class worth noting for the record.

The actual change is transitive: the two-line package.json diff drives +1151/-200 in the lockfile, nearly all of it mermaid@11.16.0 and its subtree (dompurify, katex, cytoscape, d3, marked, roughjs, uuid@14.0.1, and more). That subtree is the attack-surface change, not the two direct adds.

Vuln scan: no open Dependabot alert touches the new subtree. The one open uuid advisory (GHSA-w5hq-g745-h8pq, affects < 11.1.1) doesn't apply here, since mermaid resolves uuid@14.0.1.

Reviewed and approved. The direct packages are first-party and low-risk, the EPL-2.0 transitive is acceptable for build-time use on an internal docs site, and the new subtree carries no open advisories. No VULN task required for this one.

@withinfocus withinfocus left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One minor correction Claude found, but then I can approve.

Co-authored-by: claude[bot] <209825114+claude[bot]@users.noreply.github.com>
@MGibson1
MGibson1 requested a review from withinfocus July 22, 2026 22:57

@withinfocus withinfocus left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great change showing Mermaid usage!

@withinfocus withinfocus changed the title Arch/adr/documentation standards Mermaid ADR approval and site implementation Jul 23, 2026
@MGibson1
MGibson1 merged commit 386dcf4 into main Jul 23, 2026
9 of 10 checks passed
@MGibson1
MGibson1 deleted the arch/adr/documentation-standards branch July 23, 2026 21:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

adr ai-review Request a Claude code review

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants