https://github.com/bruce-mig/diagram-as-code
System Design diagrams for various projects for my GitHub account, created using the diagram as code paradigm
https://github.com/bruce-mig/diagram-as-code
diagram-as-code
Last synced: 12 months ago
JSON representation
System Design diagrams for various projects for my GitHub account, created using the diagram as code paradigm
- Host: GitHub
- URL: https://github.com/bruce-mig/diagram-as-code
- Owner: bruce-mig
- Created: 2024-02-29T05:53:30.000Z (over 2 years ago)
- Default Branch: main
- Last Pushed: 2024-10-04T10:07:55.000Z (over 1 year ago)
- Last Synced: 2025-03-11T21:51:54.229Z (over 1 year ago)
- Topics: diagram-as-code
- Language: Python
- Homepage: https://github.com/bruce-mig
- Size: 2.63 MB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Diagram as Code (DaC)
This repo contains system design diagrams for various projects for [my GitHub account](https://github.com/bruce-mig), created using the diagram as code paradigm. Diagram as code is a way of drawing diagrams using code, which makes them easier to maintain, version control, and collaborate on.
## How it works
The diagrams in this repo are created using the [Diagrams](https://diagrams.mingrammer.com/) Python library, which supports various providers, languages, and frameworks.
To generate a diagram, you need to write a Python script that defines the nodes and edges of your system, using the Diagrams API. Then, you can run the script and it will produce a PNG image of your diagram.
For example, here is a script that draws a simple web service architecture:
```python
from diagrams import Cluster, Diagram
from diagrams.aws.compute import ECS
from diagrams.aws.database import ElastiCache, RDS
from diagrams.aws.network import ELB
from diagrams.aws.network import Route53
with Diagram("Clustered Web Services", show=False):
dns = Route53("dns")
lb = ELB("lb")
with Cluster("Services"):
svc_group = [ECS("web1"),
ECS("web2"),
ECS("web3")]
with Cluster("DB Cluster"):
db_primary = RDS("userdb")
db_primary - [RDS("userdb ro")]
memcached = ElastiCache("memcached")
dns >> lb >> svc_group
svc_group >> db_primary
svc_group >> memcached
```
And here is the output image:

## How to use this repo
You can browse the existing diagrams in this repo, or create your own ones. To create a new diagram, follow these steps:
- Install Python 3.6 or higher and the Diagrams library. For more information, see the [Diagrams installation guide](https://diagrams.mingrammer.com/docs/getting-started/installation).
- Create a new Python file in the `diagrams` folder, with a descriptive name. For example, `invoicing_system.py`.
- Write your diagram code using the Diagrams API. You can use the [Diagrams documentation](https://diagrams.mingrammer.com/docs/guides/diagram) and the [examples](https://diagrams.mingrammer.com/docs/nodes/aws) for reference.
- Run your script to generate the image file. It will be saved in the same folder as your script, with the same name but with a `.png` extension. For example, `invoicing_system.png`.
- Add your script and image file to the repo, and commit your changes. Optionally, you can also update the `README.md` file to include a description and a preview of your diagram.