See it as a diagram
Everything below, as a diagram you can edit. Describe yours and see it in seconds.
No account needed · Editable canvas, not a picture
Why the image works on GitHub and not on npm
On GitHub, a relative path like ./docs/architecture.png resolves against the repository at the branch you are viewing, so it just works. On npmjs.com the README arrives inside the tarball, detached from the repository, and the rewriting npm attempts points at the default branch named in the repository field. It misses often enough to have earned its own long-lived bug report: npm/marky-markdown issue 432, Relative links in markdown README not being rewritten on npmjs.org. Maintainers have been filing the same broken-image complaint against the registry ever since.
The failure is silent for the author, because the file being previewed locally and on GitHub is fine. It shows up only on the package page, which is the page most consumers actually read before installing.
Use an absolute https address for every image in a published README. That single rule removes the whole category, whether the target is a raw file in the repository or a rendered diagram endpoint.
<!-- Breaks on npmjs.com -->  <!-- Works, and stays current between releases --> 
The npm page is a photograph of your publish
The README shown on a package page comes from the version that was published. Editing README.md on the default branch changes the GitHub view immediately and the npm page not at all, until the next release. Package pages for older versions keep the README they shipped with.
That has an underappreciated consequence. Between releases, an image address is the only element of the npm page whose content you can still change. The words are frozen, the picture does not have to be. A diagram behind a live URL means the package page shows the current architecture even when the last release was in March.
It also means a broken image line is a mistake you cannot correct without cutting a version, which is a good reason to open the package page after every publish and look at it once.
What npm renders and what it removes
npm renders the README as GitHub Flavored Markdown and sanitizes the result. Scripts, styles and iframes do not survive, so there is no interactive embed on a package page. Images and a conservative subset of HTML do survive, which is why the image-by-URL route is the only live option here.
Keep the markup ordinary. Fancy theme-switching markup that works on GitHub is not worth relying on inside a sanitized renderer you do not control; a single image line behaves identically everywhere the README is read, including the npm CLI page, the package page, and any mirror rendering the same tarball.
Sizing for a narrow column
The README column on a package page is narrow, and a diagram rendered for a wide screen arrives scaled down. The embed endpoint takes width from 600 to 4000, height from 400 to 4000, scale from 1 to 3, and format png or jpeg, with a default of 1600 by 1000 at 2x. For a package page, a 16 by 9 or wider render with a modest node count reads better than a tall one.
Format choice is mundane: PNG for a diagram with flat fills and text, which is nearly always the right answer, JPEG only when the render carries a photographic background. Both come from the same endpoint through the format parameter.
If the package documents a library rather than a service, the diagram worth putting here is usually the runtime picture: what the package talks to when it runs, not the file tree. Consumers are deciding whether it fits their system.
Private packages, public diagram
Keeping the picture true across releases
Connect the repository read-only from GitHub, GitLab or Azure DevOps and the daily sync regenerates the diagram and an architecture.md from the source. For a package repository that means the diagram tracks refactors without anyone remembering to redraw it before a release.
Regenerating is not starting over. Once a diagram exists, every later run is handed the previous version's node ids, labels and zone names with an instruction to reuse each one that still applies, so a release that adds a dependency adds a node rather than returning a differently shaped picture with different names. That restraint matters more on a package page than almost anywhere else: the markdown around the image is frozen at publish, so the picture has to stay recognisable to somebody who last looked at it three versions ago.
The same live address works in the repository README, so the GitHub page and the npm page show one picture rather than two that disagree. The GitHub side has its own wrinkles, mainly the image proxy, covered in embed an architecture diagram in a GitHub README.
FAQ
Why are images in my README not showing on npmjs.com?
Does updating the README on GitHub update the npm package page?
Can anything on an npm package page change between releases?
Can I embed an interactive diagram on an npm package page?
What size should the README diagram be?