Skip to content
Back to skills

Mermaid Architecture

ASecurity

Use when generating, documenting, or updating architecture diagrams, flowcharts, sequence, ER, class, or state diagrams using Mermaid in docs/architecture/.

  • 8 stars
  • 0 votes
  • 0 copies
  • 10 views
  • Added September 19, 2026
ai-agentspythonjavabashreactnodeexpressfastapispringdockerkubernetes

Works with

  • cli
  • api

Security analysis

A100/100

Pro scans all 20 files and shows the line behind each finding

Scanned September 23, 2026

npx -y skills add afonsoft/skills --skill mermaid-architecture --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Mermaid Architecture?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for Mermaid Architecture
[![Security: A β€” Skills Directory](https://www.skillsdirectory.com/api/skills/afonsoft-mermaid-architecture/badge)](https://www.skillsdirectory.com/skills/afonsoft-mermaid-architecture)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
SKILL.md
---
name: mermaid-architecture
description: Use when generating, documenting, or updating architecture diagrams, flowcharts, sequence, ER, class, or state diagrams using Mermaid in docs/architecture/.
license: MIT
metadata:
  version: 1.0.0
  visibility: public
  author: merged from SpillwaveSolutions/design-doc-mermaid
  url: https://github.com/afonsoft/skills
  homepage: https://github.com/SpillwaveSolutions/design-doc-mermaid
  sources: https://github.com/SpillwaveSolutions/design-doc-mermaid
---

# Mermaid Architecture Diagrams

Create structured, high-contrast, production-ready Mermaid architecture diagrams, workflows, and system design documentation. Native diagrams render directly in Markdown viewers (GitHub, GitLab, Obsidian, wikis) with optional image exports (PNG/SVG) generated via Mermaid CLI (`mmdc` / `npx @mermaid-js/mermaid-cli`).

## πŸ“ Storage Location (`docs/architecture/`)

All generated architecture diagrams, source `.mmd` files, exported images, and system design documents **must be stored in `docs/architecture/`**, consistent with the `drawio-architecture` convention:

```text
docs/architecture/
β”œβ”€β”€ system-architecture.md             # Architecture documentation with embedded Mermaid blocks
β”œβ”€β”€ <name>_<type>_<title>.mmd          # Source Mermaid definitions
β”œβ”€β”€ <name>_<type>_<title>.png          # Optional exported raster image
└── <name>_<type>_<title>.svg          # Optional exported vector image
```

Ensure the directory exists before saving:
```bash
mkdir -p docs/architecture
```

## When to Use

- The user asks for an **architecture diagram**, **system structure**, **component overview**, **C4 model**, **microservices topology**, or **data flow**.
- Documenting **API interactions**, **service call sequences**, **authentication flows**, or **request lifecycles**.
- Visualizing **workflows**, **state machines**, **business logic**, **ETL pipelines**, or **decision trees**.
- Mapping code to diagrams (Spring Boot, FastAPI, React, Node/Express, Python ETL, Java).
- Creating or updating full **design documents** (System Design, Architecture, API Design, Database Schema).
- In the **Orchestrator pipeline (Phase 5)**: invoked via `/architecture` (the umbrella skill that owns `docs/architecture/`) to update or generate native Markdown Mermaid diagrams.

- User asks or mentions this skill in English (e.g., "use /mermaid-architecture", "run mermaid-architecture", "generate mermaid diagram").
- O usuΓ‘rio pede ou menciona esta skill em portuguΓͺs (ex.: "use /mermaid-architecture", "execute mermaid-architecture", "gerar diagrama mermaid").

## When NOT to Use

- Visual drag-and-drop editing with native `.drawio` format β†’ use `/drawio-architecture`.
- Freehand sketch or casual whiteboard drawing β†’ use Excalidraw or tldraw.
- PlantUML-specific legacy diagrams (Salt wireframes, timing diagrams).

## Orchestrator Integration

In the Orchestrator lifecycle (Phase 5 β€” Verification & QA Gate), the orchestrator calls `/architecture`, which routes work to the specialized engines:
1. `/drawio-architecture` updates the visual editable `.drawio` system diagram.
2. `/mermaid-architecture` runs immediately after to generate or update the native Mermaid architecture diagrams and embedded Markdown files in `docs/architecture/`.
3. `/create-readme` then references the generated diagrams in `README.md`.

---

## Diagram Types & Selection Guide

| Diagram Type | Best Used For | Guide to Load |
|---|---|---|
| **Architecture / C4** | System context, containers, microservices, component boundaries | `references/guides/diagrams/architecture-diagrams.md` |
| **Sequence** | API interactions, auth flows, inter-service messaging, async events | `references/guides/diagrams/sequence-diagrams.md` |
| **Activity / Flowchart** | Business processes, approval pipelines, ETL stages, decision trees | `references/guides/diagrams/activity-diagrams.md` |
| **Deployment / Cloud** | Cloud infrastructure (AWS, Azure, GCP), Kubernetes, networking | `references/guides/diagrams/deployment-diagrams.md` |
| **Class / ER / State** | Data models, database schemas, lifecycle transitions | `references/guides/wiki-ticket-and-github.md` |

---

## Resilient Workflow with Error Recovery

To prevent syntax errors from reaching documentation, follow the resilient validation cycle:

```mermaid
flowchart LR
    A[1. Identify Diagram Type] --> B[2. Save .mmd to docs/architecture]
    B --> C{3. Validate Syntax}
    C -->|Valid| D[4. Embed in Markdown / Export]
    C -->|Invalid| E[5. Search Troubleshooting]
    E --> F[6. Apply Fix & Retry]
    F --> C

    classDef step fill:#90EE90,stroke:#333,color:darkgreen
    classDef decision fill:#FFD700,stroke:#333,color:black
    class A,B,D,E,F step
    class C decision
```

### Script Execution

Use the bundled resilient script to generate diagrams directly into `docs/architecture/`:

```bash
# Generate diagram with automatic syntax validation and image export
python3 skills/mermaid-architecture/scripts/resilient_diagram.py \
    --code "flowchart TD; A[Client] --> B[API Gateway]" \
    --output-dir docs/architecture \
    --markdown-file system_architecture \
    --diagram-num 1 \
    --title "overview" \
    --format png \
    --json
```

If `mmdc` is not installed globally, the script automatically uses `npx -y @mermaid-js/mermaid-cli`.

---

## High-Contrast Styling (Mandatory)

All diagrams must ensure readable text on both light and dark backgrounds by always specifying `color:` in every `classDef`:

```mermaid
graph TB
    classDef primary fill:#90EE90,stroke:#333,stroke-width:2px,color:darkgreen
    classDef secondary fill:#87CEEB,stroke:#333,stroke-width:2px,color:darkblue
    classDef database fill:#E6E6FA,stroke:#333,stroke-width:2px,color:darkblue
    classDef error fill:#FFB6C1,stroke:#DC143C,stroke-width:2px,color:black

    %% Rule: Every classDef MUST include color: property
```

---

## Semantic Unicode Symbols

Always incorporate Unicode symbols to increase visual scanning speed and clarity:

- πŸ‘€ **Users**: `πŸ‘€ User`, `πŸ‘¨β€πŸ’Ό Admin`
- 🌐 **Network**: `🌐 Load Balancer`, `🌐 API Gateway`, `☁️ Cloud`
- βš™οΈ **Compute**: `βš™οΈ Service`, `⚑ Worker`, `πŸš€ Microservice`
- πŸ’Ύ **Storage**: `[(πŸ’Ύ Database)]`, `[(⚑ Redis Cache)]`, `πŸ“¦ Object Storage`
- πŸ“¨ **Messaging**: `πŸ“¨ Event Bus`, `πŸ“¬ Message Queue`, `πŸ“’ PubSub`
- πŸ” **Security**: `πŸ” Auth Service`, `πŸ›‘οΈ Firewall`, `πŸ”‘ Secrets`
- πŸ“Š **Observability**: `πŸ“Š Metrics`, `πŸ“ Logs`, `🚨 Alerts`

---

## Code-to-Diagram Extraction

When generating architecture from existing source code:
1. **Analyze entry points**: Read controllers, routes, API specs (`@RestController`, `@app.get`, Express routes, Controllers).
2. **Trace service dependencies**: Follow injected services, repositories, message queues, and DB contexts.
3. **Map infrastructure**: Read `docker-compose.yml`, Helm charts, Terraform, or cloud configs.
4. **Choose view**:
   - High-level component topology β†’ `architecture-diagrams.md`
   - Method/call flow β†’ `sequence-diagrams.md`
   - Business state transitions β†’ `activity-diagrams.md`
5. Refer to framework templates in `examples/` (`spring-boot`, `fastapi`, `react`, `node-webapp`, `python-etl`, `java-webapp`).

---

## Design Document Templates (`assets/`)

When full architecture or system documentation is required, populate the corresponding template and save to `docs/architecture/`:

| Document Type | Template Path | Target Output |
|---|---|---|
| Architecture Design | `assets/architecture-design-template.md` | `docs/architecture/architecture-design.md` |
| System Design | `assets/system-design-template.md` | `docs/architecture/system-design.md` |
| API Design | `assets/api-design-template.md` | `docs/architecture/api-design.md` |
| Database Design | `assets/database-design-template.md` | `docs/architecture/database-design.md` |
| Feature Design | `assets/feature-design-template.md` | `docs/architecture/feature-<name>-design.md` |

---

## Python Utilities

The skill includes standalone utilities in `scripts/`:

```bash
# Extract diagrams from markdown, validate, or convert
python3 skills/mermaid-architecture/scripts/extract_mermaid.py docs/architecture/system.md --validate

# Convert .mmd to PNG or SVG
python3 skills/mermaid-architecture/scripts/mermaid_to_image.py docs/architecture/overview.mmd docs/architecture/overview.png

# Full resilient generation with error diagnostics
python3 skills/mermaid-architecture/scripts/resilient_diagram.py --code "..." --title "service_map"
```

---

## References

- `references/guides/diagrams/architecture-diagrams.md` β€” C4 model, microservices, component architecture
- `references/guides/diagrams/sequence-diagrams.md` β€” API interactions, service calls
- `references/guides/diagrams/activity-diagrams.md` β€” Workflows and processes
- `references/guides/diagrams/deployment-diagrams.md` β€” Cloud, infrastructure, and deployment
- `references/guides/unicode-symbols/guide.md` β€” Complete semantic symbol index
- `references/guides/troubleshooting.md` β€” 28 common syntax error solutions
- `references/guides/resilient-workflow.md` β€” Error recovery and validation protocol
- `architecture` β€” Umbrella skill that owns `docs/architecture/` and routes diagram work to this engine
- `drawio-architecture` β€” Companion skill for editable draw.io visual diagrams

Files in this skill

  • SKILL.md9 KB
  • assets/api-design-template.md9.9 KB
  • assets/architecture-design-template.md7.7 KB
  • assets/database-design-template.md13.9 KB
  • assets/feature-design-template.md11.3 KB
  • assets/system-design-template.md16 KB
  • examples/fastapi/README.md20.2 KB
  • examples/java-webapp/README.md38.1 KB
  • examples/node-webapp/README.md21.2 KB
  • examples/python-etl/README.md25.9 KB
  • examples/react/README.md18.3 KB
  • examples/spring-boot/README.md13.4 KB
  • references/guides/code-to-diagram/README.md25.9 KB
  • references/guides/diagrams/activity-diagrams.md13.6 KB
  • references/guides/diagrams/architecture-diagrams.md32.8 KB
  • references/guides/diagrams/deployment-diagrams.md17.6 KB
  • references/guides/diagrams/sequence-diagrams.md27.3 KB
  • references/guides/resilient-workflow.md15.8 KB
  • references/guides/troubleshooting.md16.3 KB
  • references/guides/unicode-symbols/guide.md13.5 KB

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

Comments

Loading comments…

Newsletter

Get the weekly list of safe new skills, and the ones we pulled.