How sylarlong/react-iztro works
1. Repository role
- This is a React component library, not a standalone app.
- Its purpose is to render a Zi Wei Dou Shu astrolabe / star chart based on the astrology engine from iztro.
- The main integration boundary is: consumer app passes birth and horoscope props into the library; the library returns a fully rendered chart.
2. Public entry points
- src/index.ts is the top-level export surface.
- Each component folder also has its own index.ts, so the package likely supports both primary top-level usage and selective component imports.
- The main public component is Iztrolabe.
3. Core composition
- Iztrolabe is the orchestrator for the whole chart.
- It composes the other UI subsystems into one astrolabe layout:
- Izpalace for each palace cell
- IzpalaceCenter for the center/overlay controls and indicators
- Izstar for star rendering
- This is the main visual aggregation layer of the repo.
4. Palace rendering subsystem
- src/Izpalace contains the component and types for an individual palace.
- This is the repeating structural unit in the chart, responsible for displaying palace-level information such as names, stems, stars, and state-specific markings.
- Izpalace.css indicates the palace is heavily styled as a visual grid/card element.
5. Center/interaction subsystem
- src/IzpalaceCenter contains IzpalaceCenter.tsx, plus Item.tsx and Line.tsx.
- This subsystem likely renders the chart’s central control area, including:
- period / limit indicators
- directional or relationship lines
- interactive items/buttons mentioned in the README
- It is the chart’s main dynamic overlay region rather than a simple static display.
6. Star rendering subsystem
- src/Izstar is the star marker/label unit.
- It has its own type file, which suggests stars are treated as first-class domain entities with structured metadata.
- This component is reused inside palaces to render star names, highlights, and visual states.
7. Domain typing and shared config
- src/config/types.ts and the per-component *.type.ts files define the domain model used across the library.
- This is the repo’s main internal contract boundary: chart data, palace props, star props, and locale/config values are kept consistent here.
- Architecturally, the types layer is important because the UI is driven by a rich astrology domain model rather than generic list/grid data.
8. Localization layer
- src/locales contains language packs for:
- en-US
- ja-JP
- ko-KR
- vi-VN
- zh-CN
- zh-TW
- src/locales/index.ts aggregates these strings for lookup.
- This means the chart UI is designed to be language-aware at the component level, not just via external app translation.
9. Styling and theming
- Styling is split across component-scoped CSS files plus src/theme/default.css.
- The architecture is therefore CSS-driven and themeable, with a default visual baseline that consumers can override.
- The README also suggests many UI elements can be shown/hidden or restyled by overriding defaults rather than changing logic.
10. Data flow
- The consumer passes birth and horoscope inputs to Iztrolabe.
- The library uses the underlying astrology model to derive palace/star/limit information.
- That derived model is then rendered through:
- palace cells
- star badges
- center indicators and lines
- localized labels
- So the flow is: props in → astrolabe model → composed chart UI out.
11. Runtime and dependency boundary
- This package is a frontend React/TypeScript library.
- It depends on the external iztro astrology library for the domain calculation layer, while this repository focuses on rendering and UI behavior.
- There is no sign of backend services, persistence, or network orchestration in this repo.
12. Development and documentation surface
- .storybook and Iztrolabe.stories.tsx show that Storybook is the primary local development and visual verification environment.
- The repository also includes Babel, TypeScript, and ESLint configs, indicating a library build/quality pipeline rather than an application runtime.
- .nojekyll suggests docs/demo hosting support, likely for GitHub Pages style publication.
13. How to draw the architecture
- Draw one outer boundary for the consumer app and one inner boundary for the react-iztro library.
- Inside the library, place:
- Iztrolabe as the top-level coordinator
- Izpalace / IzpalaceCenter / Izstar as the rendering subsystems
- locales / theme / types as shared support layers
- Show iztro as the external domain-engine dependency feeding data into the component tree.
Main entry points: Iztrolabe.tsx Iztrolabe · index.ts Public API · IzpalaceCenter.tsx IzpalaceCenter · Izpalace.tsx Izpalace
Components 16
Consumer app
Host application passes birth and horoscope props into the library.
- Consumer app · Application that supplies birth and horoscope inputs to the chart component.
react-iztro
React component library that renders the Zi Wei Dou Shu astrolabe.
- Public API · Top-level package export surface for primary and selective imports.
src/index.ts - Iztrolabe · Main component that composes the full astrolabe layout from domain props.
src/Iztrolabe/Iztrolabe.tsx - Izpalace · Repeating palace cell component for palace names, stars, stems, and markings.
src/Izpalace/Izpalace.tsx - IzpalaceCenter · Central chart area for indicators, controls, and directional overlays.
src/IzpalaceCenter/IzpalaceCenter.tsx - Item · Reusable element for interactive or labeled items inside the center overlay.
src/IzpalaceCenter/Item.tsx - Line · Line element used to draw relationships or directional markers in the center.
src/IzpalaceCenter/Line.tsx - Izstar · Star rendering unit used to display star labels and visual states.
src/Izstar/Izstar.tsx
Shared support
Types, locales, and theme assets used across the component tree.
- Palace types · Type definitions for palace props and palace-level domain data.
src/Izpalace/Izpalace.type.ts - Star types · Type definitions for star entities and display metadata.
src/Izstar/Izstar.type.ts - Config types · Shared chart and configuration types used across the library.
src/config/types.ts - Locales · Aggregated language packs for chart labels and localized text.
src/locales/index.ts - Default theme · Baseline theme and styling defaults for the rendered chart.
src/theme/default.css
Dev surface
Storybook and package-level tooling for development and verification.
- Storybook · Visual development and component verification environment.
.storybook/main.ts - Iztrolabe story · Storybook entry showcasing the main chart component.
src/Iztrolabe/Iztrolabe.stories.tsx
Other components
- iztro · External domain engine that provides astrology calculations and chart data.
Connections 18
- Consumer app → Iztrolabe: props in · Birth and horoscope inputs flow from the host application into the chart component.
- iztro → Iztrolabe: domain data · Astrology calculations and chart model data feed the renderer.
- Public API → Iztrolabe: exports · Top-level package surface re-exports the main component.
- Public API → Izpalace: exports · Package surface exposes selective palace imports.
- Public API → IzpalaceCenter: exports · Package surface exposes selective center imports.
- Public API → Izstar: exports · Package surface exposes selective star imports.
- Iztrolabe → Izpalace: composes · The chart is assembled from repeated palace cells.
- Iztrolabe → IzpalaceCenter: composes · The chart uses a central overlay for indicators and interactions.
- Iztrolabe → Izstar: renders · Stars are rendered as part of the composed astrolabe.
- Iztrolabe → Locales: localizes · Labels and UI text are resolved through the locale packs.
- Iztrolabe → Default theme: styles · Default theme provides the baseline visual presentation.
- Izpalace → Palace types: typed by · Palace rendering is driven by palace domain types.
- Izstar → Star types: typed by · Star rendering is driven by star domain types.
- IzpalaceCenter → Item: uses · Center overlay is built from reusable items.
- IzpalaceCenter → Line: uses · Center overlay draws connector lines and relationships.
- Iztrolabe story → Iztrolabe: shows · Storybook demonstrates the main component in isolation.
- Storybook → Iztrolabe story: loads · Storybook configuration includes the chart story.
- Iztrolabe → Config types: shared schema · Shared config and chart types connect the orchestration layer to the rest of the components.