How sylarlong/iztro works
1. This repository is primarily a TypeScript library for Zi Wei Dou Shu astrolabe generation and querying. The core runtime code lives under src/, and the rest of the repo is documentation, tests, build output, and usage examples.
2. The public entry point is src/index.ts, which re-exports the main modules. The most important API surface is the astro namespace in src/astro/, plus star- and palace-oriented helpers in src/star/. The README examples show the intended usage pattern: create an astrolabe from solar or lunar birth data, then query it through a chainable API.
3. The central computation pipeline is in src/astro/astro.ts and related files. This layer turns birth inputs into an astrolabe model, including natal chart construction and derived time layers such as major luck, minor luck, annual, monthly, daily, and hourly contexts. src/astro/analyzer.ts appears to handle rule-based analysis over the computed chart.
4. The astrolabe domain model is split into functional wrappers:
- FunctionalAstrolabe.ts
- FunctionalHoroscope.ts
- FunctionalPalace.ts
- FunctionalSurpalaces.ts
These are the chainable objects that power queries like “does this palace contain a star?” or “what are the surrounding palaces for this star?”. They form the main boundary between raw chart data and higher-level query behavior.
5. The star subsystem is isolated in src/star/. It distinguishes different star categories and behaviors through files such as majorStar.ts, minorStar.ts, adjectiveStar.ts, decorativeStar.ts, and horoscopeStar.ts. location.ts and FunctionalStar.ts provide location-based navigation, such as “which palace contains this star?” or “what is the opposite palace?”.
6. Core static domain data is centralized in src/data/. This includes constants, heavenly stems, earthly branches, and star definitions. The src/data/types/ folder defines the structured types used throughout the library for astrolabes, palaces, stars, and general domain objects. This separation keeps rule data distinct from computation logic.
7. Internationalization is a first-class subsystem. src/i18n/ contains locale-specific translation data for zh-CN, zh-TW, en-US, ja-JP, ko-KR, and vi-VN. The library supports mixed-language input and localized output, so the i18n layer is not just UI text—it is part of the domain model for names of stars, palaces, stems, branches, genders, and mutagens.
8. The repository’s architecture is strongly data-driven and rule-based rather than service-oriented. The main data flow is: user input for birth date/time/gender/language → astro computation → astrolabe model → functional wrappers for palace/star queries → localized results. Most query methods operate on the same underlying chart object rather than creating separate service layers.
9. There is a clear boundary between pure library code and examples that integrate external services. examples/chat-api/ demonstrates HTTP-based AI usage in JavaScript and Python, while examples/fullstack-demo/ contains a frontend, a Node backend, and a Python backend. These examples are not part of the core astrolabe engine; they show how to wrap the library in a conversational or web application.
10. The examples/fullstack-demo/frontend folder is a Vite + React/TypeScript app, and examples/fullstack-demo/backend is a Node.js service. The Python backend in examples/fullstack-demo/python-backend offers the same kind of integration path in Python. These example apps sit at the edge of the architecture and consume the library or AI API rather than implementing the chart logic themselves.
11. Testing is concentrated under src/__tests__/ and covers astro, star, palace, analyzer, and utility behavior. This indicates the repository treats rule correctness and query semantics as the most important stability boundary. jestconfig.json confirms Jest-based test execution.
12. Build and distribution tooling reflects a library-first package: tsconfig.json, webpack.config.js, .babelrc, ESLint/Prettier configs, and a package.json entry point for npm publication. The repository also ships prebuilt documentation assets under docs/, suggesting the docs site is statically generated and published alongside the package.
13. The docs/ directory is a deployed static documentation site, not source code. It includes localized HTML pages, versioned JS/CSS assets, sitemap/robots metadata, and route-specific pages like quick-start, type-definition, and learning posts. This site is a separate presentation layer for the library’s API and concepts.
14. CI/CD and release automation live in .github/workflows/ and .gitlab-ci.yml. The workflows cover code coverage, documentation publishing, and releases, which implies the repo’s delivery pipeline is centered on packaging the library and updating its docs rather than deploying a long-running server.
15. In architecture-diagram terms, the main subsystems are: domain data, core astrolabe engine, star/palace query wrappers, i18n translations, tests, docs site, and external integration examples. The critical boundary is between the pure deterministic computation engine in src/ and the consuming applications or AI/API examples in examples/ and docs/.
Main entry points: astro/index.ts Astro API · src/index.ts Entry Point · astro.ts Astro Engine · FunctionalAstrolabe.ts Astrolabe
Components 23
Core Library
Public TypeScript entry points, computation pipeline, and query wrappers.
- Entry Point · Public package surface that re-exports the main modules.
src/index.ts - Astro API · Exports the astrolabe computation and functional wrappers.
src/astro/index.ts - Astro Engine · Builds astrolabes from birth input and derives time-layer contexts.
src/astro/astro.ts - Analyzer · Applies rule-based analysis over computed chart data.
src/astro/analyzer.ts - Astrolabe · Chainable facade around the raw astrolabe model.
src/astro/FunctionalAstrolabe.ts - Horoscope · Higher-level query surface for horoscope-oriented operations.
src/astro/FunctionalHoroscope.ts - Palace · Chainable palace query object for containment and relation checks.
src/astro/FunctionalPalace.ts - Surpalaces · Surrounding-palace navigation and neighborhood queries.
src/astro/FunctionalSurpalaces.ts - Palace Logic · Core palace positioning and derivation logic.
src/astro/palace.ts - Star API · Exports star categories, location helpers, and star wrapper APIs.
src/star/index.ts - Star · Location-aware star facade for navigation and containment queries.
src/star/FunctionalStar.ts - Location · Star-to-palace navigation helpers such as opposite and containing palace.
src/star/location.ts
Domain Data
Static astrolabe constants, stars, stems/branches, and shared types.
- Data API · Central export for static domain constants and definitions.
src/data/index.ts - Data Types · Structured astrolabe, palace, star, and general domain types.
src/data/types/index.ts - Domain Constants · Core constants, stems, branches, and star definition tables.
src/data/constants.ts
Localization
Language packs and translation types used across the domain model.
- I18n API · Locale loader and translation entry point.
src/i18n/index.ts - Locale Types · Shared translation schema for stars, palaces, stems, branches, and mutagens.
src/i18n/types/index.ts - Locale Packs · Language-specific dictionaries for localized domain names and labels.
src/i18n/locales/zh-CN/index.ts
Validation
Automated tests and build/release tooling that protect the library contract.
- Astro Tests · Covers astrolabe generation, analysis, palace behavior, and plugin semantics.
src/__tests__/astro/astro.test.ts - Star Tests · Covers star categories and location helpers.
src/__tests__/star/star.test.ts
Docs & Examples
Static documentation site and integration examples that consume the library.
- Docs Site · Published documentation and localized learning pages.
docs/index.html - Chat API · HTTP/AI usage examples in JavaScript and Python.
examples/chat-api/README.md - Fullstack Demo · Frontend, Node backend, and Python backend showing library integration paths.
examples/fullstack-demo/README.md
Connections 30
- Entry Point → Astro API: exports · Package entry re-exports the astro API.
- Entry Point → Star API: exports · Package entry re-exports star helpers.
- Entry Point → Data API: exports · Package entry exposes domain data.
- Entry Point → I18n API: exports · Package entry exposes localization helpers.
- Astro API → Astro Engine: exposes · Astro barrel surfaces chart construction.
- Astro API → Analyzer: exposes · Astro barrel surfaces analysis logic.
- Astro API → Astrolabe: exposes · Astro barrel surfaces the main chart wrapper.
- Astro API → Horoscope: exposes · Astro barrel surfaces horoscope queries.
- Astro API → Palace: exposes · Astro barrel surfaces palace queries.
- Astro API → Surpalaces: exposes · Astro barrel surfaces neighborhood queries.
- Astro Engine → Data API: reads · Computation uses the static domain tables.
- Astro Engine → Palace Logic: builds · Astro engine relies on palace derivation logic.
- Astro Engine → Astrolabe: produces · Engine output is wrapped as an astrolabe object.
- Astro Engine → Analyzer: feeds · Computed charts are analyzed by rule logic.
- Astrolabe → Horoscope: chains to · Astrolabe wrapper exposes horoscope-level queries.
- Astrolabe → Palace: chains to · Astrolabe wrapper exposes palace-level queries.
- Horoscope → Surpalaces: navigates · Horoscope queries can reach surrounding palaces.
- Palace → Palace Logic: uses · Palace wrapper delegates core palace logic.
- Star API → Star: exposes · Star barrel surfaces the chainable star wrapper.
- Star API → Location: exposes · Star barrel surfaces navigation helpers.
- Star → Location: uses · Star wrapper relies on navigation helpers.
- Location → Palace Logic: resolves · Star location logic maps stars to palace positions.
- Data API → Data Types: typed by · Static domain data is shaped by shared types.
- I18n API → Locale Types: typed by · Localization API follows shared translation types.
- I18n API → Locale Packs: loads · Localization API resolves locale packs.
- Astro Tests → Astro Engine: verifies · Astro tests validate deterministic chart generation.
- Star Tests → Star: verifies · Star tests validate star query behavior.
- Docs Site → Entry Point: documents · Docs explain the public library entry point and API.
- Chat API → Entry Point: consumes · Chat examples consume the library API.
- Fullstack Demo → Entry Point: consumes · Demo app integrates the library into frontend and backend services.