Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .env.production
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
VITE_API_BASE_URL=https://astro-engine-api-7ec0.onrender.com
42 changes: 29 additions & 13 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,9 @@ name: Deploy to GitHub Pages

on:
push:
branches: [main]
workflow_dispatch: {}
branches:
- DSK369-patch-1.5
workflow_dispatch:

permissions:
contents: read
Expand All @@ -17,25 +18,40 @@ concurrency:
jobs:
build:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
- name: Checkout
uses: actions/checkout@v6

- name: Setup Node
uses: actions/setup-node@v6
with:
node-version: 20
node-version: 22
cache: npm
- run: npm ci
- run: npm run build
- uses: actions/configure-pages@v5
- uses: actions/upload-pages-artifact@v3

- name: Install dependencies
run: npm install

- name: Build
run: npm run build

- name: Setup Pages
uses: actions/configure-pages@v5

- name: Upload artifact
uses: actions/upload-pages-artifact@v4
with:
path: dist
path: ./dist

deploy:
needs: build
runs-on: ubuntu-latest
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}

runs-on: ubuntu-latest
needs: build

steps:
- id: deployment
- name: Deploy
id: deployment
uses: actions/deploy-pages@v4
4 changes: 4 additions & 0 deletions backend/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
__pycache__/
*.pyc
venv/
.env
54 changes: 54 additions & 0 deletions backend/core/astro.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
RASHIS = [
"Aries", "Taurus", "Gemini", "Cancer",
"Leo", "Virgo", "Libra", "Scorpio",
"Sagittarius", "Capricorn", "Aquarius", "Pisces"
]

RASHI_LORDS = {
"Aries": "Mars",
"Taurus": "Venus",
"Gemini": "Mercury",
"Cancer": "Moon",
"Leo": "Sun",
"Virgo": "Mercury",
"Libra": "Venus",
"Scorpio": "Mars",
"Sagittarius": "Jupiter",
"Capricorn": "Saturn",
"Aquarius": "Saturn",
"Pisces": "Jupiter"
}

NAKSHATRAS = [
"Ashwini", "Bharani", "Krittika", "Rohini",
"Mrigashira", "Ardra", "Punarvasu", "Pushya",
"Ashlesha", "Magha", "Purva Phalguni", "Uttara Phalguni",
"Hasta", "Chitra", "Swati", "Vishakha",
"Anuradha", "Jyeshtha", "Mula", "Purva Ashadha",
"Uttara Ashadha", "Shravana", "Dhanishta", "Shatabhisha",
"Purva Bhadrapada", "Uttara Bhadrapada", "Revati"
]

NAKSHATRA_LORDS = [
"Ketu", "Venus", "Sun", "Moon", "Mars", "Rahu",
"Jupiter", "Saturn", "Mercury"
] * 3


def get_rashi(longitude):
index = int(longitude // 30)
rashi = RASHIS[index]
return rashi, RASHI_LORDS[rashi]


def get_nakshatra(longitude):
nak_index = int(longitude // (360 / 27))
nakshatra = NAKSHATRAS[nak_index]
lord = NAKSHATRA_LORDS[nak_index]
return nakshatra, lord


def get_charan(longitude):
nak_fraction = (longitude % (360 / 27)) / (360 / 27)
charan = int(nak_fraction * 4) + 1
return charan
76 changes: 76 additions & 0 deletions backend/core/ayanamsa.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
import swisseph as swe

# ==============================
# PREDEFINED CUSTOM
# ==============================
CUSTOM_KP_AYANAMSA = 23 + 44/60 + 18/3600 # 23:44:18


# ==============================
# STANDARD MODES
# ==============================
AYANAMSA_MAP = {
"KP": swe.SIDM_KRISHNAMURTI,
"LAHIRI": swe.SIDM_LAHIRI,
"RAMAN": swe.SIDM_RAMAN,
"FAGAN": swe.SIDM_FAGAN_BRADLEY,
}


# ==============================
# HELPERS
# ==============================
def dms_to_decimal(deg, minute, second):
return deg + (minute / 60) + (second / 3600)


# ==============================
# MAIN SETTER
# ==============================
def set_ayanamsa(mode="KP", manual_value=None):
mode = mode.upper()

# --------------------------
# PREDEFINED CUSTOM KP
# --------------------------
if mode == "CUSTOM_KP":
swe.set_sid_mode(swe.SIDM_USER, CUSTOM_KP_AYANAMSA)

return {
"name": "Custom KP (23:44:18)",
"value_func": lambda jd: CUSTOM_KP_AYANAMSA
}

# --------------------------
# MANUAL INPUT
# --------------------------
if mode == "CUSTOM_MANUAL":
if manual_value is None:
raise ValueError("Manual ayanamsa value required")

swe.set_sid_mode(swe.SIDM_USER, manual_value)

return {
"name": f"Custom Manual ({manual_value:.6f}°)",
"value_func": lambda jd: manual_value
}

# --------------------------
# STANDARD SWE MODES
# --------------------------
if mode not in AYANAMSA_MAP:
raise ValueError(f"Unsupported ayanamsa: {mode}")

swe.set_sid_mode(AYANAMSA_MAP[mode])

return {
"name": mode,
"value_func": swe.get_ayanamsa
}


# ==============================
# OPTIONAL: LIST MODES
# ==============================
def list_ayanamsa_modes():
return list(AYANAMSA_MAP.keys()) + ["CUSTOM_KP", "CUSTOM_MANUAL"]
54 changes: 54 additions & 0 deletions backend/core/cusps.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
import swisseph as swe
from core.astro import get_rashi, get_nakshatra, get_charan
from core.utils import decimal_to_dms
from core.kp import compute_kp_levels

# SAME OFFSET as houses.py / planets.py, kept consistent so cusps line up
# with planet/lagna longitudes computed elsewhere in core/.
AYAN_OFFSET = -0.1


def calculate_placidus_cusps(jd, latitude, longitude):
houses, _ascmc = swe.houses(jd, latitude, longitude, b'P')
ayanamsa = swe.get_ayanamsa(jd)

cusps = []
for i in range(12):
tropical = houses[i]
sidereal = (tropical - ayanamsa + AYAN_OFFSET) % 360

rashi, rashi_lord = get_rashi(sidereal)
nakshatra, nak_lord = get_nakshatra(sidereal)
charan = get_charan(sidereal)
sub, sub_sub, sub_sub_sub = compute_kp_levels(sidereal, nak_lord)

cusps.append({
"house": i + 1,
"longitude": sidereal,
"degree": decimal_to_dms(sidereal),

"rashi": rashi,
"rashi_lord": rashi_lord,
"nakshatra": nakshatra,
"nakshatra_lord": nak_lord,
"charan": charan,

"sub_lord": sub,
"sub_sub_lord": sub_sub,
"sub_sub_sub_lord": sub_sub_sub,
})

return cusps


def get_placidus_house(longitude, cusp_longitudes):
"""Which Placidus house a longitude falls in, given the 12 cusp start
longitudes. Matches lib/vedicTables.js: getPlacidusHouse exactly."""
for i in range(12):
start = cusp_longitudes[i]
end = cusp_longitudes[(i + 1) % 12]
span = (end - start) % 360
offset = (longitude - start) % 360
if offset < span:
return i + 1
return None
Loading
Loading