Skip to main content

Convert documents to visual knowledge maps via LLM + Mermaid

Project description

doc2mermaid

Convert documents to visual knowledge maps — powered by LLM + Mermaid.

Document Text → LLM Structure Extraction → Graph JSON → Mermaid → SVG/PNG

Install

pip install doc2mermaid

# Mermaid CLI for SVG/PNG rendering
npm install -g @mermaid-js/mermaid-cli

Quick Start

Python API

from doc2mermaid import doc_to_map

svg_path = doc_to_map(
    open("article.md").read(),
    output="map.svg",
    llm_base_url="https://api.openai.com/v1",
    llm_api_key="sk-...",
    llm_model="gpt-4o-mini",
)

CLI

export DOC2MERMAID_BASE_URL=https://api.openai.com/v1
export DOC2MERMAID_API_KEY=sk-...
export DOC2MERMAID_MODEL=gpt-4o-mini

doc2mermaid article.md -o map.svg
doc2mermaid article.md -o map.png --theme dark
cat article.txt | doc2mermaid - -o map.svg

How It Works

  1. Extract: LLM reads your document and extracts a graph structure (nodes + edges)
  2. Render: The graph is converted to Mermaid diagram syntax with auto-styling
  3. Output: Mermaid CLI renders the final SVG or PNG

Node Types & Colors

Type Color Use For
problem Red Problems, challenges, pain points
idea Purple Ideas, hypotheses, concepts
method Blue Methods, approaches, solutions
step Cyan Process steps, actions
result Green Results, outcomes, findings
takeaway Yellow Key takeaways, conclusions

Configuration

LLM settings via environment variables or function arguments:

Env Var Argument Description
DOC2MERMAID_BASE_URL llm_base_url OpenAI-compatible API base URL
DOC2MERMAID_API_KEY llm_api_key API key
DOC2MERMAID_MODEL llm_model Model identifier

Works with any OpenAI-compatible API (OpenAI, Claude, DeepSeek, local models, etc.).

License

MIT

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

doc2mermaid-0.1.1.tar.gz (9.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

doc2mermaid-0.1.1-py3-none-any.whl (8.2 kB view details)

Uploaded Python 3

File details

Details for the file doc2mermaid-0.1.1.tar.gz.

File metadata

  • Download URL: doc2mermaid-0.1.1.tar.gz
  • Upload date:
  • Size: 9.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.2

File hashes

Hashes for doc2mermaid-0.1.1.tar.gz
Algorithm Hash digest
SHA256 631461d3955d93d40f0629ad50897b70c8323b04fb640f67a969a9b923f02df8
MD5 02533f7138fafdf673a43453b534e53d
BLAKE2b-256 f63dcb0e441f4e0a620dd34551b9838baf489ebf6952d64343bc7ad65e1294f5

See more details on using hashes here.

File details

Details for the file doc2mermaid-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: doc2mermaid-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 8.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.2

File hashes

Hashes for doc2mermaid-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 c2ae72b4182430dacd6848568390c5060ee0da96e53559cd71e0f52b811a543f
MD5 1ca74f4f7628da4fdb1e01cab12e4bae
BLAKE2b-256 c839617b7a8a82c13e91c63f6872d6454d993093164aea92efe578fa81086114

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page