• Stars
    star
    572
  • Rank 77,995 (Top 2 %)
  • Language
    Go
  • License
    MIT License
  • Created over 4 years ago
  • Updated about 3 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Generate High Level Cloud Architecture diagrams using YAML syntax.

Draft

A commandline tool that generate High Level microservice & serverless Architecture diagrams using a declarative syntax defined in a YAML file.

Why?

I prefer to think in terms of capabilities rather than specific vendor services.

  • "do we need a DNS?" instead of "do we need Route 53?"
  • "do we need a CDN?" instead of "do we need Cloudfront?"
  • "do we need a database? if yes? what type? Relational? No SQL" instead of "do we need Google Cloud Datastore?"_
  • "do we need some serverless function?" instead of "do we need an Azure Function"

...and so on.

How draft works?

draft takes in input a declarative YAML file and generates a dot script for Graphviz

draft backend-for-frontend.yml | dot -Tpng -Gdpi=200 > backend-for-frontend.png 

Piping the draft output to GraphViz dot you can generate different output formats:

format command
PNG draft input.yml | dot -Tpng > output.png
JPEG draft input.yml | dot -Tjpg > output.jpg
PostScript draft input.yml | dot -Tps > output.ps
SVG draft input.yml | dot -Tsvg > output.svg

To install GraphViz to your favorite OS, please, follow this link https://graphviz.gitlab.io/download/.

Installation Steps

To build the binaries by yourself, assuming that you have Go installed, here the steps:

Clone the repo,

git clone https://github.com/lucasepe/draft.git

Move to the 'cmd' directory:

cd draft/cmd

Generate the static assets

go generate ../...

Build the binary tool

go build -o draft

Components

The basic unit of each draft design is the component, has these attributes:

Name Required Scope Notes
id no used for the connecttions autogenerated if omitted (read more for details...)
kind yes identify the component type see all available kinds
provider no get the specific provider icon see using custom icons
label no text below the component icon can contain basic HTML tags
outline no tag to group components
impl no text above the icon can use this to specify the provider implementation
fontColor no the label text color hex color code - supports transparency too

Notes about a component id

  • you can define your component id explicitly (i.e. id: MY_SERVICE_A)
  • or you can omit the component id attribute and it will be autogenerated

How is auto-generated a component id?

An auto-generated component id has a prefix and a sequential number

  • the prefix is related to the component kind
    • examples waf1, ..., wafN or ser1, ..., serN etc.

List of all available kinds

Draft uses a set of symbols independent from the different providers (AWS, Microsoft Azure, GCP).

Below is a list of all the components currently implemented.

Clients

Sample YAML file examples/clients.yml.

draft -impl -verbose examples/clients.yml | dot -Gdpi=110 -Tpng > examples/clients.png

Clients

Networking

Sample YAML file examples/networking.yml.

draft -impl -verbose examples/networking.yml | dot -Gdpi=110 -Tpng > examples/networking.png

Networking

Compute

Sample YAML file examples/compute.yml.

draft -impl -verbose examples/compute.yml | dot -Gdpi=110 -Tpng > examples/compute.png

Compute

Database

Sample YAML file examples/database.yml.

draft -impl -verbose examples/database.yml | dot -Gdpi=110 -Tpng > examples/database.png

Database

Storage

Sample YAML file examples/storage.yml.

draft -impl -verbose examples/storage.yml | dot -Gdpi=110 -Tpng > examples/storage.png

Storage

Security

Sample YAML file examples/security.yml.

draft -impl -verbose examples/security.yml | dot -Gdpi=110 -Tpng > examples/security.png

Security

Using custom icons

Here how to render components with specific aws, google and azure icons.

  1. Download the PNG icons of your cloud provider AWS, GCP, Azure

  2. Take only the icons related to the components supported by draft

  3. Make a directory with the provider name (i.e. /draft/icons/aws, /draft/icons/google, /draft/icons/azure)

  4. Rename each icon as draft components kind (i.e. dns.png, cdn.png and so on...)

  5. Run draft specifyng the icons folder using the environment variable DRAFT_ICONS_PATH

  • example: DRAFT_ICONS_PATH=/draft/icons draft my-file.yml | dot > ark-aws.png

πŸ‘‰ I have already done all the work for points 1 to 4. So you can avoid it by copying the directory icons πŸ‘ˆ

Connections

The arrows that join the components.

To connect an origin component with one or more targets component you need to specify at least each id.

A connection has the following properties:

Attribute Type Required What is it?
origin string yes id of the starting component
targets object yes one or more destinations

Each target has the following properties:

Attribute Type Required What is it?
id string yes target component id
label string no text on the connection
labeldistance float no distance of the label from the connection tail
labelangle float no determine the label position relative to the tail
minlen float no sets the minimum connection length
num int no usefult to track an order path on your graph
color string no label color (hex color string)
dashed bool no if true the connection line will be dashed
dir string no arrows direction (forward, back, both, none)
highlight bool no if true makes the arrow thicker

Sample YAML file examples/connections.yml.

draft examples/connections.yml | dot -Gdpi=110 -Tpng > examples/connections.png

Connections

Twitter


Changelog

πŸ‘‰ Record of all notable changes made to a project


Examples

πŸ‘‰ Collection of draft architecture descriptor YAML files


(c) 2020 Luca Sepe http://lucasepe.it. MIT License

More Repositories

1

modgv

Converts 'go mod graph' output into Graphviz's DOT language
Go
474
star
2

yml2dot

Turn YAML into beautiful Graph
Go
132
star
3

jumble

Create (not just) diagrams stitching, connecting and labelling images on a grid using HCL syntax (like terraform!).
Go
105
star
4

crumbs

Turn asterisk-indented text lines into mind maps
Go
101
star
5

codename

Generate random, pronounceable, sometimes even memorable, "superhero like" codenames - just like Docker does with container names.
Go
100
star
6

tiles

Commandline tool that makes building tilesets and rendering static tilemaps super easy!
Go
51
star
7

lib_mysqludf_haversine

MySQL UDF to compute the Haversine formula
C
46
star
8

go-ps4

Search your favorite PS4 games from Playstation Store using the Command Line
Go
44
star
9

g2d

Craft beautiful geometric art using code.
Go
43
star
10

using-client-go

Source code related to my Golang Notebook "Using client-go"
Go
30
star
11

tbd

"to be defined" - a really simple way to create text templates with placeholders
Go
24
star
12

grasp

Create strong passwords using words that are easy for you to remember. A password manager that does not require any type of storage
Go
22
star
13

uri

A commandline tool to resolve URI Templates expressions as specified in RFC 6570.
Go
17
star
14

pwsafe

Cross Platform simple and secure password management from commandline.
Go
16
star
15

yo

An alternative syntax to generate YAML (or JSON) from commandline. => https://youtu.be/QL6DsCLFQ30
Go
10
star
16

clon

A convenient syntax to generate JSON (or YAML) for commandline "mumbo-jumbo".
Go
9
star
17

gptcli

An interactive ChatGPT client featuring shortcuts and auto-complete.
Go
7
star
18

kvs

KVS is a commandline tool to store and organize key-value data on your local file system.
Go
6
star
19

dot

Go package for writing Graph descriptions using the Graphviz DOT language
Go
6
star
20

slackify

Upload files to your preferred Slack channels using CLI or pipe in stdin
Go
3
star
21

memo

Store and organize notes on your local file system.
Go
3
star
22

locker

Store secrets on your local file system.
Go
3
star
23

yamldo

Create YAML documents from a directory tree or a ZIP archive.
Go
2
star
24

lib_mysqludf_qrencode

MySQL UDF for QRCode generation
C
2
star
25

local-container-registry

Create a local development environment to pull/push your images without relying on external services.
Makefile
1
star
26

expose

Markdown Driven Slides Viewer
Go
1
star
27

image-cloner

kubernetes controller that watches the Deployments and β€œcaches” the images by re-uploading to your own registry repository and reconfiguring the applications to use these copies
Go
1
star
28

envsubst

Go package emulates bash environment variable substitution
Go
1
star
29

giso

isometric graphics library
Go
1
star
30

mini

Parse (sort of) INI files like "flag" package in Go.
Go
1
star
31

markdown

A CommonMark-compliant markdown parser and renderer in Go.
Go
1
star
32

gg

Go Graphics - 2D rendering in Go with a simple API.
Go
1
star
33

todoist

A Go library for Todoist's REST API
Go
1
star
34

totp

Simple library to generate TOTP codes and parse TOTP URIs
Go
1
star
35

boilr

Projects and text templates using ${var} expansion syntax.
Go
1
star
36

strcase

Utilities for converting strings between different cases
Go
1
star
37

spinner

Simple activity indicator for your command line tools.
Go
1
star
38

nginx_apikey_access_filter_module

Nginx filter to restrict the access at your backend APIs
1
star
39

terraform-provider-codename

The Terraform Codename provider is used to generate random _"superhero like"_ codenames.
Go
1
star
40

xdg

Go
1
star