When building AstroTales, our primary architectural challenge was delivering astronomical and astrological insights (such as Sun, Moon, and Rising sign calculations) in real time without bogging down our backend servers or causing laggy API latency.
Rather than running heavy serverless functions for every calculation, we engineered a standalone, client-side astronomical engine: astrotales-core.
Here is the engineering breakdown of how to calculate high-precision Julian Days, Sidereal vs. Tropical planetary degrees, and Ascendant horizons in pure JavaScript.
1. The Astronomical Foundation: Julian Day Number (JDN)
To calculate where planets are positioned in the sky, standard calendar dates (Gregorian) are notoriously inconvenient due to leap years, month lengths, and timezones. Astronomers use the Julian Day (JD)—a continuous count of days since January 1, 4713 BC.
Here is our clean mathematical implementation:
function getJulianDay(year, month, day, hour = 0, minute = 0) { let y = year; let m = month; if (m <= 2) { y -= 1; m += 12; } const a = Math.floor(y / 100); const b = 2 - a + Math.floor(a / 4); const dayFraction = day + (hour + minute / 60) / 24; return Math.floor(365.25 * (y + 4716)) + Math.floor(30.6001 * (m + 1)) + dayFraction + b - 1524.5; } 2. Solving Tropical vs. Vedic (Sidereal) Zodiacs
The critical difference between Western astrology and classical Vedic (Jyotish) astrology is the Precession of the Equinoxes:
- Western (Tropical): Tied to the seasons (0° Aries begins at the vernal equinox).
- Vedic (Sidereal): Tied to the fixed stars and constellation backdrop.
The angular difference between these two systems is known as Ayanamsa. In modern Vedic calculation, the Chitra Paksha / Lahiri Ayanamsa is the gold standard (approx 23°51' at epoch J2000, drifting at ~50.29 arcseconds per year).
const AYANAMSA_J2000 = 23.85; function getSunPosition(jd) { const n = jd - 2451545.0; // Days since J2000.0 const l = (280.460 + 0.9856474 * n) % 360; const g = ((357.528 + 0.9856003 * n) * Math.PI) / 180; // Ecliptic tropical longitude const lambda = (l + 1.915 * Math.sin(g) + 0.020 * Math.sin(2 * g)) % 360; // Apply Lahiri precession rate const ayanamsa = AYANAMSA_J2000 + (n / 365.25) * (50.29 / 3600); const sidereal = (lambda - ayanamsa + 360) % 360; return { tropical: lambda, sidereal }; } 3. Calculating the Ascendant (Rising Sign)
While Sun and Moon signs depend on date and time, the Ascendant (Lagna) changes every ~2 hours and requires exact geographic coordinates:
- Convert Julian Day to Greenwich Mean Sidereal Time (GMST).
- Add geographic longitude to get Local Sidereal Time (RAMC).
- Solve the spherical trigonometry equation for the eastern horizon against the obliquity of the ecliptic.
function getAscendant(jd, latitude, longitude) { const t = (jd - 2451545.0) / 36525.0; let gmst = (280.46061837 + 360.98564736629 * (jd - 2451545.0)) % 360; const ramc = (gmst + longitude + 360) % 360; const eps = (23.4392911 - t * (46.8150 / 3600.0)) * (Math.PI / 180); const latRad = (latitude * Math.PI) / 180; const ramcRad = (ramc * Math.PI) / 180; const y = -Math.cos(ramcRad); const x = Math.sin(ramcRad) * Math.cos(eps) + Math.tan(latRad) * Math.sin(eps); return (Math.atan2(y, x) * 180 / Math.PI + 90 + 360) % 360; } Live Interactive Demos
We deployed this engine across our web applications to give users real-time astronomical charts with zero server lag:
- 🌟 Live Tool: Try the Big Three Astrology Calculator on AstroTales.
- 📦 NPM Module: Install the library directly via
npm install astrotales-coreor view on npm. - 📱 Mobile App: Download the AstroTales Android App on Google Play.
- 🌐 Full Platform: Explore our full astrology suite at AstroTales.co.in.

