IBM Diagrams

June 15, 2026 ยท View on GitHub

IBM Diagrams

IBM Diagrams

Transform your infrastructure into beautiful, standards-compliant architecture diagrams.

License Python


๐ŸŽฏ What is IBM Diagrams?

IBM Diagrams is a powerful Python package that generates professional architecture diagrams following the IBM Design Language - Technical Diagrams Guideline. Whether you're documenting existing infrastructure, planning new deployments, or maintaining architecture documentation, IBM Diagrams makes it effortless.

โœจ Key Features

  • ๐Ÿ“ Diagram as Code: Write Python code to create diagrams programmatically
  • ๐Ÿ”„ Terraform Integration: Auto-generate diagrams from .tfstate files
  • ๐ŸŽจ IBM Design Standards: Automatic compliance with IBM Color Palette and IBM Plex fonts
  • ๐Ÿ“ค DrawIO Output: Edit and customize diagrams in draw.io desktop
  • โšก Fast & Flexible: Multiple input methods for different workflows

๐Ÿš€ Quick Start

Installation

# Using uv (recommended - 10-100x faster)
curl -LsSf https://astral.sh/uv/install.sh | sh
uv sync

# Or using pip
pip install ibmdiagrams-x.y.z-py3-none-any.whl
# If already installed, upgrade it with:
pip install --force-reinstall ibmdiagrams-x.y.z-py3-none-any.whl

# To install the latest CLI globally on your machine, use uv tool install or pip install against the rebuilt wheel.
uv tool install ibmdiagrams-x.y.z-py3-none-any.whl
# If already installed, upgrade it with:
uv tool install --upgrade ibmdiagrams-x.y.z-py3-none-any.whl

Your First Diagram (30 seconds)

from ibmdiagrams.ibmcloud.compute import VirtualServer
from ibmdiagrams.ibmcloud.diagram import Diagram
from ibmdiagrams.ibmcloud.groups import VPC, IBMCloud, Region, Subnet, Zone

with Diagram("my-first-diagram"):
    with IBMCloud("IBM Cloud"):
        with Region("Dallas"):
            with VPC("Production VPC"):
                with Zone("Zone 1", "10.10.0.0/18"):
                    with Subnet("App Subnet", "10.10.10.0/24"):
                        vsi = VirtualServer("Web Server", "10.10.10.4")

Run it:

python my-first-diagram.py
# Output: my-first-diagram.drawio

Open in draw.io desktop and see your architecture come to life! ๐ŸŽ‰


๐Ÿ’ก Use Cases

IBM Diagrams supports four powerful workflows:

1๏ธโƒฃ Python (Diagram as Code) โ†’ DrawIO

Perfect for: Planning new architectures, documentation, presentations

python docs/examples/python/cloud.py
# Output: cloud.drawio

Benefits:

  • Version control your diagrams
  • Quickly iterate on designs
  • Reusable templates
  • No manual positioning

๐Ÿ“– See Examples | ๐Ÿ“š Full Guide


2๏ธโƒฃ Terraform State โ†’ DrawIO

Perfect for: Documenting existing infrastructure, compliance audits

# With custom labels (resource names, IPs, etc.)
ibmdiagrams docs/examples/terraform/cloud.tfstate
# Output: cloud.drawio

# With general labels (resource types only)
ibmdiagrams --general docs/examples/terraform/cloud.tfstate
# Output: cloud.drawio

Benefits:

  • Instant infrastructure visualization
  • Always up-to-date documentation
  • Onboard new team members faster
  • Audit and compliance reporting

๐Ÿ“– See Examples | ๐Ÿ“š Full Guide


3๏ธโƒฃ Terraform State โ†’ Python Code

Perfect for: Converting existing infrastructure to diagram-as-code

ibmdiagrams --python docs/examples/terraform/cloud.tfstate
# Output: cloud.py (editable Python code)

Benefits:

  • Start with existing infrastructure
  • Customize and extend diagrams
  • Create templates from real deployments
  • Bridge Terraform and diagram-as-code workflows

๐Ÿ“– See Examples


4๏ธโƒฃ JSON โ†’ DrawIO (Internal Format)

Perfect for: Advanced integrations, custom tooling

ibmdiagrams docs/examples/json/cloud.json
# Output: cloud.drawio

Note: JSON format is for internal use and not externally documented.


๐Ÿ“š Examples

Simple VPC with Virtual Server

Click to expand code
from ibmdiagrams.ibmcloud.diagram import Diagram
from ibmdiagrams.ibmcloud.groups import IBMCloud, Region, VPC, Zone, Subnet
from ibmdiagrams.ibmcloud.compute import VirtualServer
from ibmdiagrams.ibmcloud.network import PublicGateway
from ibmdiagrams.ibmcloud.security import SecurityGroup

with Diagram("simple-vpc"):
    with IBMCloud("IBM Cloud"):
        with Region("Dallas", direction="TB"):
            with VPC("My VPC"):
                pgw = PublicGateway("Public Gateway")
                
                with Zone("Zone 1", "10.10.0.0/18"):
                    with Subnet("Web Subnet", "10.10.10.0/24"):
                        web = VirtualServer("Web Server", "10.10.10.4")
                    
                    with Subnet("App Subnet", "10.10.20.0/24"):
                        app = VirtualServer("App Server", "10.10.20.4")

๐Ÿ”— More Examples


Enterprise Landing Zone

See our comprehensive VSI on VPC Landing Zone example featuring:

  • Multi-zone deployment
  • VPN and VPE configuration
  • Cloud services integration
  • Security and observability

SLZ VSI Example


๐ŸŽจ Design Standards

IBM Diagrams automatically applies IBM Design Language standards:

FeatureImplementation
ColorsIBM Color Palette (Cyan, Teal, Purple, Magenta)
FontsIBM Plex Sans (with global variants support)
LabelsTwo-line labels with SemiBold primary + regular sublabel
ShapesGroups (containers), Zones, Nodes (square), Actors (round)
LayoutAutomatic Z-order and positioning

Shape Types

  • Groups (container=1): Represent "deployedOn" relationships (e.g., VSI on subnet)
  • Zones (container=0): Represent "deployedTo" relationships (e.g., VSI to security group)
  • Nodes (square): Standalone components or devices
  • Actors (round): Users, roles, and external entities

๐Ÿ“– Documentation

GuideDescription
๐Ÿš€ Getting StartedComplete setup and first steps
โš™๏ธ SetupInstallation with uv or pip
๐Ÿ“ Diagram as CodePython API reference and examples
๐Ÿ”„ TerraformTerraform state file integration
๐Ÿค– MCP IntegrationModel Context Protocol server for AI assistants
๐ŸŽฏ MCP OnboardingStep-by-step setup for IBM Bob and Claude Desktop
๐Ÿค– AI SkillPortable AI skill for IBM Bob, Claude Code, and other AI assistants
๐Ÿงช TestingVisual regression testing guide

๐Ÿ› ๏ธ Development

Pre-commit Hooks

pip install pre-commit
pre-commit install
pre-commit run --all-files

Visual Regression Testing

# Install draw.io desktop first
pip install -r requirements-dev.txt

# Run tests
pytest tests/test_visual_regression.py

# Update baselines after intentional changes
pytest tests/test_visual_regression.py --update-baselines

See CONTRIBUTING.md for detailed development guidelines.


๐ŸŽฏ Why IBM Diagrams?

For DevOps Teams

  • Automate documentation from Terraform state
  • Version control your architecture diagrams
  • Reduce manual work with auto-generated layouts

For Architects

  • Validate designs before implementation
  • Communicate clearly with IBM-standard visuals
  • Iterate quickly without repositioning elements

For Compliance Teams

  • Audit infrastructure with up-to-date diagrams
  • Document changes automatically
  • Meet standards with IBM Design Language compliance

โš ๏ธ Known Limitations

  1. Group Spanning: Diagram-as-code cannot represent groups spanning other groups (e.g., same security group across multiple subnets must be coded separately)
  2. Connectors: Currently direct point-to-point; layout improvements planned

๐Ÿค Contributing

We welcome contributions! Please see:


๐Ÿ“„ License

This project is licensed under the Apache License, Version 2.0. Separate third-party code objects invoked by this application are licensed by their respective providers pursuant to their own separate licenses. Contributions are subject to the Developer Certificate of Origin, Version 1.1 and the Apache License, Version 2.


๐ŸŒŸ Star Us!

If IBM Diagrams helps you, please โญ star this repository to show your support!