# diagrams-js
> Draw cloud system architecture diagrams as code in TypeScript
- [diagrams-js](/)
## playground
- [Playground](/playground): Interactive diagrams-js playground
## search
- [Search the documentation](/search)
## docs
- [AI Guide](/docs/ai-guide): Guide for AI LLMs and agents using diagrams-js
- [Credits](/docs/credits): Acknowledgments and credits
- [Examples](/docs/getting-started/examples): Real-world architecture examples
- [Installation](/docs/getting-started/installation): Installing diagrams-js in your project
- [Quick Start](/docs/getting-started/quickstart): Create your first diagram in minutes
- [API Reference](/docs/guides/api): Complete API documentation
- [CLI](/docs/guides/cli): Using diagrams from the command line with @diagrams-js/cli
- [Clusters](/docs/guides/clusters): Group nodes together with clusters
- [Custom Nodes](/docs/guides/custom-nodes): Use your own icons and images
- [Diagrams](/docs/guides/diagram): Understanding the Diagram class
- [Diagram Diff](/docs/guides/diagram-diff): Compare two versions of a diagram visually to see what changed. The diff feature highlights added, removed, and modified elements with color-coded overlays in a side-by-side view.
- [Edges](/docs/guides/edge): Connecting nodes with customized edges
- [GitHub Action](/docs/guides/github-action): Using diagrams-js in GitHub Actions for CI/CD
- [JSON Serialization](/docs/guides/json): Export and import diagrams as JSON for cloud architecture provisioning and tool integration
- [Migration from Python diagrams](/docs/guides/migration): Migrate from Python diagrams to TypeScript
- [Nodes](/docs/guides/node): Working with nodes and data flow
- [Providers](/docs/guides/providers): Available cloud providers
- [Rendering](/docs/guides/rendering): Render and export diagrams
- [Alibaba Cloud](/docs/nodes/alibabacloud): Node types for Alibaba Cloud provider
- [AWS](/docs/nodes/aws): Node types for Amazon Web Services provider
- [Azure](/docs/nodes/azure): Node types for Microsoft Azure provider
- [C4 Model](/docs/nodes/c4): Visualize software architecture using the C4 model
- [DigitalOcean](/docs/nodes/digitalocean): Node types for DigitalOcean provider
- [Elastic](/docs/nodes/elastic): Node types for Elastic Stack provider
- [Firebase](/docs/nodes/firebase): Node types for Firebase provider
- [GCP](/docs/nodes/gcp): Node types for Google Cloud Platform provider
- [Generic](/docs/nodes/generic): Node types for generic/on-premise resources
- [GIS](/docs/nodes/gis): Node types for GIS (Geographic Information Systems) provider
- [IBM](/docs/nodes/ibm): Node types for IBM Cloud provider
- [Kubernetes](/docs/nodes/k8s): Node types for Kubernetes provider
- [OCI](/docs/nodes/oci): Node types for Oracle Cloud Infrastructure provider
- [On-Premises](/docs/nodes/onprem): Node types for on-premises infrastructure
- [OpenStack](/docs/nodes/openstack): Node types for OpenStack provider
- [Outscale](/docs/nodes/outscale): Node types for Outscale provider
- [Programming](/docs/nodes/programming): Node types for programming languages and frameworks
- [SaaS](/docs/nodes/saas): Node types for Software as a Service providers
- [Docker Compose Plugin](/docs/plugins/docker-compose): Import and export Docker Compose files with diagrams-js
- [Kubernetes Plugin](/docs/plugins/kubernetes): Import and export Kubernetes YAML manifests with diagrams-js
- [Plugin System Overview](/docs/plugins/overview): Extend diagrams-js with custom import/export formats, metadata providers, and hooks
---
# Full Documentation Content
Example: -- Select an example --
Share
---
[Skip to main content](#__docusaurus_skipToContent_fallback)
[](/)
[**diagrams-js**](/)[Docs](/docs/getting-started/installation)[Examples](/docs/getting-started/examples)[Guides](/docs/guides/diagram)[Providers](/docs/guides/providers)[Playground](/playground)[Visual Editor](/visual-editor)
[npm](https://www.npmjs.com/package/diagrams-js)[GitHub](https://github.com/diagrams-js/diagrams-js)
Search
# Search the documentation
Type your search here
Powered by[](https://www.algolia.com/)
Docs
* [Getting Started](/docs/getting-started/quickstart)
* [Examples](/docs/getting-started/examples)
* [API Reference](/docs/guides/diagram)
For AI
* [AI Guide](/docs/ai-guide)
* [llms.txt](/llms.txt)
* [llms-full.txt](/llms-full.txt)
Community
* [GitHub](https://github.com/diagrams-js/diagrams-js)
* [𝕏 / Twitter](https://x.com/hatem_hosny_)
More
* [Playground](/playground)
* [Visual Editor](/visual-editor)
* [Sponsor 💚](https://github.com/sponsors/hatemhosny)
Copyright © 2026 [Hatem Hosny](https://github.com/hatemhosny). MIT License.
---
# AI Guide
This guide is specifically designed for AI Large Language Models (LLMs) and autonomous agents to effectively use the diagrams-js library for generating cloud architecture diagrams.
## llms.txt[](#llmstxt "Direct link to llms.txt")
For optimal context when working with diagrams-js, use these specially formatted documentation files:
**📄 [llms.txt](/llms.txt)** - Concise overview of the library, installation, basic usage, and key concepts
**📄 [llms-full.txt](/llms-full.txt)** - Complete documentation including all guides, API reference, and examples
These files are specifically structured for AI consumption with:
* Clear API signatures and type definitions
* Code examples with expected outputs
* Provider reference lists
* Best practices and common patterns
See
`await diagram.save("filename.svg", { format: "svg" }); // or "png"/"jpeg"`
## Resources[](#resources "Direct link to Resources")
* 📚 [Full Documentation](/docs/getting-started/installation)
* 🔧 [API Reference](/docs/guides/diagram)
* 🎨 [Provider List](/docs/guides/providers)
* 🤖 [TanStack Intent Skills](https://github.com/diagrams-js/diagrams-js/blob/main/.agents/INTENT.md) - AI-assisted development
* 📄 [llms.txt](/llms.txt) - Quick reference
* 📄 [llms-full.txt](/llms-full.txt) - Complete docs
---
# Credits
diagrams-js is made possible thanks to these amazing projects and communities:
## Original Project[](#original-project "Direct link to Original Project")
**[diagrams](https://github.com/mingrammer/diagrams)** by [mingrammer](https://github.com/mingrammer)
This project is a TypeScript port of the original Python diagrams library. We are grateful to mingrammer for creating such an elegant and powerful tool for drawing cloud architecture diagrams as code.
## Rendering Engine[](#rendering-engine "Direct link to Rendering Engine")
**[Graphviz](https://graphviz.org/)**
The graph visualization software that powers the layout and rendering of all diagrams. Graphviz provides the sophisticated algorithms for positioning nodes and routing edges.
**[viz-js](https://github.com/mdaines/viz-js)** by [mdaines](https://github.com/mdaines)
A WebAssembly-based port of Graphviz for JavaScript. This enables diagrams-js to run entirely in the browser without requiring any server-side components.
## Icon Sets[](#icon-sets "Direct link to Icon Sets")
All node icons are from the original [diagrams](https://github.com/mingrammer/diagrams) library, which includes icons from various cloud providers and technology vendors.
## Community[](#community "Direct link to Community")
Thank you to all contributors and users who help improve diagrams-js through bug reports, feature requests, and pull requests.
## License[](#license "Direct link to License")
diagrams-js is released under the MIT License, same as the original diagrams library.
---
# Examples
Here are comprehensive examples demonstrating the capabilities of diagrams-js.
info
These examples are reproduced from the original [Python's Diagrams library](https://diagrams.mingrammer.com/docs/getting-started/examples) documentations.
Live Demo
For interactive examples with live rendered diagrams, check out the [playground](/playground).
## Grouped Workers on AWS[](#grouped-workers-on-aws "Direct link to Grouped Workers on AWS")
```
import { Diagram } from "diagrams-js";
import { EC2 } from "diagrams-js/aws/compute";
import { RDS } from "diagrams-js/aws/database";
import { ELB } from "diagrams-js/aws/network";
const diagram = Diagram("Grouped Workers", {
direction: "TB",
});
const lb = diagram.add(ELB("lb"));
const workers = [
diagram.add(EC2("worker1")),
diagram.add(EC2("worker2")),
diagram.add(EC2("worker3")),
diagram.add(EC2("worker4")),
diagram.add(EC2("worker5")),
];
const events = diagram.add(RDS("events"));
lb.to(workers);
workers.forEach((w) => w.to(events));
const svg = await diagram.render();
```

## Clustered Web Services[](#clustered-web-services "Direct link to Clustered Web Services")
```
import { Diagram } from "diagrams-js";
import { ECS } from "diagrams-js/aws/compute";
import { RDS, Elasticache } from "diagrams-js/aws/database";
import { ELB, Route53 } from "diagrams-js/aws/network";
const diagram = Diagram("Clustered Web Services");
const dns = diagram.add(Route53("dns"));
const lb = diagram.add(ELB("lb"));
const svcCluster = diagram.cluster("Services");
const svcGroup = [
svcCluster.add(ECS("web1")),
svcCluster.add(ECS("web2")),
svcCluster.add(ECS("web3")),
];
lb.to(svcGroup);
const dbCluster = diagram.cluster("DB Cluster");
const dbPrimary = dbCluster.add(RDS("userdb"));
const dbReplica = dbCluster.add(RDS("userdb ro"));
dbPrimary.with(dbReplica);
svcGroup.forEach((s) => s.to(dbPrimary));
const memcached = diagram.add(Elasticache("memcached"));
svcGroup.forEach((s) => s.to(memcached));
dns.to(lb);
const svg = await diagram.render();
```

## Event Processing on AWS[](#event-processing-on-aws "Direct link to Event Processing on AWS")
```
import { Diagram } from "diagrams-js";
import { ECS, EKS, Lambda } from "diagrams-js/aws/compute";
import { Redshift } from "diagrams-js/aws/database";
import { SQS } from "diagrams-js/aws/integration";
import { S3 } from "diagrams-js/aws/storage";
const diagram = Diagram("Event Processing");
const source = diagram.add(EKS("k8s source"));
const store = diagram.add(S3("events store"));
const dw = diagram.add(Redshift("analytics"));
const flowsCluster = diagram.cluster("Event Flows");
const workersCluster = flowsCluster.cluster("Event Workers");
const workerNodes = [
workersCluster.add(ECS("worker1")),
workersCluster.add(ECS("worker2")),
workersCluster.add(ECS("worker3")),
];
source.to(workerNodes);
const queue = flowsCluster.add(SQS("event queue"));
workerNodes.forEach((w) => w.to(queue));
const procCluster = flowsCluster.cluster("Processing");
const handlers = [
procCluster.add(Lambda("proc1")),
procCluster.add(Lambda("proc2")),
procCluster.add(Lambda("proc3")),
];
queue.to(handlers);
handlers.forEach((h) => {
h.to(store);
h.to(dw);
});
const svg = await diagram.render();
```

## Message Collecting System on GCP[](#message-collecting-system-on-gcp "Direct link to Message Collecting System on GCP")
```
import { Diagram } from "diagrams-js";
import { BigQuery, Dataflow, PubSub } from "diagrams-js/gcp/analytics";
import { AppEngine, Functions } from "diagrams-js/gcp/compute";
import { Bigtable } from "diagrams-js/gcp/database";
import { IotCore } from "diagrams-js/gcp/iot";
import { Storage } from "diagrams-js/gcp/storage";
const diagram = Diagram("Message Collecting");
const pubsub = diagram.add(PubSub("pubsub"));
const sourceCluster = diagram.cluster("Source of Data");
const sources = [
sourceCluster.add(IotCore("core1")),
sourceCluster.add(IotCore("core2")),
sourceCluster.add(IotCore("core3")),
];
sources.forEach((s) => s.to(pubsub));
const targetsCluster = diagram.cluster("Targets");
const flowCluster = targetsCluster.cluster("Data Flow");
const dataflow = flowCluster.add(Dataflow("data flow"));
pubsub.to(dataflow);
const lakeCluster = targetsCluster.cluster("Data Lake");
const bq = lakeCluster.add(BigQuery("bq"));
const gcs = lakeCluster.add(Storage("storage"));
dataflow.to([bq, gcs]);
const eventCluster = targetsCluster.cluster("Event Driven");
const procCluster = eventCluster.cluster("Processing");
const engine = procCluster.add(AppEngine("engine"));
const bigtable = procCluster.add(Bigtable("bigtable"));
dataflow.to(engine).to(bigtable);
const serverlessCluster = eventCluster.cluster("Serverless");
const func = serverlessCluster.add(Functions("func"));
const appengine = serverlessCluster.add(AppEngine("appengine"));
dataflow.to(func).to(appengine);
const svg = await diagram.render();
```

## Exposed Pod with 3 Replicas on Kubernetes[](#exposed-pod-with-3-replicas-on-kubernetes "Direct link to Exposed Pod with 3 Replicas on Kubernetes")
```
import { Diagram } from "diagrams-js";
import { HPA } from "diagrams-js/k8s/clusterconfig";
import { Deployment, Pod, ReplicaSet } from "diagrams-js/k8s/compute";
import { Ingress, Service } from "diagrams-js/k8s/network";
const diagram = Diagram("Exposed Pod with 3 Replicas");
const ingress = diagram.add(Ingress("domain.com"));
const svc = diagram.add(Service("svc"));
const pods = [diagram.add(Pod("pod1")), diagram.add(Pod("pod2")), diagram.add(Pod("pod3"))];
const rs = diagram.add(ReplicaSet("rs"));
const dp = diagram.add(Deployment("dp"));
const hpa = diagram.add(HPA("hpa"));
ingress.to(svc);
svc.to(pods);
pods.forEach((p) => p.from(rs));
rs.from(dp);
dp.from(hpa);
const svg = await diagram.render();
```

## Stateful Architecture on Kubernetes[](#stateful-architecture-on-kubernetes "Direct link to Stateful Architecture on Kubernetes")
```
import { Diagram } from "diagrams-js";
import { Pod, StatefulSet } from "diagrams-js/k8s/compute";
import { Service } from "diagrams-js/k8s/network";
import { PV, PVC } from "diagrams-js/k8s/storage";
const diagram = Diagram("Stateful Architecture");
const appsCluster = diagram.cluster("Apps");
const svc = appsCluster.add(Service("svc"));
const sts = appsCluster.add(StatefulSet("sts"));
const pods = [];
const pvcs = [];
for (let i = 0; i < 3; i++) {
const pod = appsCluster.add(Pod("pod"));
const pvc = appsCluster.add(PVC("pvc"));
pod.with(sts).with(pvc);
svc.to(pod).to(pvc);
pods.push(pod);
pvcs.push(pvc);
}
const pv = diagram.add(PV("pv"));
const sc = diagram.add(StorageClass("sc"));
pvcs.forEach((pvc) => {
pvc.from(pv);
});
pv.from(sc);
const svg = await diagram.render();
```

## Advanced Web Service with On-Premises[](#advanced-web-service-with-on-premises "Direct link to Advanced Web Service with On-Premises")
```
import { Diagram } from "diagrams-js";
import { Spark } from "diagrams-js/onprem/analytics";
import { Server } from "diagrams-js/onprem/compute";
import { PostgreSQL } from "diagrams-js/onprem/database";
import { Redis } from "diagrams-js/onprem/inmemory";
import { Fluentd } from "diagrams-js/onprem/aggregator";
import { Grafana, Prometheus } from "diagrams-js/onprem/monitoring";
import { Nginx } from "diagrams-js/onprem/network";
import { Kafka } from "diagrams-js/onprem/queue";
const diagram = Diagram("Advanced Web Service with On-Premises");
const ingress = diagram.add(Nginx("ingress"));
const metrics = diagram.add(Prometheus("metric"));
const grafana = diagram.add(Grafana("monitoring"));
metrics.from(grafana);
const serviceCluster = diagram.cluster("Service Cluster");
const grpcsvc = [
serviceCluster.add(Server("grpc1")),
serviceCluster.add(Server("grpc2")),
serviceCluster.add(Server("grpc3")),
];
const sessionsCluster = diagram.cluster("Sessions HA");
const sessionPrimary = sessionsCluster.add(Redis("session"));
const sessionReplica = sessionsCluster.add(Redis("replica"));
sessionPrimary.with(sessionReplica);
sessionReplica.from(metrics);
grpcsvc.forEach((svc) => svc.to(sessionPrimary));
const dbCluster = diagram.cluster("Database HA");
const dbPrimary = dbCluster.add(PostgreSQL("users"));
const dbReplica = dbCluster.add(PostgreSQL("replica"));
dbPrimary.with(dbReplica);
dbReplica.from(metrics);
grpcsvc.forEach((svc) => svc.to(dbPrimary));
const aggregator = diagram.add(Fluentd("logging"));
const kafka = diagram.add(Kafka("stream"));
const spark = diagram.add(Spark("analytics"));
aggregator.to(kafka).to(spark);
ingress.to(grpcsvc);
grpcsvc.forEach((svc) => svc.to(aggregator));
const svg = await diagram.render();
```

## Advanced Web Service with On-Premises (with colors and labels)[](#advanced-web-service-with-on-premises-with-colors-and-labels "Direct link to Advanced Web Service with On-Premises (with colors and labels)")
```
import { Diagram, Edge } from "diagrams-js";
import { Spark } from "diagrams-js/onprem/analytics";
import { Server } from "diagrams-js/onprem/compute";
import { PostgreSQL } from "diagrams-js/onprem/database";
import { Redis } from "diagrams-js/onprem/inmemory";
import { Fluentd } from "diagrams-js/onprem/aggregator";
import { Grafana, Prometheus } from "diagrams-js/onprem/monitoring";
import { Nginx } from "diagrams-js/onprem/network";
import { Kafka } from "diagrams-js/onprem/queue";
const diagram = Diagram("Advanced Web Service with On-Premises (colored)");
const ingress = diagram.add(Nginx("ingress"));
const metrics = diagram.add(Prometheus("metric"));
const grafana = diagram.add(Grafana("monitoring"));
grafana.to(Edge({ color: "firebrick", style: "dashed" }), metrics);
const serviceCluster = diagram.cluster("Service Cluster");
const grpcsvc = [
serviceCluster.add(Server("grpc1")),
serviceCluster.add(Server("grpc2")),
serviceCluster.add(Server("grpc3")),
];
const sessionsCluster = diagram.cluster("Sessions HA");
const sessionPrimary = sessionsCluster.add(Redis("session"));
const sessionReplica = sessionsCluster.add(Redis("replica"));
sessionPrimary.with(Edge({ color: "brown", style: "dashed" }), sessionReplica);
sessionReplica.from(Edge({ label: "collect" }), metrics);
grpcsvc.forEach((svc) => svc.to(Edge({ color: "brown" }), sessionPrimary));
const dbCluster = diagram.cluster("Database HA");
const dbPrimary = dbCluster.add(PostgreSQL("users"));
const dbReplica = dbCluster.add(PostgreSQL("replica"));
dbPrimary.with(Edge({ color: "brown", style: "dotted" }), dbReplica);
dbReplica.from(Edge({ label: "collect" }), metrics);
grpcsvc.forEach((svc) => svc.to(Edge({ color: "black" }), dbPrimary));
const aggregator = diagram.add(Fluentd("logging"));
const kafka = diagram.add(Kafka("stream"));
const spark = diagram.add(Spark("analytics"));
aggregator.to(Edge({ label: "parse" }), kafka);
kafka.to(Edge({ color: "black", style: "bold" }), spark);
grpcsvc.forEach((svc) => {
ingress.to(Edge({ color: "darkgreen", forward: true, reverse: true }), svc);
});
grpcsvc.forEach((svc) => svc.to(Edge({ color: "darkorange" }), aggregator));
const svg = await diagram.render();
```

## RabbitMQ Consumers with Custom Nodes[](#rabbitmq-consumers-with-custom-nodes "Direct link to RabbitMQ Consumers with Custom Nodes")
```
import { Diagram, Custom, Iconify } from "diagrams-js";
import { Pod } from "diagrams-js/k8s/compute";
const diagram = Diagram("Broker Consumers");
const consumersCluster = diagram.cluster("Consumers");
const consumers = [
consumersCluster.add(Pod("worker")),
consumersCluster.add(Pod("worker")),
consumersCluster.add(Pod("worker")),
];
const queue = diagram.add(
// Use a custom icon from a URL
Custom("Message queue", "https://jpadilla.github.io/rabbitmqapp/assets/img/icon.png", {
width: "1.0",
}),
);
// Use Iconify icons
const database = diagram.add(Iconify("Database", "logos:aws-aurora"));
queue.to(consumers);
consumers.forEach((consumer) => consumer.to(database));
const svg = await diagram.render();
```

## Docker Compose Plugin Example[](#docker-compose-plugin-example "Direct link to Docker Compose Plugin Example")
This example demonstrates using the Docker Compose plugin.
```
import { Diagram } from "diagrams-js";
import { dockerComposePlugin } from "@diagrams-js/plugin-docker-compose";
const diagram = Diagram("E-commerce Application");
// Register the plugin instance
await diagram.registerPlugins([dockerComposePlugin]);
// Import from Docker Compose YAML
const composeYaml = `
version: "3.8"
name: ecommerce-app
services:
frontend:
image: nginx:alpine
ports:
- "80:80"
depends_on:
- api
api:
image: node:18
ports:
- "3000:3000"
depends_on:
- db
- cache
db:
image: postgres:15
environment:
POSTGRES_DB: ecommerce
volumes:
- pgdata:/var/lib/postgresql/data
cache:
image: redis:7-alpine
volumes:
pgdata:
`;
await diagram.import(composeYaml, "docker-compose");
// Render the diagram
const svg = await diagram.render();
```

Learn More
For a comprehensive guide on creating plugins, check out the [Plugin System](/docs/plugins/overview) documentation.
## Next Steps[](#next-steps "Direct link to Next Steps")
* Explore [all providers](/docs/guides/providers) and their available nodes
* Read the [complete API reference](/docs/guides/diagram)
* Try the [playground](/playground) for interactive examples
---
# Installation
## Node.js[](#nodejs "Direct link to Node.js")
Install [`diagrams-js`](https://www.npmjs.com/package/diagrams-js) using your preferred package manager:
* npm
* yarn
* pnpm
* bun
```
npm install diagrams-js
```
```
yarn add diagrams-js
```
```
pnpm add diagrams-js
```
```
bun add diagrams-js
```
Bun Version
Bun 1.3.0+ is required for diagrams-js to work properly due to WebAssembly support improvements.
### Optional Dependencies[](#optional-dependencies "Direct link to Optional Dependencies")
[Rendering](/docs/guides/rendering) SVG does not require any additional packages. However, for PNG and JPG rendering in Node.js, the package `sharp` is required:
* npm
* yarn
* pnpm
* bun
```
npm install sharp
```
```
yarn add sharp
```
```
pnpm add sharp
```
```
bun add sharp
```
## Browser Usage[](#browser-usage "Direct link to Browser Usage")
### Using a Bundler[](#using-a-bundler "Direct link to Using a Bundler")
Install via npm and import:
```
import { Diagram } from "diagrams-js";
import { EC2 } from "diagrams-js/aws/compute";
```
### Using CDN[](#using-cdn "Direct link to Using CDN")
```
```
### Using CDN with Import Map[](#using-cdn-with-import-map "Direct link to Using CDN with Import Map")
You can use import maps to enable bare module imports while loading from a CDN:
```
```
Import Maps
Import maps allow you to use bare module specifiers (like `diagrams-js/aws/compute`) instead of full URLs, making your code cleaner and more portable between bundler and CDN environments.
## Next Steps[](#next-steps "Direct link to Next Steps")
* Follow the [Quick Start guide](/docs/getting-started/quickstart) to create your first diagram
* Explore the [Examples](/docs/getting-started/examples) for real-world use cases
* Check out the [Node Reference](/docs/guides/providers) for all available providers and services
---
# Quick Start
Get started with diagrams-js in just a few lines of code.
## Basic Diagram[](#basic-diagram "Direct link to Basic Diagram")
Create a simple diagram with nodes and connections:
```
import { Diagram, Node } from "diagrams-js";
// Create a diagram
const diagram = Diagram("My First Diagram", {
// Diagram options
direction: "TB", // Top to Bottom
});
// Add nodes
const web = diagram.add(Node("Web Server"));
const app = diagram.add(Node("App Server"));
const db = diagram.add(Node("Database"));
// Connect them
web.to(app).to(db);
// Render to SVG
const svg = await diagram.render();
// Clean up
```

## Using Cloud Providers[](#using-cloud-providers "Direct link to Using Cloud Providers")
Import nodes from cloud providers to get automatic icons:
```
import { Diagram } from "diagrams-js";
import { EC2, Lambda } from "diagrams-js/aws/compute";
import { RDS } from "diagrams-js/aws/database";
import { S3 } from "diagrams-js/aws/storage";
import { ALB } from "diagrams-js/aws/network";
const diagram = Diagram("AWS Architecture", { direction: "TB" });
// Create nodes with icons
const lb = diagram.add(ALB("Load Balancer"));
const web = diagram.add(EC2("Web Server"));
const api = diagram.add(Lambda("API"));
const db = diagram.add(RDS("Database"));
const storage = diagram.add(S3("Storage"));
// Connect them
lb.to(web).to(api);
api.to([db, storage]);
// Render to SVG
const svg = await diagram.render();
```

## Browser Integration[](#browser-integration "Direct link to Browser Integration")
Display the diagram directly in the browser:
```