Web AppProjects

Saju Kaaju — Korean Saju Reading

A Korean Saju (사주팔자) web app that separates "calculating" from "telling" — a Python engine calculates from real KASI astronomical data, accurate to the minute, then Uncle Pae (AI) explains it in plain language, a reading that works as a mirror. Built with Next.js 15 + Supabase + Stripe · mobile-first · PWA

13 min read

A Korean Saju (사주팔자) web app that separates "calculating" from "telling". A Python engine works out the four pillars from real Korean astronomical data (KASI), accurate to the minute, then Uncle Pae (AI) explains it in plain language. The reading is a mirror for seeing yourself, not a verdict, and it never sells fear.

Next.js 15React 19Supabase (RLS)StripePython · KASIkorean-sajuGemini / OpenAIPWA
Saju Kaaju home page on desktop, centered at 768px wide, with Uncle Pae sitting at a tea table and the headline about seeing yourself more clearly before big decisions
Saju Kaaju home page on mobile
The real app's home page — desktop (768px letterbox) and mobile
Empathize · Define

The problem

Why is it harder than it looks to make an online reading both accurate and warm?

Saju Kaaju home page, the "What Uncle Pae can help with" section: cards for self, work, love and life timing, plus question chips such as "Is this job really right for me?"
The real questions people bring to a fortune teller — the app turns them into question chips on the home page instead of fixed predictions

Korean Saju (四柱 — the four pillars of destiny) is hard to calculate. The year pillar depends on 입춘 (the start of spring), the month pillar on the 12 절기 (solar terms), and the hour pillar needs a 진태양시 (true solar time) correction by longitude, because Korean Standard Time is based on Japan's meridian (off by about 32 minutes). One minute off and a pillar changes, and the whole reading drifts. Let an AI do the math itself and it just makes the numbers up.

— The starting brief, before building Saju Kaaju

Most online readings give a fixed verdict and sell fear

They tell you this is definitely what will happen, then end with a lucky charm to buy. The listener is left with no choices, and it doesn't really help anyone understand themselves.

Calculating Korean Saju to the minute is very hard

You have to handle the 입춘/절기 boundaries, correct for 진태양시 by longitude, and split 야자시/조자시 (late and early midnight hours). One minute off and the day or hour pillar changes.

Letting the AI calculate the chart = made-up numbers

A language model is not an astronomical calculator. Ask it for the hour pillar and it guesses (hallucinates), confidently wrong. You can't trust it at all.

Terms like 오행 / 십신 / 격국 mean nothing to most people

The output of the system is all Hanja and Korean. Even if the math is right, if it isn't told in everyday language, people get nothing out of it.

It needs real auth, quotas and payments, with abuse protection

Not just a demo page: real login, a question quota that can't be edited on the client, and Stripe payments that top up the quota correctly and idempotently.


Ideate

The solution

Separate the "fact calculator" from the "storyteller" — an accurate engine feeding an AI that speaks plainly

The "Read from the system, translated into the language of life" section: cards for your overall self, work that uses your energy well, balanced love, and this year's timing
Trust strip: data from KASI, no threats, no judgment, direct but gentle
The solution on the real page: system terms translated into the language of everyday life, plus a promise of "no threats, no judgment" and a KASI data reference

Separate "calculating" from "telling" — to prevent hallucination

The Python engine calculates the four pillars, 격국 (chart structure), 용신 (useful element) and forecasts as facts → the AI only "tells the story" and never touches the math, so the numbers can be trusted

"Uncle Pae" — a warm character voice that reads your chart like a mirror

The system prompt is the persona of a Korean uncle: direct but kind, no threats, no fixed verdicts, no lucky charms for sale — the listener always keeps their choices

A real Korean Saju calculator (KASI)

Uses the korean-saju engine with real KASI data built in, corrects 진태양시 by the longitude of the birth city, accurate to the minute, with a calendar through 2050

Personalized fortune calendar + daily cache

Daily and hourly forecasts based on each person's birth chart. They're deterministic, so they can be cached per user per day in the DB — reopening doesn't recalculate.

Quotas and payments handled on the server only

Quota is deducted by an atomic Postgres function, RLS is on for every table, and top-ups go through an idempotent Stripe webhook — the client can't change its own quota


Prototype

How it works — 4 steps

From entering a birth date to Uncle Pae telling you your reading

The "How Uncle Pae reads for you" section in 4 steps: give your birth date and time, Uncle Pae calculates your Saju, translates it into the language of life, and you keep talking with him
The same 4 steps are explained on the real app's home page
1

Enter birth details

Onboarding: date · time · birth city → longitude from the city list

2

Engine calculates

Python (KASI) calculates the four pillars + 격국/용신 → cached in the DB

3

Uncle Pae tells it

The AI takes the facts and tells them in plain language, streamed and grounded in the birth chart

4

Calendar + keep talking

Open the daily fortune calendar → keep chatting → run out of quota → top up THB 99


Prototype

Tech Stack & Architecture

One Next.js app for everything (web + API) on Vercel · the Python engine as a serverless function · Supabase handles DB + Auth + RLS

Sign-in page with a Continue with Google button and an email and password form
The Supabase Auth layer on the real page — Google or email/password before chat and calendar
Web app (PWA · mobile-first ≤768px)
Chat with Uncle Pae Fortune calendar Profile + element chart Onboarding
↕
Next.js 15 (App Router) on Vercel
/api/chat /api/calendar /api/onboarding /api/stripe
↕
Saju Engine (Python · KASI) + Uncle Pae AI (Gemini → OpenAI)
calculate.py forecast.py streaming prompt cache
↕
Supabase (Postgres + Auth + RLS) + Stripe
profiles chats / messages quota_ledger stripe webhook
Why this stack?

Next.js 15 App Router — web, API routes and the Python function in one deploy, sharing the session directly · Supabase covers Postgres + Google/Email Auth + merge-by-email + RLS in one service — fewer moving parts · Python on Vercel runs the korean-saju engine with 0 dependencies as is (astronomical math is Python's job) · Provider abstraction — switch AI (Gemini ↔ OpenAI ↔ Claude) in a single file without touching routes or UI


Prototype

What I built — 8 core capabilities

The full loop, from entering a birth date to chatting with Uncle Pae and paying to top up the quota

Full reading report titled "You are mountain earth sitting on a monkey", with 12 topic chips and a card on the direction of the next 2 years
The full 12-topic reading report (sample page from the app · name changed to "Sample User")

Chat with Uncle Pae

Streaming chat grounded in the birth chart — pin, rename, delete, new chat + starter prompts (overview / work / love / money)

Korean Saju Engine

Calculates the four pillars · 오행 (five elements) · 십신 (ten gods) · 격국 · 용신 · 대운/세운 (10-year and yearly luck) from real KASI data, with 진태양시 corrected by longitude

Personalized fortune calendar

Daily and hourly forecasts from the user's chart — highlights good and caution days, auspicious hours → deep-link to ask Uncle Pae about that day

Onboarding + element chart

Enter date · time · birth city (city picker → longitude) → build the Saju chart, showing the four pillars + element balance (오행 balance)

Multi-profile

Read for other people too — switch profiles (active profile), add someone new, each with their own Saju chart and chat room

Full report + Reveal

Generates a full reading report + a reveal page with a share card (html-to-image) and Uncle Pae reading it aloud (TTS)

Auth + atomic quota

Google + Email/Password (merge-by-email), quota deducted by an atomic Postgres function + append-only ledger + RLS

Payments + admin back office

Stripe consumable (THB 99 = 100 questions) topped up via an idempotent webhook + admin dashboard: customers / quota / revenue / cost


Prototype

The look — chatting with Uncle Pae

Open the app → see your own element chart → talk to Uncle Pae right away, on one screen (mobile-first)

Uncle Pae character art: an older man in glasses sitting at a tea table, holding a bottle of soju, with a fortune notebook on the table
The "Uncle Pae" character art used in the app — tea table, fortune notebook, warm light
👴 Uncle Pae Elements Calendar Quota 8
Pillar時 Hour日 Day月 Month年 Year
Stem·Branch 癸巳 丙寅 丙子 己巳
🌲 Wood 1 🔥 Fire 3 🏔 Earth 1 ⚡ Metal 0 💧 Water 3
👴 Uncle Pae Your fire is strong, you know — the chart says you're impatient and quick to decide. That doesn't mean you're bad. It means your fire runs hot. Use it well and it gives warmth; use it badly and it burns you. Take this year one step at a time. No rush.
Overview Work Love Money This year

Prototype · UI Craft

UI & Design System

Saju Kaaju from a product designer's view — the token system, real screens from the flow, and the reasoning behind each UX decision

Brand book page on Uncle Pae's colors, mood and look: Dark Tea Brown, Rice Paper, Tea Beige, Seal Red, Muted Green, and the imagery to stay away from
The Visual Identity page in the Saju Kaaju brand book — the "tea table" palette that became the app's tokens
Design tokens — designed as a system
accent
#6D28D9
accent-dark
#4C1D95
accent-light
#EDE9FE
bg
#FDFBF6
text
#1C1917
border
#E7E5E4
H1 · 28 / 700Saju Kaaju
Body · 16 / 400Uncle Pae tells your chart in plain words
Caption · 12IBM Plex Sans Thai · 300–700
spacing 4 8 12 16 24
radius 12px 16px
Screen showcase — the real flow on mobile
Saju Kaaju home page on mobile
Home · Uncle Pae introduces himself and starts the reading
Sign-in page with a Continue with Google button and an email and password form
Sign in · Google or email
Full reading report titled "You are mountain earth sitting on a monkey", with 12 topic chips
Reading report · 12-topic summary
Element balance section of the report, with percentage bars for wood, fire, earth, metal and water
Element balance · 오행 balance from the engine
UI decisions — why I chose this

Mobile-first, letterboxed at 768px

Almost everyone visits Uncle Pae on a phone, so I designed for 393 first, then scaled to 768 → 1440

Why: on large screens the content is centered (capped at 768) instead of stretching into an empty layout — it keeps the calm "tea table" mood rather than forcing a desktop grid

An accessibility floor I wouldn't lower

Base font ≥ 16px, touch targets ≥ 44px, contrast ≥ 4.5:1 for all text and button colors

Why: the audience is broad and reads long passages on phones — small type or cramped buttons are a real barrier, not a nice-to-have

Microcopy in "Uncle Pae's" voice

Loading = "Uncle Pae is brewing your reading, hang on a moment" · Error = "Aiyah, the system tripped a little. Try again."

Why: the states people find most frustrating (waiting, errors) are exactly where the character needs to show up — and users never feel blamed for a typo

Readings as cards, not a wall of text

Terms like 오행/십신/격국 are mapped to plain language before display + long readings split into sections/cards + starter prompts

Why: however accurate the engine is, people won't read one huge block of text — visual hierarchy turns a deep subject into something easy to follow

Test & Iterate

Hacking the problems

6 problems I had to solve myself — the precision of the Korean system, keeping the AI in check, and money that can't go wrong

Element balance section of the report, with percentage bars for wood, fire, earth, metal and water, and a card on boosting luck with the wood element
Engine results (오행 / 用神) are mapped to plain language before Uncle Pae tells them — the numbers come from the calculation, not an AI guess

Korean standard time follows Japan's meridian — the hour pillar drifts

KST is based on the 135° meridian (Japan), but Seoul sits at 126.98° — true solar time runs about 32 minutes behind. Use KST directly for the hour pillar and the pillar is wrong.

Fix: use the korean-saju engine, which corrects 진태양시 by the birth city's longitude + uses 절기/입춘 boundaries from KASI + splits 야자시/조자시 — verified 100% matching over 35,000 days

If the AI calculates the chart, it makes up numbers

Language models answer chart numbers confidently but wrongly — you can't trust a reading built on bad numbers

Fix: a strict split of roles — the Python engine calculates the "facts" (pillars/격국/forecast) and passes them to the AI as context; the AI only "tells" + prompt caching on the system prompt and Saju chart to keep tokens in check

Running a Korean engine (Python) alongside Next.js

The site is TypeScript/Next.js, but the calculation lives in a Python package — how do you run them on the same serverless setup?

Fix: deploy the engine as a Vercel Python function (/api/*.py) — inject korean_saju/src into sys.path; the package has 0 dependencies so it bundles easily; Next.js calls it via an internal fetch and caches the result in the DB

Preventing quota abuse + race conditions when deducting

If the quota is deducted on the client, users can edit it; many simultaneous requests can deduct wrongly or go negative; and duplicate webhooks can top up twice

Fix: a Postgres function consume_question() deducts free/paid atomically in a single query + RLS lets only the service role write + an append-only quota_ledger + an idempotent Stripe webhook keyed on a unique stripe_session_id

The system speaks Hanja, and the AI has to be warm, not scary

Engine output is all 오행/십신/격국, which people can't read — and AI by default tends to give fixed verdicts or sound too formal, nothing like Uncle Pae

Fix: the engine maps labels to plain language before sending + the system prompt embeds Uncle Pae's brand pillars (read the chart like a mirror, no threats, no lucky charms for sale, always leave a choice) + starter prompts to get people talking

A month view = dozens of days of calculation, slow and costly

The month view of the calendar needs a forecast for every day. Calling Python again every time it opens is both slow and wasteful.

Fix: forecasts are deterministic (same chart + same day = same result), so they are cached per user per day in a daily_forecast_cache table — the calendar checks the cache first and only calls the engine on a miss, then stores the result

Define

Deliberate design decisions

What I chose "not to do" matters as much as what I did

Brand book page on what Uncle Pae does and doesn't do, such as no fixed verdicts on your life and no selling fear
The "won't do" boundaries were written into the brand book from the start, then used to steer both the UI and the system prompt

Saju Kaaju deliberately "reads the chart as a mirror, not a fixed fate" — no lucky charms, no selling fear, the listener always keeps their choices · the engine calculates and the AI tells (split roles to prevent hallucination) · mobile-first, capped at 768px and centered, no forced desktop layout · quota is a consumable, no subscription lock-in · a disclaimer + 18+ gate. Clear boundaries from the start = a straight implementation that's easy to maintain


A reading like a mirror

It reflects you back — no fixed verdicts, no selling fear


Engine calculates · AI tells

A strict split of roles so the AI can't make up numbers


Mobile-first ≤768

Centered on screen (letterbox), no forced desktop layout


THB 99 consumable

One top-up, no expiry, no subscription


Level Up · Reflect

Knowledge domains that got stronger

5 areas where my level genuinely moved up through this project

The research section "Saju is not superstition", with research cards from KCI journals
What I learned about the system was turned into Korean research cards (KCI) on the home page
1. Korean astrology / Saju 사주팔자 — from zero to understanding the structure:

I learned the four pillars (연·월·일·시), 오행 (five elements), 십신 (ten gods), 격국 (chart structure), 용신 (useful element), 대운/세운 (10-year and yearly luck), and the astronomy behind them (진태양시, 절기, 입춘 boundaries) — deep enough to turn into a data model and UX. Lesson: real domain depth is what makes a product trustworthy, not just a pretty UI.

2. Full-stack Next.js 15 + Supabase — App Router + RLS + Auth:

Built with the App Router (RSC), Supabase Auth (Google + Email/Password + merge-by-email), RLS on every table, and quota deducted by an atomic Postgres function. Lesson: one Supabase project can own the DB, auth and security surface — fewer moving parts lets a small team ship fast.

3. Polyglot serverless — TypeScript + Python on the same Vercel project:

Connected the Python engine (korean-saju, 0 dependencies) to Next.js through a Vercel Python function + sys.path injection, then cached results in the DB. Lesson: pick the language that fits the job — astronomical math belongs in Python; no need to force a rewrite in TS.

4. AI product engineering — provider abstraction + keeping it from making things up:

Built a provider layer that switches Gemini → OpenAI → template fallback in one file, with streaming, prompt caching, and hallucination control by injecting facts from the engine + a character/system prompt. Lesson: steer AI with "boundaries + facts", never let it do its own math.

5. Payments & quota economics — money is the path that can't fail:

Designed a Stripe consumable + idempotent webhook + append-only quota_ledger + a price snapshot at purchase time (later price changes don't affect past history). Lesson: anything involving money must be atomic, server-only and idempotent — no exceptions.

35,000
Days where the engine matches 100% (vs lunar-python)
8
Postgres tables — RLS on every one
15
Routes in the app (mobile-first)
0
Dependencies of the Saju engine (pure Python)

Tan · Natpakan Sirirat

Product Designer & AI Builder — designing user experiences and building AI tools that actually work.

0%