Context: Deep-dive into the local Mermaid setup, covering the Core Monorepo, Live Editor, and CLI. Ports:
5514Xrange 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 packagesnpx pnpm run test๐งช Run lints & unit tests
๐งฌ Structure
packages/mermaid: Core library logicpackages/parser: Langium grammar definitionsdemos: 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 dependenciesnpx pnpm run dev๐ Start dev server (Hot Module Reload enabled)npx pnpm run build๐๏ธ Production buildnpx pnpm run format๐ Prettier/Lint fix
โก implementation Details
- State Management: Uses Svelte 5 runes (
$state,$derived) - Icons:
unplugin-iconswith FileSystemLoader - Config:
vite.config.jshandles 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 servernpm run test๐งช Run Jest testsnpm run test:cli๐ค Run CLI specific integration tests./src/cli.jsโจ๏ธ Direct CLI entry point
โ๏ธ Workflow
- Spins up a local web server (Port 55141)
- Puppeteer launches headless Chrome
- 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:
- Start Core
dev(55145) to hack on rendering logic - Start Live Editor (55144) to test UI/UX with local changes (requires linking if needed)
- Start CLI (55141) to verify headless generation