Skip to content

uladzimirFilipchanka/noredraw

Repository files navigation

Because life is too short to redraw diagrams

No Redraw

NoReDraw is a handy command line java-based tool that converts your source code into diagram

Have you ever wondered about adding a nice diagram for your architecture? Have you ever had time for that? Are you up for maintaining the diagram for eternity?

No worries, I've got your back. Just run NoReDraw tool against your repo and it will generate diagram of desired type. All local, no internet, no fancy AIs.

wget https://github.com/uladzimirFilipchanka/noredraw/raw/main/noredraw.sh && chmod +x noredraw.sh

./noredraw.sh \
--source https://github.com/uladzimirFilipchanka/noredraw-sample.git \
--export MERMAID \
--output ./my-shiny-diagram.txt

Now you can insert generated diagram into your comapny's wiki and it will get rendered as an image (GitHub, Confluence and many more support it).

Example of the diagram:

graph TB
  linkStyle default fill:#ffffff

  subgraph diagram ["My-shiny-diagram"]
    style diagram fill:#ffffff,stroke:#ffffff

    1["<div style='font-weight: bold'>Dockerfile\n[Dockerfile]</div><div style='font-size: 70%; margin-top: 0px'></div><div style='font-size: 80%; margin-top:10px'>baseImage:eclipse-temurin:17<br />entrypoint:java -jar<br />/app/arch-diagram-sample.jar<br />path:Dockerfile port:80</div>"]
    style 1 fill:#1168bd,stroke:#0b4884,color:#ffffff
    10["<div style='font-weight: bold'>app-first-service\n[AmazonECS]</div><div style='font-size: 70%; margin-top: 0px'></div>"]
    style 10 fill:#1168bd,stroke:#0b4884,color:#ffffff
    11["<div style='font-weight: bold'>Terraform</div><div style='font-size: 70%; margin-top: 0px'></div>"]
    style 11 fill:#1168bd,stroke:#0b4884,color:#ffffff
    13["<div style='font-weight: bold'>arch-diagram-sample\n[Jar]</div><div style='font-size: 70%; margin-top: 0px'></div><div style='font-size: 80%; margin-top:10px'>targetPath:build/libs/arch-diagram-sample*.jar</div>"]
    style 13 fill:#1168bd,stroke:#0b4884,color:#ffffff
    14["<div style='font-weight: bold'>Gradle</div><div style='font-size: 70%; margin-top: 0px'></div>"]
    style 14 fill:#1168bd,stroke:#0b4884,color:#ffffff
    2["<div style='font-weight: bold'>FileSystem</div><div style='font-size: 70%; margin-top: 0px'></div>"]
    style 2 fill:#1168bd,stroke:#0b4884,color:#ffffff
    4["<div style='font-weight: bold'>app-first-task\n[AmazonECSTaskDeployment]</div><div style='font-size: 70%; margin-top: 0px'></div><div style='font-size: 80%; margin-top:10px'>cluster:app-cluster<br />family:app-first-task<br />image:venom27/arch-diagram-sample:latest<br />service:app-first-service</div>"]
    style 4 fill:#1168bd,stroke:#0b4884,color:#ffffff
    5["<div style='font-weight: bold'>Github Actions</div><div style='font-size: 70%; margin-top: 0px'></div>"]
    style 5 fill:#1168bd,stroke:#0b4884,color:#ffffff
    8["<div style='font-weight: bold'>venom27/arch-diagram-sample:latest\n[DockerImage]</div><div style='font-size: 70%; margin-top: 0px'></div><div style='font-size: 80%; margin-top:10px'>path:Dockerfile<br />tag0:venom27/arch-diagram-sample:latest<br />tag1:venom27/arch-diagram-sample:${{env.RELEASE_VERSION}}</div>"]
    style 8 fill:#1168bd,stroke:#0b4884,color:#ffffff

    11-. "<div>provisions</div><div style='font-size: 70%'></div>" .->10
    14-. "<div>builds</div><div style='font-size: 70%'></div>" .->13
    1-. "<div>containerize</div><div style='font-size: 70%'></div>" .->13
    4-. "<div>assigns</div><div style='font-size: 70%'></div>" .->8
    8-. "<div>creates</div><div style='font-size: 70%'></div>" .->1
    10-. "<div>deploys</div><div style='font-size: 70%'></div>" .->4
    2-. "<div>defines</div><div style='font-size: 70%'></div>" .->1
    5-. "<div>prepares</div><div style='font-size: 70%'></div>" .->4
    2-. "<div>defines</div><div style='font-size: 70%'></div>" .->4
    5-. "<div>builds</div><div style='font-size: 70%'></div>" .->8
  end

Alternatively NoReDraw can generate good old PNG for you by specifying --export PNG (internet connection required)

Export Formats

Currently next export formats are supported:

You can always implement your own Exporter and use it right away. See Customization for more details

Supported providers

NoReDraw delegates creating of resources to Providers. Providers yield lists of resources, typically generated by parsing specific file types (Dockerfiles, *.tf, etc). These resources then undergo linking and merging stages.

Currently next providers are supported out of the box:

New providers are highly encouraged! The project is currently in PoC and active development stages, feel free to contribute!

Alternatively, you can implement your own provider and use it right away. See Customization for more details

Input sources

You can use the `--source` parameter with either an URL to a public repository or a path pointing to the repo's directory. Private repositories aren't supported right now.

Customization

NoReDraw is exteremely simple and highly customizable by design. You can implement your own pieces of the tool, pack them in Jar and use with NoReDraw.

You can write your own Provider, Exporter, MergeStrategy or LinkStrategy in a minutes.

  1. Import noredraw-core into your project
dependencies {
    implementation 'io.github.uladzimirfilipchanka:noredraw-core:0.0.1'
}
  1. Implement an interface, for example LinkStrategy
@Named("MY_LINKING_STRATEGY")
public class MyCustomMatchLinkStrategy implements LinkStrategy {
    @Override
    public boolean linkable(Relic left, Relic right) {
      return left.getName().equals(right.getName());
    }
}
  1. Build a Jar, put it under custom folder next to noredraw.jar.
  2. Run ./noredraw specifying --link MY_LINKING_STRATEGY
  3. Enjoy

You can find example of the custom prover in noredraw-custom-example module

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages