DEV Community

EON-LEE
EON-LEE

Posted on

Why Metal is the Strict Type of Eastern Astrology

I was debugging at 2 AM when I realized my LangGraph flow was hallucinating. The AI assistant was telling a user they were "very creative and spontaneous," but their birth chart clearly indicated a dominant Metal element. In the Five Elements philosophy, Metal is the opposite of Water—it's rigid, structured, and decisive, not fluid.

That moment was a wake-up call: simply feeding a prompt with a birth chart isn't enough. You have to architect the logic so the AI understands the nature of the element it's analyzing.

I'm building a side project called SajuBox (sajubox.xyz) that combines ancient Eastern astrology with modern AI. We use Next.js 14 on the frontend, FastAPI for the backend, and LangGraph to orchestrate multi-agent workflows using Claude. Today, I want to share how we handle one of the most distinct elements: Metal.

The Architecture of Destiny (and Code)

First, a quick overview of the stack. We aren't just running a static HTML file. We're processing complex data:

  • Frontend: Next.js 14 (App Router) for a fast, SSR experience.
  • Backend: FastAPI (Python) handling the heavy lifting.
  • Database: Supabase for storing user readings.
  • Orchestration: LangGraph for managing the AI agents (The Astrologer, The Tarot Reader, etc.).
  • Hosting: Vercel + Railway for deployment.

Our goal is to take a user's birth date, calculate their element, and generate a reading that feels authentic to that specific archetype.

Metal: The Strict Type of Personality

In eastern astrology and the five elements theory, Metal represents strength, organization, and decisiveness. Think of it as the strictest type in TypeScript or the most optimized database schema you've ever written. It doesn't bend easily; it cuts through the noise.

When we prompt the LLM, we have to explicitly tell it to embody these traits. If we don't, the model defaults to a generic "friendly assistant" tone, which dilutes the cultural nuance of the reading.

The Prompt Engineering Challenge

How do we ensure the AI knows when to speak with the precision of Metal?

We created a dynamic prompt builder. Instead of a static string, we inject the specific element data into the system prompt at runtime. This ensures that every time a user asks for a reading, the context is fresh.

Here is a snippet of how we construct that prompt in Python:

from langchain.prompts import ChatPromptTemplate

def get_element_prompt(element):
    base_prompt = """
    You are an expert in Saju (Eastern Astrology). 
    Analyze the following birth chart data.

    The user's dominant element is: {element}

    Guidelines for {element}:
    - Tone: Authoritative, concise, and structured.
    - Personality Traits: Decisive, organized, perfectionist, principled, and direct.
    - Advice: Focus on discipline, setting boundaries, and achieving long-term goals.
    - Avoid: Being overly emotional, vague, or overly accommodating.
    """

    if element.lower() == "metal":
        base_prompt += "\nSpecific Persona: The user is a Metal person. They value structure and clarity. Be firm in your advice."

    return ChatPromptTemplate.from_template(base_prompt)
Enter fullscreen mode Exit fullscreen mode

In this code, we're defining a "Persona.” By injecting specific constraints into the prompt, we force the LLM to adopt a specific voice. It’s a classic technique: control the variables, control the output.

Handling Ambiguity in AI Fortune Telling

One of the hardest parts of this project is the trade-off between AI creativity and user expectation. Fortune telling is inherently vague. If the AI is too specific, it looks like a scam. If it's too vague, the user feels like they wasted a credit.

With the Metal element, this is easier. Metal people (and the developers building this for them) appreciate specificity.

  • Water: "The waters of your life are flowing..." (Too vague?)
  • Metal: "Your strength lies in your ability to execute. Your career path requires a rigid schedule. Your weakness is stubbornness." (Much better).

We use a "Chain of Thought" prompting strategy in LangGraph. Before giving the final reading, the AI agent pauses to list out the pros and cons based on the element. This step-by-step reasoning helps the model stay grounded in the logic of the five elements rather than drifting into fantasy.

The Birth Chart as a Data Structure

n
We treat the birth chart as a data structure. In our Supabase table, we store the element, the polarity (Yin/Yang), and the strength (Weak/Strong).

Here is a simplified schema logic we use to filter our readings:

// Type definition for a Saju Element
interface SajuElement {
  name: 'Wood' | 'Fire' | 'Earth' | 'Metal' | 'Water';
  polarity: 'Yin' | 'Yang';
  strength: 'Strong' | 'Weak';
  personalityTraits: string[];
}

const metalTraits: SajuElement = {
  name: 'Metal',
  polarity: 'Yin', // Usually, but depends on the year
  strength: 'Strong',
  personalityTraits: [
    'Decisive', 
    'Organized', 
    'Perfectionist', 
    'Resilient', 
    'Direct'
  ]
};
Enter fullscreen mode Exit fullscreen mode

When the user visits SajuBox and selects "Metal Element Analysis," the frontend passes this object to the API. The backend uses these traits to weight the importance of different keywords in the generated response.

What's Next?

Building this has taught me that AI is an amazing pattern matcher, but it needs a strong framework. You can't just throw data at an LLM and expect a coherent personality profile.

We are currently working on integrating the "Past Life Test," which requires a different agent entirely—one that deals with spiritual concepts rather than just astrological archetypes.

If you want to see the code in action or try a reading for yourself, check out SajuBox. Try asking for a reading and see how the AI adapts its tone based on the element!

TL;DR

  • Five Elements are great for structuring AI prompts.
  • Metal represents structure and decisiveness in eastern astrology.
  • Prompt engineering is about defining the persona and tone of the AI agent.
  • Treating the birth chart as a structured data object helps reduce hallucinations.

Try It Yourself

Want to explore what ancient Eastern wisdom says about your destiny? SajuBox is a free AI-powered birth chart reading tool that combines Four Pillars of Destiny analysis with modern AI.

Get Your Free Reading →

Top comments (0)