The Algorithm That's Been Running for 3,000 Years
Most people think "Chinese fortune telling" is either superstitious nonsense or a mysterious old man with a beard.
The reality? BaZi (八字, literally "Eight Characters") is a deterministic algorithm. Your birth year, month, day, and hour map to specific Heavenly Stems (天干) and Earthly Branches (地支). These aren't random — they follow a 60-year cycle that's been documented since the Han Dynasty.
When I first learned this, I thought: This is literally a function. Input = birth datetime. Output = personality/life chart. Why can't I automate this?
Turns out, you can.
The Tech Stack
I built SoulChart over a weekend:
Python (lunar_python) → BaZi calculation engine
FastAPI → backend API
DeepSeek Chat → AI interpretation
Next.js 16 → frontend
PIL → share card generation
The hard part wasn't the astrology math (lunar_python handles the lunar/solar calendar conversion). The hard part was making the AI interpretation actually meaningful instead of generic horoscope fluff.
How BaZi Actually Works (Simplified)
Here's the core algorithm:
from lunar_python import Solar8Char, Solar
def calculate_bazi(year, month, day, hour):
solar = Solar.fromYmdHms(year, month, day, hour)
eight_char = Solar8Char(solar)
return {
"four_pillars": eight_char.getBaZi(), # 年柱, 月柱, 日柱, 时柱
"day_master": eight_char.getDayGan(), # 日主 (your core element)
"zodiac": eight_char.getShengXiao(), # 生肖
"five_elements": eight_char.getWuXing(), # 五行统计
}
Your Day Master (日主, the heavenly stem of your day pillar) is your core essence. For example:
- 甲/乙 (Wood) — Growth-oriented, flexible, creative
- 丙/丁 (Fire) — Passionate, expressive, sharp
- 戊/己 (Earth) — Stable, reliable, nurturing
- 庚/辛 (Metal) — Determined, structured, precise
- 壬/癸 (Water) — Adaptive, deep, intuitive
The interaction between your Day Master, the four pillars, and the Five Elements creates a uniquely detailed personality profile — much more granular than Western zodiac sun signs.
Where AI Comes In
The lunar_python library gives you the raw data. But raw data doesn't help anyone.
That's where DeepSeek shines. Instead of generic "you'll meet someone special" readings, I prompt it with the actual BaZi data:
"Day Master is 己 (Earth). Born in Dragon year. Four Pillars: [data]. Five Elements: 2 Wood, 1 Fire, 3 Earth, 1 Metal, 1 Water."
The AI reads this like a trained BaZi master and produces:
- Personality analysis (accurate enough that my friends said "that's scary")
- Relationship dynamics (which elements complement yours)
- Career direction (which industries suit your element)
- Yearly forecast (how the current year's element interacts with yours)
The Invite Mechanic — Why It's Not Just a Paywall
I hate paywalls. So instead of "pay or leave", SoulChart uses a share-to-unlock model:
- Enter your birth info → Get free four pillars + short AI preview
- Share with 3 friends → Unlock the full Love Report for free
- Or buy instantly for $3.99-$7.99
The idea is: BaZi readings are best when discussed with friends. Your Wood element interacts with someone's Fire differently. It becomes a social experience.
What I Learned Building This
Ancient systems are underrated. BaZi has been refined for millennia. The fact that it maps to a deterministic algorithm makes it perfect for AI augmentation.
DeepSeek handles Chinese cultural context better than GPT. For non-Western subjects like BaZi, specialized models make a real difference.
Gen Z loves this stuff. The astrology + tech crossover resonates with younger audiences who want personalized digital experiences.
Free preview + social unlock converts better than free trial. People are more willing to share than to pay upfront — and sharing brings more users.
Try It Yourself (Free, No Signup)
The free preview gives you your Four Pillars chart, Day Master analysis, and Zodiac sign immediately. No email required.
If you invite 3 friends, the full Love Report unlocks automatically. Or grab the complete reading for $3.99.
I'd love to hear: What's your Day Master? Drop your birth year + animal in the comments, and I'll tell you what your element says about your personality. 🔮



