# Btp Diagram Generator

> Generate SAP BTP (Business Technology Platform) solution architecture diagrams as native draw.io (.drawio) files following the official SAP BTP Solution Diagram guidelines (Fiori Horizon design system) and open them via a configured draw.io MCP server. USE WHEN: user asks to create/draw/design/sketch a BTP diagram, BTP architecture, BTP landscape, BTP solution diagram, BTP reference architecture,…

- **Type:** Skill
- **Install:** `agentstack add skill-likweitan-abap-skills-btp-diagram-generator`
- **Verified:** Yes — security-reviewed for prompt injection and unsafe behavior
- **Seller:** [likweitan](https://agentstack.voostack.com/s/likweitan)
- **Installs:** 0
- **Category:** [Agent Skills](https://agentstack.voostack.com/c/agent-skills)
- **Latest version:** 0.1.0
- **License:** MIT
- **Upstream author:** [likweitan](https://github.com/likweitan)
- **Source:** https://github.com/likweitan/abap-skills/tree/main/skills/btp-diagram-generator

## Install

```sh
agentstack add skill-likweitan-abap-skills-btp-diagram-generator
```

Requires the [AgentStack CLI](https://agentstack.voostack.com/docs/cli). Works with Claude Code, Cursor, and any MCP-compatible agent.

## About

# BTP Solution Diagram Generator

Produces a `.drawio` file in the workspace that conforms to the [SAP BTP Solution Diagram guidelines](https://sap.github.io/btp-solution-diagrams/) and opens it through whichever [draw.io MCP server](https://www.drawio.com/doc/faq/ai-drawio-generation) is configured.

## ⚡ Quick Path (use this first)

For the vast majority of diagrams, **do not hand-write XML**. Use the `btp_builder` Python package — it owns icon lookup, SAP palette, port pinning, label HTML, A4 sizing, SVG upscaling, and validation. A typical L1 diagram is ~20 lines.

```python
# scripts/examples/task_center_arch.py — runnable end-to-end
import sys
from pathlib import Path
# Add the skill's scripts/ dir to sys.path so `btp_builder` imports work
# regardless of where the skill is installed (repo, ~/.claude/skills/, etc.)
sys.path.insert(0, str(Path(__file__).resolve().parent.parent))

from btp_builder import BtpDiagram

d = BtpDiagram(level="L1", title="Task Center Reference Architecture")

btp = d.btp_container(x=260, y=80, w=560, h=440)
sub = d.subaccount(parent=btp, label="Subaccount",
                   x=btp.x + 24, y=btp.y + 110, w=520, h=170)

wz = d.service("work zone",   in_=sub, x=sub.x + 60, y=sub.y + 60)
tc = d.service("task center", right_of=wz)
ci = d.service("cloud identity", below=tc)

eu = d.user("End User", x=60, y=btp.y + 100)
ac = d.app_client("Application Clients\n(Mobile or Desktop)", below=eu)

s4    = d.external("SAP S/4HANA\nOn-Premise Solutions",
                   x=btp.right_edge() + 40, y=btp.y + 70, kind="sap")
third = d.external("3rd Party\nApplications", below=s4, kind="non-sap")
cloud = d.external("SAP Cloud\nApplications", below=third, kind="sap")
idp   = d.idp("3rd-party Identity Provider",
              x=ci.center_x() - 140, y=btp.bottom_edge() + 60)

d.connect(eu, ac, direction="down")
d.connect(ac, wz, direction="right")
d.connect(wz, tc, kind="dblhd")
d.connect(tc, ci, kind="dblhd", direction="down")
d.connect(tc, s4); d.connect(tc, third); d.connect(tc, cloud)
d.connect(idp, ci, kind="dashed", direction="up")

d.save("btp-task-center-architecture.drawio")  # validates → raises on errors
```

Run via `uv run python .py` (per [AGENTS.md](../../../AGENTS.md)). `save()` validates first and raises `ValueError` with the full error list if anything is off; warnings are printed.

### Quick-Path API surface

| Call                                                        | Returns   | Notes                                                                                                                                                       |
| ----------------------------------------------------------- | --------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `BtpDiagram(level, title)`                                  | builder   | level ∈ `L0`/`L1`/`L2`. Drives icon size + label weight.                                                                                                    |
| `.btp_container(x,y,w,h, sub_label, env_label, with_logo)`  | `NodeRef` | Light-blue outer frame + SAP corner logo + Subaccount/Multi-Cloud labels.                                                                                   |
| `.subaccount(parent, label, ...)`                           | `NodeRef` | White card inside the BTP container.                                                                                                                        |
| `.inner_card(parent, label, ...)`                           | `NodeRef` | Generic white sub-card (e.g. CIS service group).                                                                                                            |
| `.service(name, in_=, right_of=, left_of=, below=, above=)` | `NodeRef` | `name` is fuzzy-matched via [reference/icon-aliases.json](reference/icon-aliases.json) (e.g. `"task center"`, `"cpi"`, `"hana cloud"`).                     |
| `.user(label, kind="sap")`                                  | `NodeRef` | kind ∈ `sap` / `non-sap` / `highlight`.                                                                                                                     |
| `.app_client(label, ...)`                                   | `NodeRef` | Generic mobile/desktop tile.                                                                                                                                |
| `.external(label, kind="sap"/"non-sap", ...)`               | `NodeRef` | Right-side external system tile.                                                                                                                            |
| `.idp(label, ...)`                                          | `NodeRef` | 3rd-party Identity Provider tile.                                                                                                                           |
| `.connect(src, tgt, kind, direction)`                       | edge id   | `kind` ∈ `std`/`dblhd`/`dashed`/`optional`/`auth`/`scim`/`trust`/`neutral`. `direction` auto-pins ports — override with `"right"`/`"left"`/`"up"`/`"down"`. |
| `.save(path, validate=True)`                                | `Path`    | Writes XML. Validates inline (raises on errors).                                                                                                            |

Positional kwargs (`right_of`, `left_of`, `below`, `above`, `in_`) auto-place nodes — only set explicit `x,y` for the first anchor in each row/column.

### Icon name discovery

```python
from btp_builder import list_aliases, list_icons, lookup_icon
print(list(list_aliases())[:30])     # short names → canonical keys
print(lookup_icon("integration suite", "L1")["key"])
```

If `lookup_icon` raises `IconNotFound`, fall back to a styled tile (`external(label, kind="sap")`) and call it out in the final response.

### Open the diagram

```sh
uv run python skills/btp-diagram-generator/scripts/open_diagram.py btp-task-center-architecture.drawio
```

Falls back to printing a `https://app.diagrams.net/?…#create=...` URL if no system opener is found. If a draw.io MCP tool is available in the runtime, prefer that — only call MCP tools that actually appear in the tool list.

---

## Manual XML path (advanced / niche cases only)

Use this only when the Quick Path doesn't cover what you need (e.g. exotic legend variants, custom flow-protocol pills, novel layouts not yet supported by the builder). Everything below documents the underlying XML primitives the builder generates for you.

## When to use

Trigger on requests like:

- "Draw a BTP architecture for …"
- "Generate a BTP solution diagram showing CAP + HANA Cloud + Build Workzone"
- "Create a draw.io of our SAP BTP integration landscape"
- "L0 / L1 / L2 BTP diagram for "

If the request is a generic flowchart, sequence diagram, or non-SAP architecture, do not use this skill — generate Mermaid or use a plain draw.io workflow instead.

## Inputs to gather (ask once, concisely)

Before generating, confirm what is missing. Default to L1 if unspecified.

| Input                    | Default              | Notes                                                                                                                                                                  |
| ------------------------ | -------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| Audience level           | L1                   | L0 = business overview (no legend, neutral connectors); L1 = technical (services + main flows); L2 = detailed (data flows, protocols, components)                      |
| BTP services / SaaS apps | (must ask)           | e.g. CAP, Build Code, Integration Suite (CPI/Event Mesh/API Mgmt), HANA Cloud, SAC, AI Core, Joule, Build Workzone, Identity Authentication, Destination, Connectivity |
| Non-BTP systems          | (optional)           | e.g. S/4HANA Cloud, SuccessFactors, Ariba, third-party SaaS, on-prem systems, end users                                                                                |
| Environment / runtime    | Cloud Foundry        | Cloud Foundry, Kyma, ABAP Environment                                                                                                                                  |
| Region / multi-region?   | single               | Affects grouping containers                                                                                                                                            |
| Primary flows            | (must ask)           | What connects to what, direction, purpose                                                                                                                              |
| Output filename          | `btp-diagram.drawio` | Saved to workspace root unless user specifies                                                                                                                          |

If the user gives a one-line prompt with enough services and a clear flow, proceed without asking — surface assumptions in the final response.

## Workflow

### 1. Map requirements to BTP icons

> **There is no `mxgraph.sap.*` stencil family.** SAP BTP icons in draw.io are SVGs embedded as base64 inside `shape=image;image=data:image/svg+xml,;…` style strings, distributed via the [SAP draw.io shape library XML files](https://github.com/SAP/btp-solution-diagrams/tree/main/assets/shape-libraries-and-editable-presets/draw.io). Generating `shape=mxgraph.sap.foo` produces an empty square in the canvas — you have seen this fail.

For every requested service, obtain its real `style` string by looking it up in [reference/icon-index.json](reference/icon-index.json):

1. **Preferred:** Load [reference/icon-index.json](reference/icon-index.json) (~660 KB, 100 icons). It maps each icon title (e.g. `31068-sap-build-work-zone_sd`) to its `style` string and library cell `width`/`height`. Match by substring against the requested service name.
2. **Source XML libraries** (if you need a non-default size or a metadata field the index doesn't carry) live in [reference/libraries/](reference/libraries/) — one size-M `mxlibrary` per icon set (foundational, integration suite, app-dev, AI, data-analytics, BTP-SaaS, all-in-one).
3. **Style donors:** for compound patterns (subaccount cards, NETWORK boundaries, pill labels, legend cards), consult the curated [reference/examples/](reference/examples/) — 11 official editable diagrams (Task Center L0/L1/L2, Build Work Zone L2, Process Automation L2, Cloud Identity Services L1/L2, Private Link L2, SAP Start L2). Open any of them and copy the exact style string.
4. If a service is genuinely missing from the library, use the styled fallback tile (see §3 below) and **list it in the final response** so the user can replace it.

Default icon geometry by audience level (matches the official examples — see [reference/example-patterns.md §5](reference/example-patterns.md)):

> **SVG intrinsic size warning:** Every icon in the SAP shape library has `width="16" height="16"` on its root `` element, even in the size-M set. draw.io rasterizes at that intrinsic size then upscales, producing a blurry icon. After extracting a base64 SVG, patch the root `` and `` to match the target cell size (e.g. 48 for L1) before re-encoding. Keep `viewBox` unchanged. See [reference/example-patterns.md §11](reference/example-patterns.md) for the Python helper.

| Level | Icon size | Label            |
| ----- | --------- | ---------------- |
| L0    | 50×50     | Arial 14 bold    |
| L1    | 48×48     | Arial 14 bold    |
| L2    | 32×32     | Arial 12 regular |

The label goes in the cell's `value=` attribute and renders below the icon (the library style already sets `verticalLabelPosition=bottom`). Always keep the `points=[[0,0,0,0,0],…]` 12-anchor array from the library style so connectors snap cleanly.

### 2. Apply the SAP Fiori Horizon palette

Always use these colors only (never pick arbitrary fills). Source: SAP BTP Solution Diagram guideline — _Foundation (Atoms)_ and _Areas_:

| Token                      | Hex                      | Use                                                           |
| -------------------------- | ------------------------ | ------------------------------------------------------------- |
| SAP/BTP border (Primary)   | `#0070F2`                | BTP container stroke, accent fills, sub-card stroke           |
| SAP/BTP fill               | `#EBF8FF`                | BTP container background                                      |
| Non-SAP border             | `#475E75`                | Non-SAP / external area strokes, generic data-flow connectors |
| Non-SAP fill / Subtle bg   | `#F5F6F7`                | Non-SAP areas, page background, generic pill fill             |
| Title text                 | `#1D2D3E`                | Headings, primary labels                                      |
| Secondary text             | `#556B82`                | Sub-labels, descriptions, footnotes                           |
| Positive (Auth, green)     | `#188918` / bg `#F5FAE5` | Authentication flows (SAML, OIDC) — per guideline             |
| Critical (Warning, orange) | `#C35500` / bg `#FFF8D6` | Warnings                                                      |
| Negative (Error, red)      | `#D20A0A` / bg `#FFEAF4` | Errors                                                        |
| Teal accent                | `#07838F` / bg `#DAFDF5` | Highlight areas                                               |
| Indigo (Authorization)     | `#5D36FF` / bg `#F1ECFF` | Authorization / provisioning (SCIM) flows — per guideline     |
| Pink (Trust)               | `#CC00DC` / bg `#FFF0FA` | Trust flows (mutual trust, federation) — per guideline        |

Font: `Arial` (or `Arial Black` for headings), size 12 for body labels, 14 for service labels, 16 for group titles.

### 3. Apply the atomic structure

Per the SAP atomic design system (Atoms → Molecules → Organisms). The exact style strings, sizes and HTML label patterns to copy live in [reference/example-patterns.md](reference/example-patterns.md) — match those rather than inventing variants.

- **Document title** (every diagram): a floating text cell above the BTP container, blue `#0070F2` bold Arial 16, format `"{Scenario} - SAP BTP Solution Diagram"`.
- **Outer container** (Subaccount / Multi-Cloud): `rounded=1;strokeColor=#0070F2;fillColor=#EBF8FF;arcSize=32;absoluteArcSize=1;strokeWidth=1.5;`. Carries the SAP-logo image tile in the top-left and two stacked labels: bold `Subaccount` (Arial 16) + smaller `Multi-Cloud` (Arial 12).
- **Sub-containers** (white cards inside the BTP boundary — e.g. Cloud Identity Services group): same `#0070F2` stroke, `#FFFFFF` fill, `arcSize=16`. **Always blue stroke, never slate**, when the card sits inside the BTP container. Per the guideline _Areas / Nesting_: alternate fill vs. no-fill between parent and child to keep visual contrast (BTP container has fill `#EBF8FF`, so inner cards use white).
- **Service nodes**: BTP icons (§1) wrapped in a `style="group" connectable="0"` cell whenever they need a separate text label or are co-positioned with another shape. Children use coordinates relative to the group origin.
- **External-system tiles** (e.g. `SAP S/4HANA On-Premise`): a group of (white card `arcSize=14` + ~28×28 icon top-left + bold `font-size:16px` label on the right). Sit outside the BTP container.
- **Users / actors**: a `group` containing the user SVG image and a centered `End User` text label below.
- **Connectors** — copy the right variant from the example patterns reference. Per the guideline _Connectors_ section, line _style_ encodes flow nature and line _color_ encodes flow semantic:
  - **Line style:** solid = direct synchronous request/

…

## Source & license

This open-source skill is cataloged on AgentStack and links to its original source — we do not rehost the code.

- **Author:** [likweitan](https://github.com/likweitan)
- **Source:** [likweitan/abap-skills](https://github.com/likweitan/abap-skills)
- **License:** MIT

Install and usage instructions live in the source repository linked above.

## Pricing

- **Free** — Free

## Security capabilities

Automated source analysis of v0.1.0 — what this tool can access:

- **Network access:** no
- **Filesystem access:** yes
- **Shell / process execution:** no
- **Environment & secrets:** no
- **Dynamic code execution:** no

*"Yes" means the capability is present in the source — more access means more to trust, not that it is unsafe.*


## Versions

- **0.1.0** — security scan: passed — Imported from the upstream source.

## Links

- Listing page: https://agentstack.voostack.com/l/skill-likweitan-abap-skills-btp-diagram-generator
- Seller: https://agentstack.voostack.com/s/likweitan
- Browse the marketplace: https://agentstack.voostack.com/browse

---
Listed on AgentStack — the marketplace for AI agent skills and MCP servers. Every listing is security-reviewed. Creators keep 70%.
