This is a simple Express.js application that uses the Kroki API to generate Mermaid diagrams in SVG format.
- Accepts a POST request with Mermaid diagram source code.
- Generates an SVG diagram using Kroki's API.
- Returns the generated SVG diagram in the response.
- Node.js (version 14 or higher)
- npm (Node Package Manager)
-
Clone this repository OR download zip:
git clone https://github.com/your-username/kroki-diagram-generator.git
-
Navigate to the project directory:
cd kroki-diagram-generator
- Install the dependencies:
npm install
- Start the server
npm run dev
-
The server will start on
http://localhost:3000
(or any other port specified in the .env file). -
To generate a diagram, send a POST request to /generate with the following JSON payload:
{
"diagram": "graph TD; A-->B; A-->C; B-->D; C-->D;"
}
Replace the diagram value with your Mermaid diagram source code.
- The server will respond with an SVG image of the diagram.
curl -X POST http://localhost:3000/generate \
-H "Content-Type: application/json" \
-d '{"diagram": "graph TD; A-->B; A-->C; B-->D; C-->D;"}'
- Ensure you have all dependencies installed by running npm install.
- Check the server logs for any errors if the application is not working as expected.
- Make sure your network allows outgoing requests to
https://kroki.io
.