# Documentation (/en/docs)

A Zi Wei Dou Shu chart engine, field-for-field identical to JS iztro, plus pattern judgement, knowledge packs and reverse birth-date lookup — with LLM-ready text output. A Rust core, callable from Rust, Python, Go and JavaScript / TypeScript.



Zi Wei Dou Shu — Chinese "Purple Star" astrology — charts a life from a birth date and hour.
This library turns that birth moment into a complete chart, and into text a language model can
read in one call — **let the library get the chart right; let the AI do the reading**.

One call produces the Markdown below — the full basic info, palace overview, patterns and the first
palace, with the other eleven palaces following in the same shape. Paste it into any language model
and start asking questions:

```text
# Natal Chart 2000-8-16 Tiger hour female

## Basic Info
- Solar: 2000-8-16 · Lunar: 2000-7-17 · Hour: Tiger hour (03:00~05:00)
- Pillars: geng chen - jia shen - bing woo - geng yin · Zodiac: dragon · Sign: leo
- Five Elements Class: wood 3rd · Soul Star: rebel · Body Star: scholar
- Soul Palace: woo · Body Palace: xu (career) · Original Palace: chen (spouse)
- Birth-Year Mutagen: sun [A]→children, warrior [B]→wealth, moon [C]→friends, fortunate [D]→health

## Palace Overview
| Palace | Major Stars | Minor Stars | Decadal |
|---|---|---|---|
| **soul** woo | emperor([+3]) | artist([-3]) | 3-12 |
| siblings si | advisor([-1]) | — | 13-22 |
| spouse chen [Original Palace] | marshal([+3]) | helper, impulsive([-3]) | 23-32 |
| children mao | sun([+3]) [A], sage([+3]) | — | 33-42 |
| wealth yin | warrior([+1]) [B], minister([+3]) | horse | 43-52 |
| health chou | fortunate([-2]) [D], advocator([-2]) | assistant, fickle | 53-62 |
| surface zi | wolf([+2]) | spark([-3]) | 63-72 |
| friends hai | moon([+3]) [C] | — | 73-82 |
| career xu [Body Palace] | judge([0]), empress([+3]) | officer | 83-92 |
| property you | — | ideologue, driven([-3]) | 93-102 |
| spirit shen | rebel([+1]) | scholar([+1]), money | 103-112 |
| parents wei | — | aide, tangled([+3]) | 113-122 |

## Patterns
- **Empress and Minister Facing the Palace** (soul): empress([+3]), minister([+3])

## Palaces

### soul (ren woo) · Decadal 3-12
- Major Stars: emperor([+3])
- Minor Stars: artist([-3])
- Adjective Stars: refined, lucky, intercepted, instigated, considery(Y)
- Trine & Opposite: Opposite surface · Trine wealth, career
- Stem ren Flying: sage [A]→children, emperor [B]→soul, officer [C]→career, warrior [D]→wealth
- Twelve Gods: Changsheng·weak, Boshi·dragon, Suiqian·downcast, Jiangqian·disastery
- Age Fortune Years: 5, 17, 29, 41, 53, 65, 77, 89, 101, 113

… (the other eleven palaces)
```

<Callout title="Reading the sample">
  `Lunar` reads year-month-day of the lunar calendar (`2000-7-17` = the 17th day of the 7th lunar month,
  2000; a leap month reads `leap-4`).
  `Pillars` is the four pillars in iztro's own romanization — close to pinyin, but note 午 renders as
  `woo` to avoid clashing with 戊 `wu`. Bracket notation: `([+3])` is brightness on a -3…+3 scale,
  `[A]`/`[B]`/`[C]`/`[D]` are the four mutagens, and `→children` names the palace the mutagen star
  sits in. The full conventions are on the [to\_text page](/en/docs/guide/guides/to-text#format-conventions).
</Callout>

Whether a chart is *correct* has one hard standard here: **zero field-level divergence from JS
[iztro](https://github.com/SylarLong/iztro) v2.6.3**, held by 747,572 golden test cases — see
[Accuracy](/en/docs/guide/about/accuracy). Defaults match iztro exactly; the Zhongzhou school and
every boundary convention are [switchable](/en/docs/guide/guides/config), because parity with iztro
is an engineering standard, not a claim that any one school is the only correct one.

## Where to start [#where-to-start]

<Cards>
  <Card title="x-iztro Guide" href="/en/docs/guide" description="Installation, your first chart, Zi Wei concepts, configuration and data model. Applies to every binding." />

  <Card title="Getting started" href="/en/docs/guide/getting-started" description="The inputs a chart needs, how to install for each programming language, and your first chart." />

  <Card title="Using it without writing code" href="/en/docs/guide/guides/for-non-developers" description="What it can do, where it fits, and what to hand your engineers." />

  <Card title="Semantic text (to_text)" href="/en/docs/guide/guides/to-text" description="How the text above is produced, its format, and how to wire it into a model." />
</Cards>

API reference for each language:

<LanguageCards>
  <Card title="Rust API" href="/en/docs/rust" description="The core library. Every binding calls into it." />

  <Card title="Python API" href="/en/docs/python" description="A typed API built from dataclasses and StrEnums, with no external dependencies." />

  <Card title="Go API" href="/en/docs/go" description="Embedded WebAssembly on a pure Go runtime, no cgo." />

  <Card title="JavaScript / TypeScript API" href="/en/docs/js" description="A WebAssembly core with complete bundled type declarations, for browsers and Node.js." />
</LanguageCards>

## Three things iztro doesn't have [#three-things-iztro-doesnt-have]

These are the semantic layers above the raw chart — the part an AI pipeline actually consumes —
and upstream iztro has no equivalent API for any of them:

<Cards>
  <Card title="Pattern judgement (64 rules)" href="/en/docs/guide/concepts/patterns" description="One rule set shared by natal charts and horoscopes; every hit names its palace, variant and evidencing stars." />

  <Card title="Knowledge packs" href="/en/docs/guide/guides/knowledge-pack" description="Reading texts and school attributes in swappable JSON, default pack included — doubles as RAG corpus." />

  <Card title="Reverse lookup" href="/en/docs/guide/guides/reverse" description="From BaZi pillars or chart features back to candidate birth dates, each verified by re-charting." />
</Cards>

## Find your path [#find-your-path]

* **A practitioner, not a programmer** → [Using it without writing code](/en/docs/guide/guides/for-non-developers)
* **Backend / AI application engineer** → [Getting started](/en/docs/guide/getting-started), then the [LLM guide](/en/docs/guide/guides/llm)
* **New to Zi Wei Dou Shu** → [the concepts](/en/docs/guide/concepts), starting from stems, branches and the twelve palaces

## Several programming languages, one result [#several-programming-languages-one-result]

Every binding calls the same Rust core, so charts come out identical field for field.
The predicate methods are built on language-independent keys, so one analysis rule — written in
Rust, Python, Go or JavaScript — yields the same answer on a chart rendered in any output language.

<Tabs items="['Rust', 'Python', 'Go', 'TypeScript']">
  <Tab value="Rust">
    ```rust
    use x_iztro::*;

    let chart = by_solar("2000-8-16", 2, Gender::Female, true, Language::EnUS, Config::default())?;
    let soul = chart.palace(Palace::Soul).unwrap();

    println!("{}", soul.has(&[StarKey::ZiweiMaj]));
    ```
  </Tab>

  <Tab value="Python">
    ```python
    from x_iztro import Astro

    chart = Astro().by_solar("2000-8-16", 2, "female", language="en-US")
    soul = chart.palace("soulPalace")

    print(soul.has(["ziweiMaj"]))
    ```
  </Tab>

  <Tab value="Go">
    ```go
    chart, _ := iztro.BySolar("2000-8-16", 2, iztro.GenderFemale, true, iztro.LanguageEnUS, nil)
    soul := chart.Palace(iztro.PalaceSoul)

    fmt.Println(soul.Has(iztro.StarZiweiMaj))
    ```
  </Tab>

  <Tab value="TypeScript">
    ```ts
    import { init, astro } from 'x-iztro';

    await init();
    const chart = astro.bySolar('2000-8-16', 2, 'female', { language: 'en-US' });
    const soul = chart.palace('soulPalace')!;

    console.log(soul.has(['ziweiMaj']));
    ```
  </Tab>
</Tabs>

They all report the same answer — the Soul palace of this chart holds Ziwei, the Emperor star
(Python prints `True`; the others print `true`). All of them use the language-independent key
`ziweiMaj`: render the same chart in English or Japanese and the answer doesn't change.
