Data Visualization / Diagram-as-Code

Diagram-as-Code: Mermaid for Data Lineage & Alignment

Horizontal ETL flowcharts, ERDs, Git graphs, cloud architecture, and Gantt roadmaps in Markdown

Diagram-as-Code: Mermaid for Data Lineage & Alignment
By: Chiyul Song
Mermaid.js • GitHub Markdown • Confluence • HTML
Executive Abstract
Target Ecosystems: Data Engineering • Product Specs • Analytics Project Management

How I use Mermaid.js in GitHub PRs, Confluence specs, and HTML docs to align Product Managers and Data Engineers on ETL lineage, join grains, release branches, and project timelines.

The Core Business Problem

Cross-functional analytics projects frequently suffer from silent schema mismatches—such as joining daily transaction tables directly to weekly inventory snapshots (causing SQL fan-out), uncoordinated SQL hotfixes corrupting QBR metrics, or PMs missing upstream ETL dependencies in project schedules.

Engineered Architecture & Solution

Standardized five production Mermaid patterns across analytics documentation: (1) Horizontal ETL Flowcharts tracing PostgreSQL DB, S3 Parquet, and CSV files into the semantic layer, (2) ER Diagrams to lock primary/foreign keys and join grains, (3) Git Graphs for governed metric & forecast model releases, (4) Cloud Architecture diagrams for system RFCs, and (5) Gantt Charts for end-to-end QBR project management.

5 Production Diagram-as-Code Patterns

How I Use Mermaid in Real Analytics Workflows

Scroll through all 5 templates below
Pattern 01 • With Data Engineers & BI EngineersSyntax: `flowchart LR`

Horizontal ETL Data Lineage (DB / Parquet / CSV ➔ Semantic Layer)

In enterprise analytics, raw data arrives from heterogeneous sources—operational PostgreSQL/Oracle DBs, S3 Parquet partitions, and manual finance CSV targets. Using Mermaid's distinct geometric shapes—cylinders for databases, parallelograms for files, diamonds for QA gates, double-bordered subroutines for governed tables, and stadium pills for endpoints—makes the ETL flow immediately readable.

Practical Impact: Encoding data types by geometric shape lets Data Engineers and Analysts spot raw files, validation gates, and governed warehouse tables at a glance.
Rendered Diagram Output (flowchart LR)
1. RAW SOURCESPostgreSQL ERP[(Orders DB)]AWS S3 Parquet[/events.parquet/]Finance Target.csv[/guidance.csv/]2. DATABRICKS PYSPARK ETLAuto-Loader & Cleanse(PySpark Ingestion)Grain & FX{Valid?}3. SNOWFLAKE GOLDfact_weekly_mktplace[[Semantic Truth]]4. CONSUMPTIONTableau LOD Cockpit([Executive QBR])MinT Forecast Engine([Hierarchical ML])Pass
View Mermaid Code (flowchart LR)
Pattern 02 • With Data Engineers & Analytics EngineersSyntax: `erDiagram`

Entity-Relationship Diagram (ERD) for Join-Grain Contracts

The most common bug in commercial analytics is 'SQL fan-out'—joining a daily transaction fact table directly to a weekly inventory snapshot without pre-aggregating. Before writing complex SQL or Tableau LOD expressions, I embed an ERD in Confluence to lock primary keys (PK), foreign keys (FK), and cardinality (1:N).

Practical Impact: Acts as a strict schema contract between Data Engineering and Analytics before any pipeline code is merged.
Rendered Diagram Output (erDiagram)
DIM_PRODUCT_SKUPK sku_id (varchar) category_division msrp_usd (numeric)DIM_FISCAL_CALENDARPK date_key / week_id fiscal_quarter season_codeFACT_ORDER_TXN (Daily)PK txn_idFK sku_id, store_id, date_key units_sold, net_revenueFACT_INVENTORY_WOHFK week_id, sku_id on_hand_units weeks_on_hand (WOH)||--o{ (1:N)||--o{ 1:N (Weekly Grain)
View Mermaid Code (erDiagram)
Pattern 03 • With Analytics Team & Data Science PeersSyntax: `gitGraph`

Git Graph for Governed Metric & Forecast Model Releases

When multiple analysts and data scientists collaborate on shared SQL semantic views or forecasting repositories, ad-hoc hotfixes can corrupt production QBR numbers. I use Mermaid's gitGraph in team onboarding docs and PR templates to enforce how feature branches, experimental causal models, and hotfixes merge into main.

Practical Impact: Brings software engineering discipline (CI/CD, tagged QBR releases, isolated experiment branches) to analytics teams.
Rendered Diagram Output (gitGraph)
mainfeat/mint-forecasthotfix/fx-patchv1.0-Q1-Lockv1.0.1-Hotfixv2.0-Q2-QBRMinT covariance$0.00 gap testSync mainAPLA backtestFix JPY FX rate
View Mermaid Code (gitGraph)
Pattern 04 • With Platform Architects & Engineering LeadsSyntax: `architecture-beta`

System & Cloud Architecture Diagram

When proposing a new decision-support simulator or an automated LLM insight dispatcher, platform engineers need to see service boundaries, compute layers, and storage icons (`disk`, `database`, `server`, `internet`). Mermaid's architecture-beta syntax renders dedicated infrastructure icons directly inside technical RFCs.

Practical Impact: Bridges the gap between cloud system architecture diagrams and the actual GitHub repository where the infrastructure-as-code lives.
Rendered Diagram Output (architecture-beta)
Data Ingestion LayerAWS S3 Parquet(disk)Enterprise ERP(database)Databricks & Snowflake CorePySpark ETL(server)Snowflake Gold(database)Causal & MinT(server)Executive & App ServingTableau LOD(internet)Simulator App(internet)
View Mermaid Code (architecture-beta)
Pattern 05 • With Product Managers (PM) & Business StakeholdersSyntax: `gantt`

Gantt Chart for Analytics Roadmap & QBR Milestone Alignment

Analytics projects often stall because stakeholders don't see the upstream data engineering dependencies required before a dashboard or causal readout can be delivered. I embed Mermaid Gantt charts in Confluence project pages so PMs clearly see how data ingestion, QA validation, and modeling map to executive review dates.

Practical Impact: Updating a single date string in Markdown automatically shifts the visual timeline—keeping PMs, DEs, and leadership aligned in real time.
Rendered Diagram Output (gantt)
Wk 1 (Jan 05)Wk 3 (Jan 19)Wk 5 (Feb 02)Wk 7 (Feb 16)Wk 9 (Mar 02)1. Data & ETLParquet & Grain LockIngest S3 & POS (Done)Grain Lock (Done)2. Modeling & QAMinT & Causal DiDMinT Reconciliation (Active)DiD Backtest3. BI & QBR RolloutTableau UAT & Sign-offTableau Cockpit & UATQBR Sign-Off Milestone
View Mermaid Code (gantt)

Technologies & Protocols

Mermaid.jsETL FlowchartER Diagram (ERD)Git GraphArchitecture DiagramGantt Chart