Generate architecture diagrams using Python diagrams library from user descriptions. Analyzes architectures, selects appropriate nodes, and produces executable Python code for visual diagrams.
Generate architecture diagrams using the Python `diagrams` library. Convert user descriptions into visual diagrams by analyzing system architectures, selecting appropriate components, and producing executable Python code.
This skill enables you to create architecture diagrams programmatically by:
- Example: `diagrams.onprem.analytics.Spark` for Apache Spark
- Example: `diagrams.aws.compute.EC2` for AWS EC2 instances
- `diagrams.generic.os.LinuxGeneral`
- `diagrams.generic.blank.Blank`
Follow this structure:
```python
from diagrams import Diagram, Cluster, Edge
from diagrams.onprem.database import Postgresql
from diagrams.onprem.network import Nginx
with Diagram("Architecture Name", show=False, direction="LR"):
# Use Clusters to group related components
with Cluster("Service Layer"):
web = Nginx("Web Server")
app = LinuxGeneral("App Server")
# Define standalone components
db = Postgresql("Database")
# Create connections with edges
web >> Edge(label="forwards") >> app
app >> Edge(label="queries") >> db
```
**Key Patterns:**
```python
from diagrams import Diagram, Cluster, Edge
from diagrams.onprem.network import Nginx
from diagrams.onprem.compute import Server
from diagrams.onprem.database import Postgresql
with Diagram("Web App Architecture", show=False):
with Cluster("Frontend"):
lb = Nginx("Load Balancer")
with Cluster("Application"):
app = Server("App Server")
db = Postgresql("Database")
lb >> Edge(label="routes") >> app
app >> Edge(label="queries") >> db
```
```python
from diagrams import Diagram, Cluster, Edge
from diagrams.onprem.queue import Kafka
from diagrams.onprem.database import MongoDB
from diagrams.generic.os import LinuxGeneral
with Diagram("Microservices", show=False, direction="LR"):
with Cluster("Services"):
svc1 = LinuxGeneral("Service A")
svc2 = LinuxGeneral("Service B")
queue = Kafka("Message Queue")
db = MongoDB("Document Store")
svc1 >> Edge(label="publishes") >> queue
queue >> Edge(label="consumes") >> svc2
svc2 >> Edge(label="stores") >> db
```
```python
from diagrams import Diagram, Cluster, Edge
from diagrams.onprem.analytics import Spark
from diagrams.onprem.queue import Kafka
from diagrams.onprem.database import Cassandra
with Diagram("Event Processing", show=False):
ingestion = Kafka("Event Ingestion")
with Cluster("Processing"):
processor = Spark("Stream Processor")
storage = Cassandra("Time Series DB")
ingestion >> Edge(label="streams") >> processor
processor >> Edge(label="writes") >> storage
```
Leave a review
No reviews yet. Be the first to review this skill!
# Download SKILL.md from killerskills.ai/api/skills/diagram-generator-python-diagrams/raw