MING
Back to blog

We Open-Sourced Our Entire Bazi Toolchain: Introducing bazi-kit

The AskingMing team open-sourced the full Bazi toolchain powering our product: computation engine bazi-engine, bilingual terminology DB bazi-terms, and React chart component bazi-chart. MIT licensed.

Sep 7, 2026Ming Team

Building a Bazi (Four Pillars) product is hard — not because of the interpretation logic, but because there's no clean bilingual terminology database or usable chart UI out there. Most resources are Chinese-only, and every chart component you find is welded to one specific calculation engine. Want to swap engines or show English labels? You're rewriting the entire view layer.

We hit the same wall building AskingMing. So we extracted the entire toolchain that powers our product and open-sourced it as bazi-kit under the MIT license — three npm packages, each usable independently or together:

  • bazi-engine — Computation layer: pass a birth date, time, location and gender; get a complete chart.
  • bazi-terms — Bilingual terminology database: Heavenly Stems, Earthly Branches, Ten Gods, Na Yin, Shen Sha… structured, translatable, zero dependencies.
  • bazi-chart — React chart component: render any chart data as a clean bilingual UI.

Dependencies flow strictly one-way: bazi-terms ← bazi-engine / bazi-chart. The renderer never depends on the engine — bring your own or use ours.

bazi-engine: From Birth Data to a Complete Chart

This is the heaviest layer, and the most underestimated. Chart computation looks like table lookups, but getting true solar time, historical DST, and city coordinates right is far more work than it seems.

import { computeBazi } from 'bazi-engine';

const result = computeBazi({
  solar: '1990-03-24 09:54',
  gender: 'male',
  location: { city: 'Guangzhou' },
});
// result.pillars, result.daYun, result.solarTime …

computeBazi is a pure function: identical input always produces byte-identical output. No IO, no Date.now(), no global state. It enables true solar time correction by default (using the Meeus equation-of-time formula) and handles historical DST via the IANA timezone database — China was UTC+9 in summer 1988, a detail no static offset table can express.

v1 capabilities:

  • Four Pillars (stems, branches, hidden stems), Ten Gods (stem + hidden-stem level)
  • Na Yin, Xun/Kong (void branches), Growth Stages, Self-sitting
  • Luck Pillars with ten gods and Na Yin
  • True Solar Time (Meeus / approximate algorithms)
  • Built-in coordinate and timezone mapping for 88 cities

Interactions, Shen Sha, and Five-Element scores are planned for v2.

bazi-terms: Every Concept, Translatable and Searchable

Every term a chart uses is structured data:

  • Heavenly Stems STEMS (10), Earthly Branches BRANCHES (12)
  • Five Elements (with cycles) ELEMENTS, ELEMENT_CYCLES
  • Ten Gods (incl. Day Master) TEN_GODS (11)
  • Growth Stages GROWTH_STAGES, Shen Sha SHEN_SHA (38)
  • Sixty Jiazi Na Yin NA_YIN (30 melodies / 60 pairs)
  • Interactions INTERACTION_TYPES (8), General Terms GENERAL_TERMS (40+)

Each entry carries key, zh, en, optional pinyin, and an English definition you can paste into a tooltip. The workhorse translate() never throws — unrecognized input passes through unchanged, so you can safely pipe raw engine output straight through it:

import { translate, t, naYinOf } from 'bazi-terms';

t('dayMaster');              // 'Day Master'
translate('元男');            // 'Day Master'   (aliases auto-resolved)
translate('甲子');            // 'Sea Gold'     (Na Yin by sexagenary pair)
naYinOf('甲子')?.en;          // 'Sea Gold'

Different engines name the same concept differently. bazi-terms normalizes them all through aliases and dedicated resolvers, so one zh → key mapping serves every engine.

bazi-chart: Render Any Chart, Bilingually

Feed your chart data to <BaziChart />. It auto-detects the input shape, normalizes it, and renders — no extra configuration needed.

import { BaziChart } from 'bazi-chart';

export default function Reading({ engineOutput }) {
  return <BaziChart data={engineOutput} lang="both" theme="light" />;
}

It renders the full picture: Four Pillars, Five-Element score bars, interactions panel, Luck Pillar timeline, and auxiliary palaces. Styling is inline-only — no CSS import, SSR-safe, works with any meta-framework (Next.js, Remix, Astro).

Already have your own engine? bazi-chart auto-detects the two most common community shapes and also accepts a hand-built NormalizedChart.

Install & Compose

Use any package alone or combine as needed:

npm install bazi-engine bazi-chart   # Full stack
npm install bazi-chart               # Render only
npm install bazi-terms               # Terminology only

All ship ESM + CJS dual builds with full TypeScript declarations.

Why Open-Source the Entire Chain

Most Bazi projects open-source either the algorithm or the UI, leaving a gap that forces you to adapt to someone's proprietary format. We opened all three layers because each has independent reuse value:

  • Building a Bazi app? Use bazi-engine + bazi-chart — save months of infrastructure work.
  • Already have an engine? Install bazi-chart — it's engine-agnostic.
  • Writing Bazi articles and need accurate bilingual terms? bazi-terms is zero-dependency, grab and go.

Our hope: stop reinventing wheels, make the basics public infrastructure, and focus energy on differentiated interpretation and product experience.

About AskingMing

bazi-kit is the toolchain open-sourced from AskingMing — an AI-powered Bazi insight and personal growth product (the site you're reading this on). But these tools are designed for anyone building in this space, independent of the product itself.

It's early (v0.1.x), and feedback is genuinely welcome: missing terms, wrong translations, edge cases, new chart shapes, or non-React renderer needs — reach out via GitHub issues or PRs.

Want to see what this chart renderer actually looks like? Enter your birth date and time to generate your own Bazi chart instantly: Free Bazi Chart.

GitHub: https://github.com/favkit/bazi-kit · npm: bazi-engine / bazi-terms / bazi-chart

Recommended reading