Skip to content

anubhav-m/logisketch-server

Repository files navigation

Logisketch – Smart Diagram Generator from Natural Language & Images


About

Generate system architecture, ER, flowchart, network packet, circuit logic, 3D, math, and sequence diagrams from natural language prompts.
A backend-powered diagram assistant for developers, educators, and system designers.
Supports 13+ diagram engines like PlantUML, Mermaid, Graphviz, Structurizr, D2, Vega-Lite, Tikz, and many more.



Supported Models

Text-based LLMs:

  • meta-llama/llama-4-scout-17b-16e-instruct
  • llama-3.3-70b-versatile
  • llama-3.1-8b-instant
  • meta-llama/llama-4-maverick-17b-128e-instruct

Text + Image-based LLMs:

  • mistralai/mistral-small-3.2-24b-instruct-2506:free


Supported Diagram Engines (via Kroki)

Engine Can Generate
Graphviz Flowcharts, directed/undirected graphs
Blockdiag Block diagrams
Seqdiag Sequence diagrams
Packetdiag Network packet diagrams
C4 C4 model diagrams (software architecture)
D2 Entity relationships, org charts, architectures
ERD Entity Relationship Diagrams
Mermaid Flowcharts, Gantt, class, pie, state diagrams
Nomnoml UML class diagrams
PlantUML UML diagrams (sequence, activity, use-case, etc.)
Structurizr Software architecture diagrams (C4 model)
Symbolator Digital logic and circuit diagrams
TikZ Math figures, circuit diagrams, flowcharts
Vega-Lite Bar, line, scatter charts (data visualization)
Wavedrom Digital timing diagrams


Key Features

  • Natural language to diagram via Kroki
  • Image + text-based diagram generation
  • Multi-model LLM support
  • Custom prompt engineering support
  • Rate limiting and bot protection via Arcjet
  • Supports 13+ diagram engines


API Routes Description

1. POST /api/generate-image

Generates a diagram image from a natural language prompt, with optional image input (used for models that support images).
This route performs the full LLM-to-Kroki pipeline and returns both the generated code and the rendered diagram.

2. POST /api/render-code

Renders a given diagram code (in a supported diagram syntax) directly into an image using the selected Kroki engine.
This route bypasses the LLM and is ideal when you already have the code and just want to convert it to an image.



API Usage

For Text-based Models

POST /api/generate-image

{
  "prompt": {
    "text": "Create a CI/CD pipeline diagram with key stages and tool relationships."
  },
  "model": "llama-3.3-70b-versatile",
  "engine": "plantuml"
}

✅ Success Response

{
  "success": "true",
  "code": "...",
  "svg": "..."
}

❌ Error Response

{
  "success": "false",
  "error": "..."
}

For Text + Image Models

POST /api/generate-image

{
  "prompt": {
    "text": "Create an ER diagram from following image",
    "image": "https://dataedo.com/asset/img/blog/erd_with_pen.png"
  },
  "model": "llama-3.3-70b-versatile",
  "engine": "erd"
}

✅ Success Response

{
  "success": "true",
  "code": "...",
  "svg": "..."
}

❌ Error Response

{
  "success": "false",
  "error": "..."
}

For Rendering Code

POST /api/render-code

{
  "code":"..."
  "engine": "plantuml"
}

✅ Success Response

{
  "success": "true",
  "svg": "..."
}

❌ Error Response

{
  "success": "false",
  "error": "..."
}


Accepted Parameters

Parameter Type Allowed Values Description
model string (LLM) Text-based LLMs
meta-llama/llama-4-scout-17b-16e-instruct,
llama-3.3-70b-versatile,
llama-3.1-8b-instant,
meta-llama/llama-4-maverick-17b-128e-instruct

Text+Image LLMs
mistralai/mistral-small-3.2-24b-instruct-2506:free
LLMs used for generating diagrams
engine string (Diagram Engine) plantuml, mermaid, graphviz, structurizr, blockdiag, seqdiag, packetdiag, c4plantuml, d2, erd, nomnoml, tikz, vegalite, symbolator, wavedrom Rendering engines supported by Kroki


Environment Configuration

Create a file named either:

  • .env.development.local – for development
  • .env.production.local – for production

⚠️ Other filenames will not work without changes to the environment loader config.

Place it in the root of your project directory.


Sample .env.*.local File

# ENVIRONMENT
NODE_ENV=development

# PORT
PORT=3000

# ARCJET
ARCJET_KEY=your_arcjet_key_here

# LLM PROVIDERS

# 1. GROQ
GROQ_API=your_groq_api_key_here
GROQ_ENDPOINT=https://api.groq.com/openai/v1/chat/completions

  # GROQ MODELS
  GROQ_LLM_1=meta-llama/llama-4-scout-17b-16e-instruct
  GROQ_LLM_2=llama-3.3-70b-versatile
  GROQ_LLM_3=llama-3.1-8b-instant
  GROQ_LLM_4=meta-llama/llama-4-maverick-17b-128e-instruct

# 2. OPENROUTER

OPENROUTER_ENDPOINT=https://openrouter.ai/api/v1/chat/completions

  # OPENROUTER MODELS
  OPENROUTER_LLM_1=mistralai/mistral-small-3.2-24b-instruct-2506:free
  OPENROUTER_API_1=your_mistralai_api_key_here

# RENDER ENGINES
ENGINE_1=graphviz
ENGINE_2=blockdiag
ENGINE_3=seqdiag
ENGINE_4=packetdiag
ENGINE_5=c4plantuml
ENGINE_6=d2
ENGINE_7=erd
ENGINE_8=mermaid
ENGINE_9=nomnoml
ENGINE_10=plantuml
ENGINE_11=structurizr
ENGINE_12=symbolator
ENGINE_13=tikz
ENGINE_14=vegalite
ENGINE_15=wavedrom

Get Your API Keys



How to Run Locally

1. Clone the repo and cd into it

git clone git@github.com:anubhav-m/logisketch-server.git
cd logisketch-server

2. Install dependencies

npm install

3. Create and configure your .env file

Refer to the Environment Configuration section for setup

4. Run the development server

npm run dev


Deployment Guide

When deploying on Render, Railway, Fly.io, or similar platforms, make sure to configure the following:

Build Command:

npm install

Start Command:

npm start

Environment Variable:

NODE_ENV=production

Secrets:

Upload your env.production.local file.

Refer to the Environment Configuration section for the full list of variables.



License

This project is licensed under the terms of the MIT License.