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 Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distribution

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

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

Uploaded Python 3

File details

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

File metadata

  • Download URL: doc2mermaid-0.1.2-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.2-py3-none-any.whl
Algorithm Hash digest
SHA256 1539cc23061db1a4fb10b4c826476a1248b90902c0b1962e01165545a54dd46f
MD5 7124e6a4da1fa885c6c4d66ddf69a45c
BLAKE2b-256 3a4465660d530f897dac91cfcbc0018910e8bba0c566e6d38a9402d8e6feb608

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