How microsoft/flint-chart works
1. Monorepo shape
- This repo is organized around one product family, Flint, with three shipping surfaces: the TypeScript library (flint-js), the MCP server (flint-mcp), and the public demo/documentation site (site).
- A source-only Python port (flint-py) mirrors the library architecture for validation and future release work.
2. Core compilation pipeline
- The architectural center is the Flint compiler pipeline in packages/flint-js/src/core.
- Input is a compact chart spec plus data and semantic types; core modules resolve semantics, make chart/layout decisions, compute sizing, and apply color/encoding rules before backend rendering.
3. Backend boundary
- Backend-specific code is cleanly separated from core logic.
- vegalite, echarts, and chartjs each expose the same high-level assembly entry points, but generate different native spec formats and have their own templates, recommendation logic, and spec instantiation paths.
4. Template-driven rendering
- Each backend has a templates/ layer containing chart-specific renderers such as bar, line, scatter, heatmap, pie, radar, waterfall, etc.
- The templates are the main extension point for adding chart types without changing the compiler core.
5. Shared type and semantics system
- The core package defines the domain model: chart spec types, semantic types, field semantics, encoding actions/overrides, and registry metadata.
- This semantic layer is what allows Flint to infer presentation details from business meaning rather than requiring verbose chart configuration.
6. MCP server architecture
- packages/flint-mcp wraps the library in an agent-facing server that exposes tools to list, validate, compile, and render charts.
- It is both a protocol server and a rendering service: it can return backend-native specs, static SVG/PNG-like outputs, or open an interactive chart view for MCP clients.
7. Render subsystem in MCP
- The MCP package has its own render/ boundary that converts Flint specs into visual output.
- It includes backend adapters, SVG/font handling, and data-source loading, which lets the server render charts from in-memory rows or from local files such as JSON, CSV, or TSV.
8. Web demo and authoring experience
- The site/ package is a Vite + React application that consumes the same library code to provide the landing page, docs viewer, chart gallery, editor, and MCP walkthrough pages.
- It contains reusable UI components for chart previews, code/editing panels, sizing playgrounds, and side-by-side backend views.
9. Test-data as a shared architectural asset
- shared/test-data is a large corpus of fixture inputs/expected outputs that drives automated tests, gallery examples, and cross-backend regression coverage.
- This is a key boundary in the repo: the same canonical cases validate the TypeScript package, the MCP renderer, and the Python port.
10. Python port parity
- packages/flint-py mirrors the TypeScript structure closely: core for semantics/decisions/layout and vegalite for backend assembly/templates.
- Its tests and tooling suggest it is used as a parity implementation rather than an independent product path.
11. Documentation and contribution workflow
- The docs/ tree is part of the architecture, not just marketing: it documents compiler design, backend integration, chart templates, semantic types, and the MCP workflow.
- Repo docs and agent skill files form an authoring boundary for humans and agents outside the codebase.
12. Build, release, and verification
- The project uses GitHub Actions for CI, code scanning, npm publishing, and GitHub Pages deployment.
- TypeScript packages are built/tested with modern Node tooling (tsup, vitest), while the site is built separately and published as the project website.
Main entry points: src Site app · core Core pipeline · render Render boundary · workflows CI workflows
Components 21
TypeScript library
Primary Flint compiler and backend assembly implementation.
- Core pipeline · Semantics, decisions, layout, sizing, and encoding rules for Flint specs.
packages/flint-js/src/core - Vega-Lite · Vega-Lite assembly and chart templates.
packages/flint-js/src/vegalite - ECharts · ECharts assembly, facet handling, and templates.
packages/flint-js/src/echarts - Chart.js · Chart.js assembly and templates.
packages/flint-js/src/chartjs - Gallery data · Canonical gallery scenarios and benchmark-style examples.
packages/flint-js/src/gallery - TS fixtures · TypeScript test corpus covering semantics, sizing, backends, and gallery cases.
packages/flint-js/src/test-data
MCP server
Agent-facing server plus chart rendering boundary.
- MCP server · Agent-facing server exposing list, validate, compile, and render tools.
packages/flint-mcp/src/server.ts - Tools · Tool definitions and schemas for chart operations.
packages/flint-mcp/src/tools - Render boundary · Converts Flint specs into visual output through backend adapters and SVG handling.
packages/flint-mcp/src/render - MCP UI · Interactive chart view served alongside the MCP server.
packages/flint-mcp/ui
Web site
Docs, gallery, editor, and demo application.
- Site app · Landing page, docs viewer, gallery, editor, and walkthrough pages.
site/src - UI components · Reusable preview, editor, sizing, and comparison components.
site/src/components - Routes · Top-level site experiences and content entry points.
site/src/routes - Site data · Docs catalog, backend lists, wall settings, and editor payload helpers.
site/src/shared
Python port
Source-only parity implementation mirroring the TypeScript library.
- Py core · Python parity implementation of semantics, layout, and decisions.
packages/flint-py/flint/core - Py Vega-Lite · Python Vega-Lite assembly and templates mirroring the TS structure.
packages/flint-py/flint/vegalite - Py eval · Validation and evaluation tooling for Python implementation parity.
packages/flint-py/tests
Shared assets
Canonical fixtures and documentation used across runtimes.
- Shared corpus · Canonical input/expected-output cases shared across TypeScript, MCP, and Python validation.
shared/test-data - Docs · Design, tutorial, and reference documentation for compiler and workflows.
docs - Agent skills · Skill and agent guidance for chart authoring and repository workflows.
agent-skills - CI workflows · GitHub Actions for testing, publishing, scanning, and site deployment.
.github/workflows
Connections 33
- Core pipeline → Vega-Lite: feeds specs · Core decisions are assembled into Vega-Lite backend specs.
- Core pipeline → ECharts: feeds specs · Core decisions are assembled into ECharts backend specs.
- Core pipeline → Chart.js: feeds specs · Core decisions are assembled into Chart.js backend specs.
- Vega-Lite → Gallery data: renders examples · Gallery examples are instantiated through the Vega-Lite backend.
- ECharts → Gallery data: renders examples · Gallery examples are instantiated through the ECharts backend.
- Chart.js → Gallery data: renders examples · Gallery examples are instantiated through the Chart.js backend.
- Shared corpus → TS fixtures: drives tests · Shared canonical cases are mirrored into TypeScript test data.
- Shared corpus → Render boundary: drives render tests · Shared fixtures validate MCP rendering behavior.
- Shared corpus → Py eval: drives parity · Shared fixtures validate Python parity and evaluation.
- MCP server → Tools: exposes tools · Server registers compile, validate, list, and render tools.
- MCP server → Render boundary: delegates render · Server forwards render requests into the render subsystem.
- Render boundary → Core pipeline: uses compiler · MCP rendering starts from the same Flint core compiler pipeline.
- Render boundary → Vega-Lite: backend adapter · Rendering can target Vega-Lite output.
- Render boundary → ECharts: backend adapter · Rendering can target ECharts output.
- Render boundary → Chart.js: backend adapter · Rendering can target Chart.js output.
- MCP server → MCP UI: serves view · The server can open an interactive chart view for clients.
- Site app → UI components: composes · Site pages are built from reusable UI components.
- Site app → Routes: routes · Top-level experiences are organized as route modules.
- Site app → Site data: uses data · Site pages rely on shared catalog and configuration data.
- Site app → Core pipeline: uses library · The site consumes the Flint library code for live previews and docs.
- Site app → Vega-Lite: shows backend · The site compares backend-native outputs, including Vega-Lite.
- Site app → ECharts: shows backend · The site compares backend-native outputs, including ECharts.
- Site app → Chart.js: shows backend · The site compares backend-native outputs, including Chart.js.
- Py core → Py Vega-Lite: feeds specs · Python core output is assembled into Python Vega-Lite specs.
- Py eval → Py core: verifies · Python tests validate core behavior and parity decisions.
- Docs → Core pipeline: documents · Docs explain the compiler pipeline and semantic model.
- Docs → MCP server: documents · Docs cover MCP setup and workflow.
- Docs → Site app: supports authoring · Docs feed the website content and walkthroughs.
- Agent skills → Docs: guides usage · Skill files and guidance sit beside the documentation boundary.
- CI workflows → Shared corpus: validates · CI runs regression coverage over the shared corpus.
- CI workflows → Site app: deploys · CI builds and publishes the site.
- CI workflows → Core pipeline: tests · CI verifies the TypeScript library and backends.
- CI workflows → Py eval: tests · CI includes Python parity verification.