Context: Deep-dive into the local Mermaid setup, covering the Core Monorepo, Live Editor, and CLI. Ports: 5514X range assigned for local dev.


๐Ÿง  Mermaid Core (Monorepo)

Path: /home/dv/merms/mermaid Tech Stack: pnpm (workspaces), Vite + esbuild (hybrid build), Docker, Cypress (E2E), Vitest (Unit), Langium (Parsers).

๐Ÿ”Œ Ports

  • Dev Server: 55145 (was 9000)
  • Docs (Vitepress): 55146 (was 3333)

๐Ÿ› ๏ธ Key Commands

  • npx pnpm install ๐Ÿ“ฆ Install dependencies (root)
  • npx pnpm run dev ๐Ÿš€ Start dev server (Esbuild/Vite hybrid)
  • npx pnpm run docs:dev ๐Ÿ“š Start documentation server
  • ./run ๐Ÿณ Docker helper script (e.g., ./run pnpm install)
  • npx pnpm run build ๐Ÿ—๏ธ Build all packages
  • npx pnpm run test ๐Ÿงช Run lints & unit tests

๐Ÿงฌ Structure

  • packages/mermaid: Core library logic
  • packages/parser: Langium grammar definitions
  • demos: Static HTML files for testing diagrams
  • .esbuild/server.ts: Custom dev server logic

๐ŸŽจ Mermaid Live Editor

Path: /home/dv/merms/mermaid-live-editor Tech Stack: Svelte 5 (Runes), Vite, TailwindCSS, CodeMirror / Monaco.

๐Ÿ”Œ Ports

  • Dev Server: 55144 (was 3000)

๐Ÿ› ๏ธ Key Commands

  • npx pnpm install ๐Ÿ“ฆ Install dependencies
  • npx pnpm run dev ๐Ÿš€ Start dev server (Hot Module Reload enabled)
  • npx pnpm run build ๐Ÿ—๏ธ Production build
  • npx pnpm run format ๐Ÿ’… Prettier/Lint fix

โšก implementation Details

  • State Management: Uses Svelte 5 runes ($state, $derived)
  • Icons: unplugin-icons with FileSystemLoader
  • Config: vite.config.js handles full reloads for stability

๐Ÿ–ฅ๏ธ Mermaid CLI

Path: /home/dv/merms/mermaid-cli Tech Stack: Node.js, Puppeteer (Chromium), Vite.

๐Ÿ”Œ Ports

  • Dev Server: 55141 (Internal dev/test server)

๐Ÿ› ๏ธ Key Commands

  • npm install ๐Ÿ“ฆ Install dependencies (Standard npm)
  • npm run dev ๐Ÿš€ Start internal dev server
  • npm run test ๐Ÿงช Run Jest tests
  • npm run test:cli ๐Ÿค– Run CLI specific integration tests
  • ./src/cli.js โŒจ๏ธ Direct CLI entry point

โš™๏ธ Workflow

  1. Spins up a local web server (Port 55141)
  2. Puppeteer launches headless Chrome
  3. Renders diagram SVG/PNG from input definitions

๐Ÿ”— Common Ops

Dependency Management:

  • Core & Live Editor use pnpm (strict, fast)
  • CLI uses npm (legacy/compat)

Dev Loop:

  1. Start Core dev (55145) to hack on rendering logic
  2. Start Live Editor (55144) to test UI/UX with local changes (requires linking if needed)
  3. Start CLI (55141) to verify headless generation