Diagram as Code (Service architecture diagram)

Hai Le Phu
Eway Engineering
Published in
2 min readSep 7, 2020

Make code documentation more clear. It’s that way I will do for you today.

Diagrams let you draw a system architecture in Python code. It was born for prototyping without any design tools. You can also describe or visualize the existing system architecture.

Positive to thing about it:

  • Allows you to track the architecture diagram changes on any version control system.

Diagrams currently support these major provider, resource type, and name.
You may already have seen each part in the example on the official website.
Here we go: https://diagrams.mingrammer.com/docs/guides/node

Now, let’s begin!

You can start with this quick start. You can go to the guides for more details.

To make things more specials today. I will explain, how I work with GitLab CI.

  1. Diagrams per microservice.
Create diagram.py file$ touch project_path/resource/diagram.py

And describe service architecture & business logic.

2. Build CI for automation README document

3. Add artifact resource to README.md file

## Diagram
[View from Artifact](https://gitlab.com/flexsale/api-shipping-postback/-/jobs/artifacts/master/file/diagram.png?job=create_diagrams)
![Consumer Processing Diagram](https://gitlab.com/flexsale/api-shipping-postback/-/jobs/artifacts/master/raw/diagram.png?job=create_diagrams)

Conclusion

I appreciate this tool because I prefer coding than a draw. We can put it to running in a version control system and generate diagrams in each tag or release. If you have any questions or suggestions, leave a comment, or reach out to me.

Thanks for reading!

References:

--

--