惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

V
V2EX
IT之家
IT之家
博客园 - 叶小钗
雷峰网
雷峰网
T
Tailwind CSS Blog
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
S
SegmentFault 最新的问题
Apple Machine Learning Research
Apple Machine Learning Research
爱范儿
爱范儿
博客园 - 【当耐特】
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
大猫的无限游戏
大猫的无限游戏
Last Week in AI
Last Week in AI
月光博客
月光博客
酷 壳 – CoolShell
酷 壳 – CoolShell
Jina AI
Jina AI
博客园 - Franky
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
宝玉的分享
宝玉的分享
阮一峰的网络日志
阮一峰的网络日志
Hugging Face - Blog
Hugging Face - Blog
博客园 - 司徒正美

DEV Community

Authentication Security Deep Dive: From Brute Force to Salted Hashing (With Java Examples) Why AI Systems Don’t Fail — They Drift Spilling beans for how i learn for exam😁"Reinforcement Learning Cheat Sheet" I Replaced Chrome with Safari for AI Browser Automation. Here's What Broke (and What Finally Worked) How Python Borrows Other People's Work The $40 Architecture: Processing 1 Billion API Requests with 99.99% Uptime Vibe Coding: A Workflow Guide (From Zero to SaaS) Most webhook security guides protect the wrong side. The scary part is delivery. Headless CMS for TanStack Start: Build a Blog with Cosmic EU Age Verification App "Hacked in 2 Minutes" — What Actually Happened Comfy Cloud’s delete function does not actually remove files Running AI Models on GPU Cloud Servers: A Beginner Guide Event-driven media intelligence with AWS Step Functions and Bedrock I scored 500 AI prompts across 8 quality dimensions — here's what broke How to Call Google Gemini API from Next.js (Free Tier, No Backend Needed) The Portal Protocol: Reclaiming Human Connection in the Age of AI How to Fix Your Team's Scattered Knowledge Problem With a Self-Hosted Forum Intro to tc Cloud Functors: A Graph-First Mental Model for the Modern Cloud Designing Multi-Tenant Backends With Both Ownership and Team Access I Built a Neumorphic CSS Library with 77+ Components — Here's What I Learned PostgreSQL Performance Optimization: Why Connection Pooling Is Critical at Scale Cómo construí un SaaS multi-rubro para gestionar expensas en Argentina con FastAPI + Vue 3 🚀 I Built an Ethical Hacking Scanner Tool – Open Source Project I Replaced /usage and /context in Claude Code With a Single Statusline A Pythonic Way to Handle Emails (IMAP/SMTP) with Auto-Discovery and AI-Ready Design I Collected 8.9 Million Polymarket Price Points — Here's What I Found About How Markets Really Move EcoTrack AI — Carbon Footprint Tracker & Dashboard Everyone's Using AI. No One Agrees How. 5 self-hosted ebook managers worth trying in 2026 Building Your First AI Agent with LangChain: From Chatbot to Autonomous Assistant
I Built an AI-Powered Chinese BaZi (八字) Fortune Teller ...
kk mors · 2026-05-06 · via DEV Community

kk mors

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

Enter fullscreen mode Exit fullscreen mode

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(),    # 五行统计
    }

Enter fullscreen mode Exit fullscreen mode

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:

  1. Enter your birth info → Get free four pillars + short AI preview
  2. Share with 3 friends → Unlock the full Love Report for free
  3. 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

  1. 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.

  2. DeepSeek handles Chinese cultural context better than GPT. For non-Western subjects like BaZi, specialized models make a real difference.

  3. Gen Z loves this stuff. The astrology + tech crossover resonates with younger audiences who want personalized digital experiences.

  4. 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.

👉 Get Your Free BaZi Reading

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. 🔮