Create Mermaid-Js ERD diagrams from existing tables

Overview

Mermerd

Create Mermaid-Js ERD diagrams from existing tables.

Features

  • Supports PostgreSQL and MySQL
  • Select from available schemas
  • Select only the tables you are interested in
  • Show only the constraints that you are interested in
  • interactive cli (multiselect, search for tables and schemas, etc.)

Why would I need it / Why should I care?

Documenting stuff and keeping it updated is hard and tedious, but having the right documentation can help to make the right decisions. Mermerd was designed to be able to export an existing database schema in a format that can be used to prototype and plan new features based on the existing schema. The resulting output is an ERD diagram in Mermaid-Js format that can easily be updated and extended.

How does it work

  1. Specify the connection string (via parameter or interactive cli)
  2. Specify the schema that should be used (via parameter or interactive cli)
  3. Select the tables that you are interested in (multiselect, at least 1)
  4. Enjoy you current database schema in Mermaid-JS format
example.mp4

Parameters

Some configurations can be set via command line parameters. The parameters can also be viewed via mermerd -h

Parameter Description Example
c the connection string mermerd -c="postgresql://user:[email protected]:5432/dvdrental"
s the schema mermerd -s=public
ac toggle if all constraints should be included (default false) 1 mermerd -ac

Connection strings

Examples for connection strings:

How can I write/update Mermaid-JS diagrams?

  • All information can be found here: Mermaid-JS
  • I also recommend using an IDE with an Mermaid-JS extension, e.g. VS Code

Roadmap

  • Unit tests
  • Configurable suggestions for connection string input
  • Support }o--o| relation (currently displayed as }o--||)
  • Improve output file naming

Footnotes

  1. If the flag -ac is provided, mermerd will print out all constraints of the selected tables, even when the resulting constraint is not in the list of selected tables. These tables do not have any column infos and are only present via their table name.

Issues
  • add config: allow surrounding output with backticks

    add config: allow surrounding output with backticks

    Hi,

    thank you for this amazing work.

    I needed a few extra features for a project of mine, so I added them myself.

    Since I don't know if you are welcoming new additions or if this feature even is on your roadmap, feel free to reject this PR.

    If you want to discuss around this work, please do.

    Anyway, if you would like to know more about what I did:

    The idea was that I wanted to be able to directy preview output file. I therefore needed it to have the proper backticks characters for parsers to understand it.

    • Added a new config entry: encloseWithMermaidBackticks (boolean)
    • If this entry is not set, or false, behaviour will be default (nothing more than what mermerd already does)
    • If this entry is set to true, it will prefix output by "mermaid", and insert "" right before the ending new lines.

    Have a great day,

    opened by rvictorino 3
  • Cool idea of a tool!

    Cool idea of a tool!

    Hey @KarnerTh!

    This looks really cool and a promising idea. My immediate reflection is

    • Would it be possible to opt in on all tables?
    • Not force input interaction and relay on config/inputs
    • Make it more accessible to use in a CI / CD pipeline.
      • Maybe host it on docker?

    Eager to see more of this. Good work so far!

    opened by lillheaton 2
  • error with diagram's creation from mysql with lastest release

    error with diagram's creation from mysql with lastest release

    Hi

    Great tool, thank you !

    There is a bug with mysql connection

    .  ..___.__ .  ..___.__ .__
    |\/|[__ [__)|\/|[__ [__)|  \
    |  |[___|  \|  |[___|  \|__/ (dev)
    
    Create MermaidJs diagrams from your database
    
    ? Choose a schema: VIRO_NGS_COVID
    ? Choose tables: ALIAS_DICT, [...snip...]
    [                    ]Getting columns and constraintsError 1054: Unknown column 'c.TABLE_NAME' in 'on clause'
    
    
    X Something went wrong!
    

    A small typo in a query c.TABLE_NAME -> kc.TABLE_NAME

    Here, diff after bug fix from master branch

    diff --git a/database/mysql.go b/database/mysql.go
    index 82d1226..7ff4699 100644
    --- a/database/mysql.go
    +++ b/database/mysql.go
    @@ -113,7 +113,7 @@ func (c mySqlConnector) GetConstraints(tableName string) ([]ConstraintResult, er
                                       from information_schema.KEY_COLUMN_USAGE kc
                                                            left join information_schema.KEY_COLUMN_USAGE kc2
                                                                              ON kc.COLUMN_NAME = kc2.COLUMN_NAME AND kc2.CONSTRAINT_NAME = 'PRIMARY' AND
    -                                                                                kc2.TABLE_NAME = c.TABLE_NAME
    +                                                                                kc2.TABLE_NAME = kc.TABLE_NAME
                                       where kc.CONSTRAINT_NAME = c.CONSTRAINT_NAME
                               ) "isPrimary",
                               (
    

    A new build and it works :)

    ✓ Diagram was created successfully (result.mmd)
    

    Regards

    opened by littlebzh 1
  • Test setup

    Test setup

    • added testify for test assertion and mocks
    • refactored stuff to use interfaces/dependency injection
    • added unit tests
    • added integration tests
    • added github action that runs all tests on every push
    opened by KarnerTh 0
  • Command and config improvements

    Command and config improvements

    Refactored commands and config to use the Cobra and Viper package.

    Thanks to the feedback #2

    New features:

    • Fully POSIX-compliant flags (including short & long versions)
    • add the possibility to opt in for all tables
    • start mermerd with a predefined run config
    • add version command
    • show version number in header
    • improved help command output
    • exit with error code 1 on failure
    opened by KarnerTh 0
  • Add debug mode

    Add debug mode

    Hello, i was really hyped about your tool for documentation :).

    I just tried it on my DB and it does not want to do the job :

    more than one row in subquery
    

    And i have no clue about what is the problem.

    Maybe a --debug flag could be postponed to understand better why it would not work ?

    What do you think ?

    opened by Ragatzino 1
Releases(v0.1.0)
Example golang using gin framework everything you need, i create this tutorial special for beginner.

Golang Gin Framework Fundamental Example golang using gin framework everything you need, i create this tutorial special for beginner. Feature Containe

Restu Wahyu Saputra 65 Jun 22, 2022
Create a demo RESTful application using Golang

Instructions The goal of this exercise is to create a demo RESTful application using Golang. The Task In this task, we are building backend of an appl

Masaru Ohashi Júnior 0 Oct 30, 2021
Create a Protocol Buffers (Protobuf) plugin, which is executed with the protoc compileCreate a Protocol Buffers (Protobuf) plugin, which is executed with the protoc compile

Interview Assignment Overview You assignment is to create a Protocol Buffers (Protobuf) plugin, which is executed with the protoc compiler. In this ex

Patrick Valle 0 Nov 19, 2021
Create a short link

Shortlink using a GCP Cloud Run Serverless example Make a Dir: mkdir shortlink && cd shortlink Clone: git clone https://github.com/tonnytg/shortlink.

Antonio Thomacelli Gomes 0 Nov 26, 2021
This application is a tool to rapidly create TFS tasks and synchronize them with wiki.

This application is a tool to rapidly create TFS tasks and synchronize them with wiki.

Andrey Cherkashin 0 Jan 10, 2022
Give developers an easy way to create and integrate bank processing into their own software products

Community · Blog moov-io/bankcron Moov's mission is to give developers an easy way to create and integrate bank processing into their own software pro

moov 3 Mar 9, 2022
poCo: portable Containers. Create statically linked, portable binaries from container images (daemonless)

poCo Containers -> Binaries Create statically linked, portable binaries from container images A simple, static golang bundler! poCo (portable-Containe

Ettore Di Giacinto 63 Jun 28, 2022
Using golang framework (Gin) to create a web-application

News feeder Using golang framework (Gin) to create a web-application. This simpl

AmirH.Najafizadeh 1 Dec 20, 2021
ging is a tool for create gin web framework development templates

ging ging is a tool for create gin web framework development templates This tool is for the freshmen who want to learn golang and gin web framework, i

null 1 Jan 15, 2022
A new way to create web applications using go and sdf framework.

SDF GO A new way to create web applications using go and sdf framework Explore the docs » View Demo · Report Bug · Request Feature Table of Contents A

Metin Simsek 1 Feb 3, 2022
Create diagrams from the Kubernetes API with go-diagrams.

Kubernetes diagrams k8s-diagrams creates diagrams from your kubernetes clusters. You just have to provide a namespace (or not), and you get a picture

Pierre Erraud 121 Jun 28, 2022
This package provides Go (golang) types and helper functions to do some basic but useful things with mxGraph diagrams in XML, which is most famously used by app.diagrams.net, the new name of draw.io.

Go Draw - Golang MX This package provides types and helper functions to do some basic but useful things with mxGraph diagrams in XML, which is most fa

null 1 Nov 30, 2021
Create beautiful system diagrams with Go

Go-Diagrams Fast and easy application diagrams Go-Diagrams is a loose port of diagrams. Contents Features Usage Features Turn this: d, err := diagram.

null 3.6k Jun 29, 2022
RbacCustom - Create Tables Before executing the APIs

rbacCas Create Tables Before executing the APIs Members Table CREATE TABLE publi

Akash Desale 0 Feb 8, 2022
Generate High Level Cloud Architecture diagrams using YAML syntax.

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

Luca Sepe 535 Jun 16, 2022
A command line tool to generate sequence diagrams

goseq - text based sequence diagrams A small command line utility used to generate UML sequence diagrams from a text-base definition file. Inspired by

Leon Mika 180 Jun 29, 2022
Generate plantuml diagrams from go source files or directories

go-plantuml go-plantuml generates plantuml diagrams from go source files or directories. Installation go get -u github.com/bykof/go-plantuml Please co

Michael Bykovski 240 Jun 29, 2022
Generate plantuml diagrams from go source files or directories

go-plantuml go-plantuml generates plantuml diagrams from go source files or directories. Installation go get -u github.com/bykof/go-plantuml Please co

Michael Bykovski 240 Jun 29, 2022
A CLI for generating ER diagrams for Ent schema

enter A CLI for generating ER (entity-relationship) diagrams for Ent schema using mermaid.js.

Ariel Mashraki 91 Jun 21, 2022
Generate PlantUML diagrams from Chrome or Firefox network inspections

hoofli Generate PlantUML diagrams from Chrome or Firefox network inspections This tool reads browser HAR files stored on your local disk and transform

Pascal Dennerly 3 Feb 22, 2022
✨ #PTerm is a modern go module to beautify console output. Featuring charts, progressbars, tables, trees, and many more 🚀 It's completely configurable and 100% cross-platform compatible.

?? PTerm | Pretty Terminal Printer A golang module to print pretty text Show Demo Code PTerm.sh | Installation | Documentation | Quick Start | Example

null 2.8k Jun 30, 2022
Simple tables in terminal with Go

Simple tables in terminal with Go This package allows to generate and display ascii tables in the terminal, f.e.: +----+------------------+-----------

Alexey Popov 363 Jun 28, 2022
A tiny library for super simple Golang tables

Tabby A tiny library for super simple Golang tables Get Tabby go get github.com/cheynewallace/tabby Import Tabby import "github.com/cheynewallace/tabb

Cheyne Wallace 318 Jun 22, 2022
Tabular simplifies printing ASCII tables from command line utilities

tabular Tabular simplifies printing ASCII tables from command line utilities without the need to pass large sets of data to it's API. Simply define th

InVision 63 May 26, 2022
Fast, realtime regex-extraction, and aggregation into common formats such as histograms, numerical summaries, tables, and more!

rare A file scanner/regex extractor and realtime summarizor. Supports various CLI-based graphing and metric formats (histogram, table, etc). Features

Chris LaPointe 155 Jun 30, 2022
Utilities to prettify console output of tables, lists, progress-bars, text, etc.

go-pretty Utilities to prettify console output of tables, lists, progress-bars, text, etc. Table Pretty-print tables into ASCII/Unicode strings.

Naveen Mahalingam 1.3k Jun 30, 2022
Generate PlantUML ER diagram textual description from PostgreSQL tables

Generate PlantUML ER diagram textual description from PostgreSQL tables

Akira Chiku 463 Jun 21, 2022
The utility that created for easily database and their tables rolling up

The utility that created for easily database and their tables rolling up

null 0 Nov 6, 2021
CloudQuery extracts, transforms, and loads your cloud assets into normalized PostgreSQL tables.

The open-source cloud asset inventory backed by SQL. CloudQuery extracts, transforms, and loads your cloud assets into normalized PostgreSQL tables. C

CloudQuery 2.3k Jul 1, 2022