fuatyah/mirror-ai-astrology
Mirror AI Astrology Service
This service is the isolated Swiss Ephemeris calculation layer for Mirror AI.
It is intentionally kept outside the mobile app and outside Supabase Edge Functions because Swiss Ephemeris uses native Python/C code. The mobile app calls Supabase Edge Functions; Supabase then calls this service through HTTPS.
License Note
Swiss Ephemeris and pyswisseph are available under AGPL-compatible terms, with a separate Swiss Ephemeris Professional License option from Astrodienst. For public or commercial release, choose the correct license path before shipping.
Do not commit downloaded ephemeris files. Put them under services/astrology/ephe, which is ignored by Git.
Required Ephemeris Files
For the MVP natal chart range, the service needs these files under services/astrology/ephe locally or /app/ephe in production:
sepl_18.se1
semo_18.se1
seas_18.se1By default, the Docker service can auto-download missing files from the public Swiss Ephemeris GitHub mirror:
SWISS_EPHEMERIS_DOWNLOAD_BASE_URL=https://raw.githubusercontent.com/aloistr/swisseph/master/ephe
MIRROR_ASTRO_AUTO_DOWNLOAD_EPHEMERIS=true/health reports whether those files are present:
{
"ok": true,
"service": "mirror-ai-astrology",
"ephemeris": {
"path": "/app/ephe",
"required_files": {
"sepl_18.se1": true,
"semo_18.se1": true,
"seas_18.se1": true
},
"ready": true,
"moshier_fallback_enabled": false
}
}Local Setup
cd services/astrology
python -m venv .venv
.venv\Scripts\activate
python -m pip install -r requirements.txt
python -m uvicorn app.main:app --reload --host 0.0.0.0 --port 8010Health check:
curl http://localhost:8010/healthNatal chart:
curl -X POST http://localhost:8010/natal-chart ^
-H "Content-Type: application/json" ^
-H "Authorization: Bearer your-local-token" ^
-d "{\"birth_date\":\"1998-08-24\",\"birth_time\":\"14:30\",\"latitude\":41.0082,\"longitude\":28.9784,\"timezone\":\"Europe/Istanbul\"}"Environment
SWISS_EPHEMERIS_PATH=./ephe
SWISS_EPHEMERIS_DOWNLOAD_BASE_URL=https://raw.githubusercontent.com/aloistr/swisseph/master/ephe
MIRROR_ASTRO_AUTO_DOWNLOAD_EPHEMERIS=true
MIRROR_ASTRO_FALLBACK_TO_MOSHIER=false
MIRROR_ASTROLOGY_SERVICE_TOKEN=For a strict real-device test, keep MIRROR_ASTRO_FALLBACK_TO_MOSHIER=false. With auto-download enabled, the first chart request will populate the missing files and /health should then return "ready": true.
Docker
cd services/astrology
docker build -t mirror-ai-astrology .
docker run --rm -p 8010:8010 ^
-e MIRROR_ASTROLOGY_SERVICE_TOKEN=your-token ^
-e SWISS_EPHEMERIS_PATH=/app/ephe ^
-v "%cd%/ephe:/app/ephe:ro" ^
mirror-ai-astrologyPublic HTTPS Deploy
Recommended flow for the first real test:
- Deploy this folder as a Docker web service on Render, Railway, Fly.io, Cloud Run, or a VPS.
- Mount or copy the ephemeris files into
/app/ephe. - Set:
SWISS_EPHEMERIS_PATH=/app/ephe
MIRROR_ASTRO_FALLBACK_TO_MOSHIER=false
MIRROR_ASTROLOGY_SERVICE_TOKEN=<strong random token>- Confirm:
curl https://your-astrology-service.example.com/health- In Supabase Edge Function Secrets set:
ASTROLOGY_SERVICE_URL=https://your-astrology-service.example.com
ASTROLOGY_SERVICE_TOKEN=<same token>- Redeploy
calculate-natal-chartif needed, then test from the mobile app.
The root render.yaml is included as a Render Blueprint starter. For strict Swiss mode on Render, you still need a way to provide /app/ephe files; do not commit them to the public repository unless your license decision allows that.
