Go implementation of a HTTP server to allow remote generation of mermaid-js diagrams without any pre-requisites installed locally.
Go to file
Matt 707e87e454 more updates 2025-05-24 11:59:34 +02:00
.github Bump actions/cache from 3.0.4 to 3.0.10 2022-10-10 07:08:16 +00:00
cmd/app Add --allow-all-origins arg 2022-09-29 16:29:44 +01:00
internal more updates 2025-05-24 11:59:34 +02:00
mermaidcli more updates 2025-05-24 11:59:34 +02:00
.gitignore Initial commit with basic HTTP endpoint working 2020-04-06 23:25:47 +01:00
Dockerfile more updates 2025-05-24 11:27:00 +02:00
LICENSE Create LICENSE 2024-12-20 22:08:02 +00:00
Makefile Do some cleanup and add a Makefile 2020-10-02 14:33:34 +01:00
README.md Update README.md 2024-03-28 12:53:30 +00:00
alternative_api_call.js more updates 2025-05-24 11:45:48 +02:00
basic_test.mmd more updates 2025-05-24 11:45:48 +02:00
debug_request.js more updates 2025-05-24 11:45:48 +02:00
docker-compose.yml more updates 2025-05-24 11:45:48 +02:00
enhanced_conversion_script.js more updates 2025-05-24 11:59:34 +02:00
example.png Add example image 2020-04-06 23:29:21 +01:00
final_fixed_api_call.js more updates 2025-05-24 11:59:34 +02:00
fixed_api_call.js more updates 2025-05-24 11:45:48 +02:00
go.mod updated mermaid-cli 2025-05-24 11:14:38 +02:00
go.sum Use grace instead of lifetime 2021-08-14 16:34:07 +01:00
simple_post_fix.js more updates 2025-05-24 11:59:34 +02:00
simple_working_chart.mmd more updates 2025-05-24 11:45:48 +02:00
single_line_examples.md more updates 2025-05-24 11:59:34 +02:00
smart_conversion_script.js more updates 2025-05-24 11:59:34 +02:00
test_bar_chart.mmd updates 2025-05-24 11:21:16 +02:00
test_different_syntax.js more updates 2025-05-24 11:59:34 +02:00
test_url_encoding.js more updates 2025-05-24 11:45:48 +02:00
test_urlsearchparams.js more updates 2025-05-24 11:59:34 +02:00
test_workflow_format.js more updates 2025-05-24 11:45:48 +02:00
working_analytics_chart.mmd more updates 2025-05-24 11:45:48 +02:00
working_bar_chart.mmd more updates 2025-05-24 11:45:48 +02:00
working_single_line_mermaid.md more updates 2025-05-24 11:59:34 +02:00

README.md

mermaid-server

Use mermaid-js to generate diagrams in a HTTP endpoint.

While this currently serves the diagrams via HTTP, it could easily be manipulated to server diagrams via other means.

Basic usage

Docker

Run the container:

docker run -d --name mermaid-server -p 80:80 tomwright/mermaid-server:latest

Manually as a go command

Start the HTTP server:

go run cmd/app/main.go --mermaid=./mermaidcli/node_modules/.bin/mmdc --in=./in --out=./out

Diagram creation

Use the query param 'type' to change between 'png' and 'svg' defaults to 'svg'.

POST

Send a CURL request to generate a diagram via POST:

curl --location --request POST 'http://localhost:80/generate' \
--header 'Content-Type: text/plain' \
--data-raw 'graph LR

    A-->B
    B-->C
    C-->D
    C-->F
'

GET

Send a CURL request to generate a diagram via GET... send in url encoded data under the data query param:

curl --location --request GET 'http://localhost:80/generate?data=graph%20LR%0A%0A%20%20%20%20A--%3EB%0A%20%20%20%20B--%3EC%0A%20%20%20%20C--%3ED%0A%20%20%20%20C--%3EF%0A'

Example request in Postman

Caching

All generated diagram input and output will be cached for 1 hour. The cache time is reset whenever a cached diagram is accessed.