Git Product home page Git Product logo

rediagram's Introduction

License: MIT code style: prettier PRs Welcome All Contributors

rediagram

Markup and draw your system diagrams with React.

Key Feature

Draw Your System with JSX/TSX

Code your system architecture in the style of React, JSX/TSX.

MyInfra.rediagram.tsx

import React from 'react';
import { PNG, Diagram, GeneralIcon } from 'rediagram';
import { AWS, InvizAWS, EC2, Lambda, Region, SecurityGroup, AutoScalingGroup } from '@rediagram/aws';

PNG(
  <Diagram title="My Infra">
    <InvizAWS>
      <AWS>
        <Region name="Asia Pacific (Tokyo)">
          <AutoScalingGroup>
            <EC2 name="REST API" type="Instance" upstream={['worker4']} />
          </AutoScalingGroup>
          <SecurityGroup>
            <Lambda name="worker4" type="Lambda Function" upstream={['worker5', 'worker6']} />
            <Lambda name="worker5" type="Lambda Function" />
            <Lambda name="worker6" type="Lambda Function" />
          </SecurityGroup>
        </Region>
      </AWS>
      <GeneralIcon name="Browser" type="Client" upstream={['REST API']} />
    </InvizAWS>
  </Diagram>,
);

Running this file will generate a diagram of MyInfra.rediagram.png.

$ ts-node MyInfra.rediagram.tsx

MyInfra

You can choose PNG, SVG, or PDF as the output format.

See more examples.

Note: Do you want to execute them all at once?

We provide the rediagramc command that generates images at once by matching the patterns of **/*.rediagram.tsx.

See @rediagram/cli for more details.

Easy to setup

You can set up a project with one command by using create-rediagram-project.

# yarn create rediagram-project <project-name>
$ yarn create rediagram-project my-rediagram
  ๐ŸŒˆ Creating new rediagram project in my-rediagram.
  ...

See this document for more information.

Packages

Requirement

This project requires Graphviz. If you don't have it installed, install it here.

Contributors

Thanks goes to these wonderful people (emoji key):

Yuki Yamazaki
Yuki Yamazaki

๐Ÿ’ป ๐Ÿ–‹ ๐ŸŽจ ๐Ÿ’ก
odd
odd

๐Ÿ›
fealone
fealone

๐Ÿค” โš ๏ธ ๐Ÿ›
78hack
78hack

๐Ÿ’ป ๐Ÿ›
YukiSasaki
YukiSasaki

๐Ÿค”
Tatsuya Yamamoto
Tatsuya Yamamoto

๐Ÿ’ป
tubone(Yu Otsubo)
tubone(Yu Otsubo)

๐Ÿ›
mattfirtion
mattfirtion

๐Ÿ› ๐Ÿ’ป

This project follows the all-contributors specification. Contributions of any kind welcome!

License

This software is released under the MIT License, see LICENSE.

rediagram's People

Contributors

78hack avatar allcontributors[bot] avatar dependabot-preview[bot] avatar dependabot[bot] avatar kamiazya avatar mattfirtion avatar tubone24 avatar yamatatsu avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

rediagram's Issues

Embed images when outputting SVG

Is your feature request related to a problem? Please describe.

When outputting SVG, the image is the path of the file.

Portability is not good because the file path cannot be referenced at the time of distribution.

Describe the solution you'd like

Base64 encode the image and embed it in SVG.

Upgrade GCP icons

Is your feature request related to a problem? Please describe.

The GCP icon has been updated, but it is not supported.

Describe the solution you'd like

Update the component icon to a new one.

It also supports new services.

Additional context

https://cloud.google.com/icons

Create a package dependency diagram

Problems

There are a lot of packages, and it is difficult to understand the dependencies and purposes.

How to solve

Create a diagram that visualizes dependencies to increase project transparency.

If upstream and downstream are mixed, the orientation is incorrect.

Describe the bug
If upstream and downstream are mixed, the orientation described earlier has priority.

  • Example code
<AppEngine
    name="ExampleA"
    upstream={["ExampleB"]}
    downstream={["ExampleB"]}
/>
  • Expected diagram

ExampleA -> ExampleB
ExampleA <- ExampleB

  • Actual diagram

ExampleA -> ExampleB
ExampleA -> ExampleB

Add error handling

Is your feature request related to a problem? Please describe.

The exceptions of the rediagram component cannot be handled and the error is difficult to understand.

Describe the solution you'd like

Consider adding an error boundary to your tree to customize error handling behavior.
Visit https://fb.me/react-error-boundaries to learn more about error boundaries.

Additional context

Display known errors such as useAssertProvider in an easy-to-understand manner.

Add Example

Ideas

  • Add an example diagram of a multi-cloud configuration to the gallery.

Allows changing the edge color and style

Is your feature request related to a problem? Please describe.

Visibility is poor because the color and type of the tip are the same.

Describe the solution you'd like

  • Allows changing the color and style of the edges.
  • Allows specifying by edge color or style theme.
  • Edge is automatically color-coded.

the Browser image vanishes

I caught the below error.

$ git clone https://github.com/kamiazya/rediagram.git
$ cd rediagram/docker

// I wrote a model that same as the example in README.md.
$ vim MyInfra.rediagram.tsx
$ make build
...
$ docker run --rm -v `pwd`:/workdir/ rediagram:0.1.1
(node:1) UnhandledPromiseRejectionWarning: Error: Command failed: dot -Tpng -o MyInfra.rediagram.png
Warning: No such file or directory while opening /node_modules/@rediagram/aws/assets/general/Client.png
Error: No or improper image file="/node_modules/@rediagram/aws/assets/general/Client.png"
in label of node Browser
Warning: Arrow type "point" unknown - ignoring

    at checkExecSyncError (child_process.js:630:11)
    at Object.execSync (child_process.js:666:15)
    at Object.renderDot (/node_modules/@ts-graphviz/node/lib/index.js:51:15)
    at renderToFile (/node_modules/rediagram/lib/render.js:13:12)
    at render (/node_modules/rediagram/lib/render.js:17:5)
    at Object.PNG (/node_modules/rediagram/lib/render.js:27:5)
    at Object.<anonymous> (/workdir/MyInfra.rediagram.tsx:5:1)
    at Module._compile (internal/modules/cjs/loader.js:1138:30)
    at Module.m._compile (/usr/local/share/.config/yarn/global/node_modules/ts-node/src/index.ts:1043:23)
    at Module._extensions..js (internal/modules/cjs/loader.js:1158:10)
(node:1) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 1)
(node:1) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

Providing components that can express grouping such as VPC from rediagram package

Is your feature request related to a problem? Please describe.

Although there are groupings such as VPC, it exists only in AWS and GCP packages, and it was not suitable for abstract discussions that do not depend on specific infrastructure.

Describe the solution you'd like

A component that expresses abstract grouping such as Group is provided from the rediagram package.

`create-rediagram-project ` is not work

Describe the bug
I tried yarn start and following error is occurred.

src/MyInfra.rediagram.tsx
(node:24669) UnhandledPromiseRejectionWarning: Error: spawn dot ENOENT
    at Process.ChildProcess._handle.onexit (internal/child_process.js:269:19)
    at onErrorNT (internal/child_process.js:465:16)
    at processTicksAndRejections (internal/process/task_queues.js:80:21)

To Reproduce
Steps to reproduce the behavior:

> yarn create rediagram-project my-rediagram
> yarn start

Expected behavior
Success yarn start, without errors.

Screenshots
If applicable, add screenshots to help explain your problem.

  • OS: [macos catalina 10.15.7]
  • Node.js version [14.x]
  • Package Name
    • create-rediagram-project
  • Package Version
    • latest

Additional context

I tried to catch error. Result is following;


Error: spawn dot ENOENT
    at Process.ChildProcess._handle.onexit (internal/child_process.js:269:19)
    at onErrorNT (internal/child_process.js:465:16)
    at processTicksAndRejections (internal/process/task_queues.js:80:21) {
  errno: -2,
  code: 'ENOENT',
  syscall: 'spawn dot',
  path: 'dot',
  spawnargs: [
    '-Tpng',
    '-o',
    '/my/project/dir/my-rediagram/img/MyInfra.rediagram.png',
    '/var/folders/fr/5qmpnmcs41v1ypvgv454y6c40000gq/T/tmp-27783-vtNDIm2O94H7'
  ],
  cmd: 'dot -Tpng -o /my/project/dir/my-rediagram/img/MyInfra.rediagram.png /var/folders/fr/5qmpnmcs41v1ypvgv454y6c40000gq/T/tmp-27783-vtNDIm2O94H7',
  stdout: <Buffer >,
  stderr: <Buffer >
}

This is occurred at here https://github.com/ts-graphviz/node/blob/master/src/executeDot.ts#L25 , i think.

I don't remove ./my-rediagram/img folder.

tmp-promise has something wrong?

thanks.

Support yarn on create-rediagram-project

Is your feature request related to a problem? Please describe.

The create-rediagram-project command does not support yarn.

Describe the solution you'd like

Allow the user to choose between npm and yarn when executing the command.

Watch the target file with CLI

Problems

Since rediagramc only executed the target file once, I had to execute the command every time and the experience was not good.

How to solve

Provides an option to detect file changes and allow re-rendering with the redigramc CLI.

add ci

Check lint rule and build, test if possible.

EC2 type AutoScaling is broken

Describe the bug
A clear and concise description of what the bug is.

To Reproduce
Steps to reproduce the behavior:

  1. Go to '...'
  2. Click on '....'
  3. Scroll down to '....'
  4. See error

Expected behavior
A clear and concise description of what you expected to happen.

Screenshots
If applicable, add screenshots to help explain your problem.

  • OS: [e.g. macos, windows, linux]
  • Node.js version [e.g. 10.x, 12.x, 14.x]
  • Package Name
  • Package Version

Additional context
Add any other context about the problem here.

Create a package for the starter kit

Create a starter kit to make it easier to create a rediagram package with the command below.

$ npx create-rediagram-diagram
$ yarn create rediagram-diagram

Add lint and format npm-scripts to the project created by create-rediagram-project

Is your feature request related to a problem? Please describe.

The project created by create-rediagram-project has no coding rules, so maintainability may deteriorate.

Describe the solution you'd like

When creating a project, install code formatting tools such as eslint and prettier in advance.

Describe alternatives you've considered

Add options to the cli and let the user choose if they need a lint mechanism.

Error handling on cli

Is your feature request related to a problem? Please describe.

The error is not handled by cli.

like this issue.

#97

Describe the solution you'd like

Display the error details appropriately.

ASWใฎใ‚ขใ‚คใ‚ณใƒณใซใ‚ตใƒผใƒ“ใ‚นๅใŒๅ‡บใ‚‹ใ‚ˆใ†ใซใ—ใŸใ„

Is your feature request related to a problem? Please describe.
AWSใซ่ฉณใ—ใใชใ„้กงๅฎขใ‚„ใƒกใƒณใƒใƒผใจไผš่ฉฑใ™ใ‚‹้š›ใซใ€AWSใฎใ‚ขใ‚คใ‚ณใƒณใŒใฉใฎใ‚ตใƒผใƒ“ใ‚นใ‚’ๆŒ‡ใ—ใฆใ„ใ‚‹ใฎใ‹ใ‚ใ‹ใ‚Šใšใ‚‰ใ„

Describe the solution you'd like
AWSใฎใ‚ขใ‚คใ‚ณใƒณใซใ‚ตใƒผใƒ“ใ‚นๅใ‚’ๅ‡บใ›ใ‚‹ใ‚ˆใ†ใซใ™ใ‚‹ใ“ใจ

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.