architecture-diagrams-library
Architecture diagrams as code: reviewable in PRs, diffable, no screenshot that rots.
git clone https://github.com/fernando-moretes/ref-architecture-diagrams-library.gitListen to guide
generated on playGenerated only on first play
Powered by Amazon Polly + OmniVoice
A catalog of architecture diagrams written as code — AWS, C4, BPMN, event-driven, sequence and state — with version-controlled source, pull-request review and a Next.js site that publishes them at diagrams.moretes.com.
Why a diagram becomes code
The problem this repository solves is not drawing — it's keeping the drawing true after the architecture changes. A diagram that exists only as a PNG exported from a visual tool loses its source on the first laptop swap, has no diff and nobody reviews it. Six months later the architecture document shows three SQS queues where five now exist and a Lambda that was retired.
I applied to diagrams the same discipline applied to infrastructure: text source, in a repository, behind a pull request. A Mermaid .mmd or a PlantUML .puml fits in a code review, shows line by line what changed and can be rendered by the documentation pipeline without a human in the loop. When someone swaps EventBridge for SNS/SQS in an ADR, the diagram change lands in the same PR as the decision change.
What the repository is: a curated catalog of those sources, organized by type (AWS reference, C4 layers, BPMN process, event-driven topology, sequence, state), plus a Next.js 16 frontend that renders and publishes all of it. What it is not: a new diagramming tool. The renderers are the usual ones — Mermaid, PlantUML and the Python diagrams library — the value is in the curation and the review flow.
What the catalog holds
diagrams (Python), for when you need the official service icons.From source file to published diagram
The flow is the same as any code: PR, CI, deploy. A diagram is only published because it went through review.
- Mermaid · .mmd — C4, sequência, estado
- PlantUML · .puml — sequência, estado
- diagrams (Python) · AWS com ícones oficiais
- CI · lint + validação das fontes
- Security · scan de dependências
- Frontend · build Next.js 16
- Catálogo Next.js · App Router + React 19
- DNS · diagrams.moretes.com
How the repository works
There are two halves with separate responsibilities. The sources: text files in three diagram languages. Mermaid covers most of it — C4 via the C4Context/C4Container syntax, sequence, state and flowcharts for event-driven — because it renders on GitHub itself and in almost every documentation generator without a plugin. PlantUML steps in where Mermaid runs short, mainly long sequences with groups and notes. The Python diagrams library is reserved for AWS architectures where the official service icon makes the picture readable to non-engineers.
The frontend: a Next.js 16 application (App Router, React 19, TypeScript 5, Tailwind CSS 4) under frontend/ that reads the sources, renders and publishes the catalog. It runs on Vercel; DNS for diagrams.moretes.com is managed on Cloudflare.
The pipeline: four GitHub Actions workflows — CI, Frontend, Vercel and Security. CI validates sources on the PR; Security scans dependencies; Frontend builds the site; the deploy goes to Vercel. The detail that matters: validation happens before merge, so a .mmd with broken syntax never reaches main — it breaks in the PR, where someone is looking. That is the difference between a catalog that stays maintained and a folder of files nobody trusts.
The operational documents live in the repository itself: docs/architecture.md for the system design, SETUP.md for the environment, OPERATIONS.md for day-to-day and CONTRIBUTING.md for anyone who wants to add a diagram.
Install and use
- 1
Clone the repository
git clone https://github.com/fernando-moretes/ref-architecture-diagrams-library.git. Use the newfernando-moretesorg URL; the README badges still point atfernandofatech, and GitHub redirects, but a redirect is not something to depend on in automation. - 2
Install the frontend
cd frontend && npm install. Requires Node 20 or later — Next.js 16 does not build on earlier versions.SETUP.mdlists whatever else the environment needs. - 3
Run the catalog locally
npm run devstarts the site athttp://localhost:3000. Browse by diagram type and open any item to see the source next to the render. - 4
Copy the snippet into your ADR
Every diagram is a block of text. Paste the Mermaid inside a ``
mermaid fence in the ADR's Markdown and GitHub renders it immediately, no build. PlantUML anddiagrams` need the matching renderer in your docs pipeline. - 5
Add or fix a diagram via PR
Follow
CONTRIBUTING.md: one source file per diagram, in the category's directory. CI validates the syntax on the PR; a broken diagram does not pass. Do not edit a PNG — it does not exist as a source of truth here.
# 1. Clone (URL nova da org)
git clone https://github.com/fernando-moretes/ref-architecture-diagrams-library.git
cd ref-architecture-diagrams-library
# 2. Frontend do catálogo (Next.js 16 — Node >= 20)
cd frontend
npm install
npm run dev # http://localhost:3000
# 3. Renderizar uma fonte fora do site, se precisar do arquivo
# Mermaid -> SVG
npx -y @mermaid-js/mermaid-cli -i ../path/to/diagram.mmd -o diagram.svg
# PlantUML -> PNG (precisa de Java + plantuml.jar no PATH ou via Docker)
plantuml ../path/to/diagram.puml
# diagrams (Python) -> PNG (precisa de Graphviz instalado)
pip install diagrams
python ../path/to/aws_reference.pyThe Python renderer has a dependency outside pip
The diagrams library shells out to Graphviz underneath. pip install diagrams succeeds and python file.py fails with ExecutableNotFound: dot — the message shows up only on first run, not at install time. Install Graphviz through the system package manager (brew install graphviz, apt install graphviz) before trying to render the AWS architectures.
How I use this in architecture work
The most common case is not opening the site — it's opening an ADR. When I write a decision about, say, orchestration with Step Functions versus choreography with EventBridge, each option gets a sequence or topology diagram pasted from the catalog and adjusted with the domain's real names. The reviewer sees option A and option B side by side, in the same Markdown, in the same style. Without that, every architect draws in whatever tool is at hand and the architecture board spends the first ten minutes decoding legends.
C4 in layers, not all at once: the mistake I see most is a single diagram trying to be Context and Component at the same time. The catalog splits the four layers into separate files precisely so Context fits on one screen and Component can be detailed without polluting what the business stakeholder needs to see.
BPMN next to the technical view: when the business process and the event topology live in the same repository, divergence between them becomes a diff. An approval step that exists in the BPMN with no matching event in the topology is a design bug you catch in review — before it becomes a production bug at 2 AM.
The cost this repository reduces is not drawing the first diagram — it's keeping fifty diagrams true over years, with teams that change.
Frequently asked questions
Do I need to run the frontend to use the diagrams?
No. The sources are text files in the repository; you can clone, copy the .mmd or .puml and paste it into your document without installing anything from Next.js. The site is the browsable showcase, not a prerequisite.
Why three diagram languages instead of one?
Because none of them covers everything well. Mermaid renders natively on GitHub and is the default choice. PlantUML handles long sequences and grouping better. Python diagrams is the only one of the three with official AWS icons, which changes readability for a non-technical audience. Use Mermaid when you can, the other two when you must.
Can I use the diagrams in my company's material?
Yes — the license is MIT. Copy, adapt, rename. What the license does not do is guarantee the diagram describes your architecture: it is a starting point, and the review with whoever operates the system is still on you.
References
Who it is for
Use this repository when you write ADRs or RFCs often, when the team reviews architecture in pull requests, and when your wiki diagrams have already diverged from what runs in production at least once. It is worth less if your documentation flow does not go through Git — PR review is the whole mechanism, not a detail. Start with Mermaid, paste the first snippet into your next ADR, and only install Graphviz and Java when a stakeholder asks for the official icon or a sequence Mermaid cannot draw.
Architecture, AWS, AI and market deep dives — straight to your inbox. Free.
No spam · unsubscribe anytime