Building LaKinh: Vietnamese Astrology Meets Modern Code
Building LaKinh: Vietnamese Astrology Meets Modern Code
I'm building an app that calculates Vietnamese astrology charts.
Not a simple "what's your zodiac sign" app. The real deal: Tử Vi Đẩu Số — a complex divination system with 100+ stars, 12 palaces, and algorithms that would make any developer's head spin.
And I'm doing it completely in the open.
## What Is LaKinh?
LaKinh (La Kinh / 羅經) is a Vietnamese astrology app that generates your complete astrological chart based on:
- >Birth date and time
- >Lunar calendar calculations
- >Gender
- >Hour of birth
It calculates:
- >12 palaces (Mệnh, Thân, Tài Bạch, etc.)
- >100+ stars and their positions
- >Life phases (Đại Hạn, Tiểu Hạn)
- >Annual predictions (Lưu Niên)
- >Tràng Sinh 12-phase life cycle
Think of it as a birth chart calculator, but for a system that's been refined over 1000 years in Vietnam and China.
## Why Am I Building This?
Reason 1: The existing tools suck.
Most Vietnamese astrology sites are:
- >Cluttered with ads
- >Terrible UX
- >Mobile-unfriendly
- >No explanations
- >Look like they're from 2005
Reason 2: The algorithms are fascinating.
This isn't "if month = 3 then Pisces." This is:
- >Stem-Branch calendar conversions
- >Modular arithmetic with 10-stem and 12-branch cycles
- >Star positions based on birth hour AND lunar month
- >Gender-dependent calculation flows
- >Five-element (Ngũ Hành) interactions
It's like solving a mathematical puzzle that's also culturally significant.
Reason 3: I want to preserve knowledge.
These calculation methods exist in old books and scattered websites. Many Vietnamese millennials don't know how to calculate their own charts. I want to make it accessible.
## The Technical Challenge
Here's what makes this hard:
1. No official spec exists.
There's no "RFC for Tử Vi calculations." Knowledge is scattered across:
- >Vietnamese astrology books (vague descriptions)
- >Old websites (tuvi.vn, lichngaytot.com)
- >Forums (conflicting information)
- >Masters who guard their "secrets"
2. Every star has different logic.
Some stars follow simple patterns:
Kình Dương position = (Lộc Tồn position + 1) % 12
Others are nightmare fuel:
Hoả Tinh position = lookup table based on:
- Year branch group (Dần Ngọ Tuất vs Thân Tý Thìn vs...)
- Birth hour
- Then add modular offset
- Unless it's a leap month
- Then check if...
3. Reference sites don't always agree.
I cross-reference against tuvi.vn and lichngaytot.com. Sometimes they differ. Which is correct? I have to dig into old texts.
4. Testing is manual and tedious.
For each change, I:
- >Generate a test chart
- >Compare against reference sites
- >Check all 12 palaces
- >Verify 100+ star positions
- >Check Đại Hạn / Tiểu Hạn calculations
- >Test edge cases (leap years, different Cục, etc.)
One typo in a lookup table = wrong predictions for thousands of people.
## My Development Method
I work with Claude Code CLI in focused sessions:
Step 1: Research
- >Study one star or algorithm
- >Document the formula
- >Find test cases from reference sites
Step 2: Implement
- >Write TypeScript
- >Add unit tests where possible
- >Cross-verify against multiple sources
Step 3: Verify
- >Generate real charts
- >Compare pixel-by-pixel with tuvi.vn
- >Fix discrepancies
Step 4: Document
- >Update session summary
- >Note what's done, what's next
- >Save for context in future sessions
I use the Kai system (my 5-file structure) to keep context across sessions. Each session picks up exactly where the last one ended.
## Current Progress
As of February 2026, I've completed:
### ✅ Core Engine
- >Lunar calendar conversion
- >Stem-Branch calculations
- >Palace (Cung) positioning
- >Five-element (Cục) detection
### ✅ Major Stars (14 total)
- >Tử Vi, Thiên Cơ, Thái Dương, Vũ Khúc...
- >All verified 100% against tuvi.vn
### ✅ Minor Stars (27 total)
- >Kình Dương, Đà La
- >Hoả Tinh, Linh Tinh
- >Đào Hoa, Hồng Loan
- >Tràng Sinh 12-phase cycle
- >All 5 Cục (Thuỷ, Mộc, Kim, Thổ, Hoả)
### ✅ Life Phases
- >Đại Hạn (10-year cycles) — 100% accurate
- >Tiểu Hạn (yearly cycles) — verified
- >Lưu Niên overlay (10 annual stars)
### 🚧 In Progress
- >Star descriptions UI (40 stars need short descriptions)
- >Tràng Sinh labels in palace UI
### ⏳ Coming Next
- >Tứ Hoá transformations (complex!)
- >AI-powered chart interpretations
- >Caching strategy to reduce API costs
- >Mobile responsive polish
## The Tràng Sinh Breakthrough
One of my proudest moments: cracking the Tràng Sinh formula.
Tràng Sinh is a 12-phase life cycle that starts at different palaces based on your Cục (element group) and gender.
The pattern seemed random:
- >Thuỷ (Water): Dương starts at Thân, Âm starts at Tý
- >Mộc (Wood): Dương at Hợi, Âm at Dậu
- >Kim (Metal): Dương at Mão, Âm at Tỵ
- >...
After testing dozens of birth charts, I found the formula:
dương_start + âm_start ≡ 8 (mod 12)
Meaning: For each element, if you know where Dương (male) starts, Âm (female) is always 8 steps away in the opposite direction.
This one formula replaced 10 lookup tables.
I verified it across all 5 Cục, multiple test cases. 100% match with tuvi.vn.
That's the kind of detective work this project requires.
## Why Build In Public?
I'm documenting everything because:
1. Accountability When I say "I'm building LaKinh," people can see actual progress. Not vaporware.
2. Learning in public Other developers interested in cultural algorithms can follow along. The techniques apply beyond astrology.
3. Transparency If you're going to trust an app with your birth chart, you deserve to know the calculations are accurate.
4. Community verification If I make a mistake, someone who knows Tử Vi can catch it. Crowdsourced accuracy.
## The Tech Stack
Frontend: React 18 + TypeScript + Vite + Tailwind CSS Backend: Firebase Firestore (for caching interpretations) Deployment: Vercel Development: Claude Code CLI + Cursor IDE Version Control: Git + GitHub
Why Firebase? If I add AI interpretations later, I can cache them. "Mệnh palace with Tử Vi + Thiên Phủ for Kim Cục male" → store once, reuse forever. Saves API costs.
## The Challenges Ahead
Challenge 1: Tứ Hoá Transformations
This is the final boss. Tứ Hoá changes star meanings based on:
- >Your birth year stem
- >Which palace a star is in
- >Interactions with other stars
It's like CSS specificity rules, but for divination.
Challenge 2: Interpretations
Calculating positions is math. Interpreting them is art.
"Tử Vi in Mệnh palace with Tả Phù and Hóa Quyền in Kim Cục for a Dương male born in Horse year" = ??
I'll likely use Claude API to generate interpretations, then cache them in Firestore to avoid repeat costs.
Challenge 3: Mobile UX
A chart has 12 palaces, 100+ stars, multiple layers of info. How do you show this on a 375px screen without overwhelming users?
Still figuring this out.
## What Success Looks Like
Phase 1 (Current): Accuracy Get the calculations 100% correct. This is non-negotiable.
Phase 2: UX Make it beautiful and easy to use. Better than any existing tool.
Phase 3: Interpretations Add AI-powered explanations. Not just data, but meaning.
Phase 4: Community Let users save charts, share with friends, compare with family.
Revenue? Maybe later. Right now, I'm focused on building something accurate and useful.
## The Meta-Lesson
Building LaKinh taught me:
Complex cultural algorithms can be reverse-engineered.
You don't need access to ancient masters. You need:
- >Multiple reference sources
- >Systematic testing
- >Pattern recognition
- >Patience
AI is a force multiplier for solo developers.
I'm one person. I don't speak ancient Chinese. I'm not an astrology expert.
But with Claude Code CLI, I can:
- >Implement complex algorithms
- >Test edge cases
- >Refactor confidently
- >Document thoroughly
What would've taken a team of 3-4 people, I'm doing alone.
Building in public creates accountability.
Knowing people are watching makes me:
- >Test more thoroughly
- >Document better
- >Ship consistently
- >Care about quality
## Follow The Journey
I update progress in session summaries after each major milestone. Next big task: star descriptions in the UI.
If you're interested in:
- >Cultural algorithm preservation
- >Working with AI as a solo dev
- >Vietnamese astrology
- >TypeScript + complex math
This project has all of it.
The code will be open source once I clean it up. The goal isn't to hoard knowledge. It's to make it accessible.
Current status: ~70% complete on calculations, 30% on UX.
Next session: Add star descriptions to palace modal.
Timeline: Launch beta in 4-6 weeks.
Will it make money? Don't know, don't care yet. Right now, I'm preserving cultural knowledge and learning a ton.
That's reward enough.
—
P.S. If you know Tử Vi and spot errors in my calculations, please tell me. Accuracy matters more than ego.
P.P.S. Yes, I'm a designer who codes. Yes, I learned modular arithmetic for this project. Yes, it's worth it.