About this project

Zi Wei Dou Shu is a traditional Chinese metaphysical charting system. This project is an open-source chart engine based on Ni Haixia's Tian Ji teaching system, built with Next.js 14 (App Router) and TypeScript. It includes chart algorithms, a knowledge base, classical text data, a frontend interface, and a large-scale sample dataset. The author provides an online site, metisziwei.com, for direct experience. Core chart algorithms reside in the lib/ziwei/ directory: algorithm.ts implements the complete charting process, including setting the Destiny Palace, determining the Five Elements Bureau, placing the 14 Major Stars, placing auxiliary stars, and calculating major and minor limits; sihua.ts is the Four Transformation Flying Stars system (Lu, Quan, Ke, Ji), including transformation tables for each Heavenly Stem; patterns.ts is a knowledge base of over 1,100 lines covering classic patterns like Zi Fu Tong Gong, Ri Yue Bing Ming, and Qi Sha Chao Dou; heming-knowledge.ts provides dual-chart comparison methodology; cities.ts includes Chinese city coordinates for true solar time correction; constants.ts (Heavenly Stems, Earthly Branches, and star constants), types.ts (type definitions), and famous.ts (historical celebrity chart examples) are also included. The underlying charting relies on open-source libraries iztro and lunar-javascript. For classical texts, lib/classics/ contains original text from Gu Sui Fu, Zi Wei Dou Shu Quan Ji (Qing Dynasty edition), and Zi Wei Dou Shu Quan Shu (Chen Xiyi's version); lib/seo/ provides structured knowledge data for 14 Major Stars × 12 Palaces, usable for content generation or knowledge base construction. The frontend interface includes a charting workbench (chart grid, palace details, star panel), a dual-chart analysis page, a classical text reader with full-text search, and a metaphysical encyclopedia (14 Major Stars and 12 Palaces knowledge pages). It supports light/dark theme switching and mobile adaptation. Styling uses Tailwind CSS and CSS Variables design system, with animations via Framer Motion. Dataset: The repository Releases provide a v3.0 chart sample dataset totaling 518,400 entries (covering combinations of 60 years × 12 months × 30 days × 12 hours × 2 genders), approximately 5.5 GB, split into 3 compressed volumes with SHA256 checksum files. Each sample includes a complete chart JSON and interpretation text for 13 topics (overall destiny, wealth, career, relationships, health, etc.). The README notes its use for small model fine-tuning, RAG retrieval sources, A/B baseline comparison after modifying patterns.ts, and metaphysical research and data analysis. Boundaries to note: The open-source portion does not include AI interpretation prompts, backend API routes (e.g., /api/interpret, /api/heming, /api/generate), user systems, server-side security, or deployment configurations. The chart algorithm and frontend interface can run independently; for AI interpretation capabilities, users must implement corresponding interfaces themselves. The README suggests referencing the knowledge bases in patterns.ts and heming-knowledge.ts, combined with any LLM to construct prompts. Quick start: Clone the repository, run npm install, copy .env.example to .env.local and fill in the AI API Key, then start the development server with npm run dev. License: Code (lib/, app/, components/) is under the MIT license; the sample dataset is freely usable (including commercially), with the sole requirement of attribution; classical texts are in the public domain.