AI-Driven Astrology and Tarot App Development by Vipin VaratharajanAI-Driven Astrology and Tarot App Development by Vipin Varatharajan

AI-Driven Astrology and Tarot App Development

Vipin Varatharajan

Vipin Varatharajan

Project Overview:

Creating an AI-driven astrology and tarot platform presents unique technical challenges: preventing LLM hallucinations on strict astronomical data, managing highly complex Vedic astrology planetary position calculations, ensuring secure handling of in-app purchases, and providing hyper-personalized, localized content globally. I engineered the backend for Fastrology, a comprehensive Firebase and Node.js-based application that seamlessly blends deterministic astronomical math with the reasoning capabilities of Google's Gemini AI to deliver real-time, accurate readings.

The Solution:

I built a robust serverless architecture using Firebase Cloud Functions (v2), Firestore, and Express. The system integrates advanced AI with exact planetary algorithms provided as AI context. To ensure AI accuracy, I engineered a sophisticated "tool-calling" agent architecture where the LLM is forced to query the backend for exact planetary transits & aspects before making predictions. Additionally, I built an automated global pricing engine that adjusts in-app purchase costs based on World Bank Purchasing Power Parity (PPP) data to ensure that the in-app purchases prices are comparable to cost of living for each country to increase conversion rates.
The App's Tarot Card Feature

Key Features

Agentic AI Astrology Engine: A chat system powered by Gemini AI that utilizes strict tool-calling. Instead of guessing, the AI requests real-time planetary transits/positions and aspect calculations directly from the backend before answering.
Automated Daily & Monthly Horoscopes: Scheduled serverless cron jobs that generate customized horoscopes every night, taking into account the exact real-time planetary transits for each Zodiac sign.
Automated Dynamic Tarot Piles: A scheduled job utilizing Google's Imagen 4 model to dynamically generate beautiful, text-free gemstone-themed tarot card backs, and hosted on Firebase Storage.
Birth Time Rectification (BTR) Engine: A complex algorithm that generates chart snapshots at certain time intervals across a user's uncertain birth time window, correlating astrological Dasha/Antardasha shifts with the user's major life events to estimate the likely birth time based on astrologic principles.
Automated PPP Pricing Synchronization: A custom Node.js script that fetches live World Bank PPP metrics and automatically adjusts Google Play store prices across 100+ regions with proper rounding rules.
Traditional Indian Star-Based Horoscope Matching Feature Infused with LLM-powered Detailed Explanation of Scores
Traditional Indian Star-Based Horoscope Matching Feature Infused with LLM-powered Detailed Explanation of Scores

Key Challenges

Challenge 1: Grounding AI to Prevent Astrological Hallucinations

The Issue: Large Language Models are notoriously bad at spatial and mathematical reasoning. If an LLM is asked to predict marriage timing, it will often hallucinate planetary positions, aspects, or claim a planet is in a sign it actually isn't, destroying the credibility of the app.
The Solution: I implemented a strict agentic execution loop with Function Declarations (Tool Calling). I provided the LLM with custom tools to make specific astrological calculations using Swiss Ephemeris library which is then used by AI to compute its final response. Through rigid system instructions, the AI is forbidden from guessing planetary positions. It must silently call these backend tools to calculate the precise math, inject the factual astronomical data back into its context window, and only then generate its final natural-language reading.

Challenge 2: Securing In-App Purchases Against Race Conditions

The Issue: Handling virtual currencies (Credits) for AI chats requires bulletproof transaction logic. If a user's network stutters, they might retry a purchase, leading to double-crediting. Furthermore, fake receipts could be submitted to steal credits.
The Solution: I engineered a highly secure webhook and fulfillment pipeline using Firestore's transaction API. When a user submits a Google Play purchase token, the backend first validates the token against the official Play Developer API Client. If valid, it enters an atomic transaction lock that verifies the token hasn't been processed yet, increments the user's credit balance, and writes the token to the DB collection simultaneously to ensure idempotency.

Challenge 3: Scaling Global Pricing with Psychological Rounding

The Issue: Manually managing localized pricing for subscriptions and credit packs across 100+ countries is impossible to maintain. Furthermore, strict mathematical conversion often results in ugly, unnatural prices (e.g., converting $5 USD to VND might yield 127,341 VND, which looks illegitimate).
The Solution: I developed an automated script that fetches the latest Purchasing Power Parity (PPP) indices from the World Bank API. It maps ISO3 country codes to Google Play regions, calculates the fair local price, and applies a custom rounding algorithm. This algorithm is magnitude-aware: it rounds large currencies like IDR or VND to the nearest hundred/thousand, enforces "ending in 9" logic specifically for INR, and uses standard .49/.99 rounding for Western currencies, automatically pushing these beautiful, localized prices via the Google Play Developer API.

Challenge 4: Solving Birth Time Uncertainty (BTR) Computationally

The Issue: Vedic astrology requires precise birth times to calculate the Ascendant (Lagna) and planetary periods (Dashas). Many users only know their birth time within a rough window (e.g., ±2 hours).
The Solution: I engineered a computational Birth Time Rectification endpoint. The backend takes the user's base time, uncertainty window, and 3 major life events. It loops through the time window in shorter time intervals, calculating the exact zodiac sign of Ascendant and active dashas (astrological calculation) for the dates of those specific life events at every step. This dense matrix of astrological shifts is fed into the AI, which analyzes the permutations to deduce the most mathematically and astrologically sound exact birth time estimate for the user.

Conversational AI Chat Feature With Astrological Response
Conversational AI Chat Feature With Astrological Response

Results & Impact

Zero-Maintenance Content Pipeline: Daily horoscopes, monthly forecasts, and dynamic tarot imagery are entirely hands-off, saving hundreds of hours of manual writing and design work.
Enterprise-Grade AI Accuracy: By chaining LLMs with deterministic mathematical functions, the app provides highly accurate, hallucination-free astrological insights that rival human astrologers.
Maximized Global Revenue: The automated PPP pricing script ensures the app remains affordable in developing nations while maximizing revenue in high-income regions, completely removing the friction of manual Google Play Console updates.
Bulletproof Economy: The atomic transaction architecture resulted in zero duplicated credits or dropped purchases, ensuring a trustworthy premium economy.
Like this project

Posted Jun 18, 2026

Engineered Fastrology's serverless backend. Prevented AI hallucinations via Gemini tool-calling, secured IAP economies, and automated global PPP pricing.