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 doc2map 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 DOC2MAP_BASE_URL=https://api.openai.com/v1
export DOC2MAP_API_KEY=sk-...
export DOC2MAP_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
DOC2MAP_BASE_URL llm_base_url OpenAI-compatible API base URL
DOC2MAP_API_KEY llm_api_key API key
DOC2MAP_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.0.tar.gz (9.7 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.0-py3-none-any.whl (8.1 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: doc2mermaid-0.1.0.tar.gz
  • Upload date:
  • Size: 9.7 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.0.tar.gz
Algorithm Hash digest
SHA256 c7e3f119e5d37604ecf79f96f6af7cefbc93b18b6b3048a8e3c5936a48e42068
MD5 7c0e544e897ac4f1e10118a9313e3cf5
BLAKE2b-256 714e461914ce0df43c709ebf82331927d8b5629c0384c7464ff8abe9e49f3ad7

See more details on using hashes here.

File details

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

File metadata

  • Download URL: doc2mermaid-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 8.1 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.0-py3-none-any.whl
Algorithm Hash digest
SHA256 f73720e2bd2c12fd5a4ad8f74529ba27f220ab72758774675e6de6453898a65b
MD5 86ed4f67ebe3269a7205c1218c6aae79
BLAKE2b-256 b3c88bb0d2fd2b36f0d038c063529378d4eab954a0a6027ff67f436211a5cf54

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