How mermaid-chart/mermaid-develop works
File structure
• Root config: CI workflows (.github/workflows), linters, build scripts (vite.config.ts, .vite), Docker compose for local dev, Cypress/E2E tests, demos/, docs/ (static site), scripts/, tests/webpack.
• package.json + pnpm-workspace manage dependencies and workspaces.
README for additional insights
• Core flow: markdown-inspired text → mermaidAPI → detect type → parse → AST/Db → renderer → SVG/HTML.
• Integrations: Node API, browser API, CLI, Live Editor, GitHub, other host apps.
• Visual regression using Applitools in E2E.
Main components & their interactions
a. Clients / Entry Points:
– Browser bundler (via ESM bundle built by Vite/Rollup)
– Live Editor (separate repo but uses core API)
3) Parser: Jison grammars produce intermediate data models (Db objects)
5) Rendering-Util: shared utilities (text splitting, markdown handling, DOM helpers)
6) Themes & Styles: CSS/JS themes applied at render time
7) Config & Schemas: default/final config, type definitions, validation
8) Logger, Errors, Accessibility modules
c. Plugin Packages:
d. Documentation & Demos:
– docs/ (static markdown site via Vitepress), demos/ (static HTML examples)
e. CI/CD & Testing:
– GitHub Actions orchestrate lint, build, test, publish
– Cypress for visual and functional E2E tests with Applitools
– Jest/Mocha for unit tests in each package
f. Packaging & Publishing:
– pnpm workspaces, root & each package package.json
– build scripts in scripts/ and .vite/
– npm publish to registry, site deploy via Netlify
Architectural patterns & design principles
• Modular plugin architecture: detectors + parsers + renderers register under mermaidAPI
• Pipeline pattern: text → detect → parse → render
• Monorepo with workspace orchestration for code reuse and version alignment
• CI pipeline ensures consistency across packages and documentation
Elements
• Clear labels for each component (e.g., “Detector”, “Flowchart Parser”, “Theme Engine”)
– Rectangles for code modules
– Parallelograms for inputs/outputs (text input, SVG output)