Every time someone asks me how to build an "AI astrology" app, they assume the hard part is the model. It isn't. The hard part is that the calendar underneath is a moving target, and every bug shows up as a vague complaint: "the chart is wrong."
I build Taoly, a Chinese Four Pillars (Bazi) tool. Here are the four places it actually broke, in the order they cost me the most time.
1. The month pillar does not follow the month
In Bazi, the month pillar is decided by solar terms, not by the Gregorian month. So "born in March" tells you nothing until you know whether the birth fell before or after 惊蛰. Every date needs an exact term timestamp for the birth year — which means your date library is not enough, and you end up shipping a term table instead of a formula.
The fix that stuck: precompute term boundaries for a wide year range, store them, and treat the term table as a data dependency with its own tests.
2. "11pm" is ambiguous, and only sometimes
Chinese hour pillars split the day into 12 two-hour blocks (时辰), and the boundary behaviour around 23:00 differs between schools. On top of that, many practitioners use true solar time (真太阳时), which needs longitude. So the same wall-clock time can produce different charts depending on options the user has never heard of.
We made this explicit in the UI: a timezone/longitude option with a documented default, and the chosen mode printed on the chart. Silent defaults here produce support tickets you cannot resolve.
3. Capsule caching by tuple
Once the chart is a pure function of (date, time, timezone, gender), caching gets easy: the key is the tuple, the value is the rendered chart. That also made server-side rendering cheap and made the API predictable for the AI chat layer, which needs the same chart the user is looking at.
4. Draw the chart yourself
The "life K-line" view — one candlestick per decade, from the luck pillars — is the part users screenshot. It's plain SVG. A charting library would have added ~90KB for twelve candles, and I needed the axis labels in Chinese with fixed positions anyway.
None of this is exotic. It is just the unglamorous half of the project: pinning the calendar, making the chart deterministic, and being honest in the UI about the choices that change the answer.
If you want to see the result, the free chart tool is at taoly.app.