A modern, single-page Streamlit app that generates concise astrology readings using Google Gemini. It supports geocoding, optional birth time to the minute, manual time zone override, a shareable deep link, a reading history, and automatic logging to Google Sheets (including IP and User-Agent).
- Personalized astrology reading powered by Google Gemini
- Clean UI with Overview, Reading, Extras, and History tabs
- Optional birth time (minute precision)
- Geocoding for birth place (OpenStreetMap Nominatim)
- Manual time zone override (IANA, e.g., Asia/Kolkata)
- Extras: Sun sign, DOB moon phase (approx), days to next birthday
- Shareable deep link (URL prefilled with inputs)
- History of readings in-session with per-entry download
- Google Sheets logging (one row per submission, fixed schema)
- Lightweight cookies for convenience (name, dob, place, time, tz, focus)
- Client IP and User-Agent capture via JS
.
├─ gemini.py # Streamlit app
├─ requirements.txt # Python dependencies
├─ GOOGLE_SA_PATH.json # (optional) Service Account JSON (do not commit)
└─ README.md # This file
- Python 3.10+ (3.11 recommended)
- A Google API key for Gemini
- A Google Sheet for logging submissions
- A Google Cloud Service Account with Sheets API enabled
- Windows, macOS, or Linux
- Create a virtual environment and install dependencies
python -m venv venv
venv\Scripts\activate # Windows
# source venv/bin/activate # macOS/Linux
pip install -r requirements.txt- Create a .env file next to gemini.py
GOOGLE_API_KEY=your_gemini_api_key
# Google Sheets
GOOGLE_SHEET_ID=your_sheet_id # string between /d/ and /edit in the sheet URL
GOOGLE_SA_PATH=c:/absolute/path/to/service_account.json
# OR paste the whole JSON as one line instead of GOOGLE_SA_PATH:
# GOOGLE_SA_JSON={"type":"service_account",...}
# Optional
COOKIE_PASSWORD=some_long_random_string # for cookie encryption
GOOGLE_SHEET_TAB=submissions # if you want a specific worksheet/tab- Run the app
streamlit run gemini.pyOpen the Local URL in your browser.
- Fill the form
- Full name, date of birth
- Birth time (optional, minute precision)
- Birth place (city, country; geocoded automatically)
- Focus (optional): tell the app what you care about
- Advanced (optional): set a manual time zone when auto-detection isn’t available (Windows build tools are avoided)
- Click "Get Reading"
- Overview tab shows a summary, location/time zone details, and a copyable share link
- Reading tab streams the generated reading; you can download it and it’s saved in History
- Extras tab shows Sun sign, DOB moon phase, and days to next birthday
- History tab lists prior readings for the session
- Logging
- Each submission is written to your Google Sheet as a single row with a fixed header schema
- Lightweight cookies are saved (if the dependency is present)
This app appends one row per submission in a precise, column-wise format. The app writes a header automatically if it’s missing.
Header schema (in order):
[timestamp, name, dob, time, birth_place_input, birth_place_display,
latitude, longitude, timezone, focus, ip, user_agent]
Example row:
2025-08-18 08:22:31, Jane Doe, 1990-04-12, 07:45, Paris, France,
48.8566, 2.3522, Europe/Paris, career growth, 203.0.113.10,
Mozilla/5.0 (Windows NT 10.0; Win64; x64) ...
Setup steps (once):
- Create a Google Cloud project
- Enable the Google Sheets API
- Create a Service Account and download its JSON key
- Share your spreadsheet with the service account email (Editor)
- Put the JSON path or JSON content into .env (GOOGLE_SA_PATH or GOOGLE_SA_JSON)
- Set GOOGLE_SHEET_ID (string between /d/ and /edit in the sheet URL)
- Optionally set GOOGLE_SHEET_TAB to use/create a specific worksheet tab
Tip: If your existing sheet is messy, create a new tab (e.g., submissions), put its name in GOOGLE_SHEET_TAB, and let the app write fresh rows.
- GOOGLE_API_KEY: Gemini API key (required)
- GOOGLE_SHEET_ID: Target Google Sheet ID (required for logging)
- GOOGLE_SA_PATH: Absolute path to service account JSON (required if not using GOOGLE_SA_JSON)
- GOOGLE_SA_JSON: Entire service account JSON as one line (alternative to GOOGLE_SA_PATH)
- COOKIE_PASSWORD: Optional secret for cookie encryption
- GOOGLE_SHEET_TAB: Optional worksheet/tab name (app creates it if missing)
The app supports these query parameters:
- name: string
- dob: YYYY-MM-DD
- place: string (city, country)
- time: HH:MM (24h)
- focus: string
Example:
http://localhost:8501/?name=Jane%20Doe&dob=1990-04-12&place=Paris%2C%20France&time=07:45&focus=career
-
Could not write to Google Sheet
- Share the sheet with the service account email as Editor
- Verify GOOGLE_SHEET_ID and credentials (GOOGLE_SA_PATH or GOOGLE_SA_JSON) in .env
- Ensure Sheets API is enabled in your Google Cloud project
- Optional: set GOOGLE_SHEET_TAB to a clean/new tab
-
IP / User-Agent are blank
- Ensure streamlit-javascript is installed
- Wait a second for the Advanced panel to show values before submitting (the app will auto-rerun once on first capture)
- Check that https://api.ipify.org is reachable (adblockers/VPN may block it)
-
Geocoding fails or is inaccurate
- OSM Nominatim can rate limit or return ambiguous results; try a more specific place string (city, state, country)
-
No reading or an error like “no parts returned”
- The app now falls back to non-streaming mode if streaming yields no text
- Shorten the Focus text, avoid sensitive content, and confirm your GOOGLE_API_KEY and quota
-
Deprecation warning about st.cache
- Comes from the cookies dependency; safe to ignore
- If you want to remove the warning, remove streamlit-cookies-manager and I can replace it with a JS-based cookie helper
-
Time zone detection
- Auto time zone lookup is disabled on Windows (to avoid compiling native deps). Use Advanced -> Manual time zone (IANA), e.g., Asia/Kolkata
- This hobby project logs rows to your Google Sheet automatically on submit
- Captured fields: name, dob, time, birth_place_input, birth_place_display, latitude, longitude, timezone, focus, ip, user_agent, timestamp
- Cookies store non-sensitive values to prefill fields later
- If you publish this app, ensure you comply with local privacy laws and disclose data collection
- Framework: Streamlit
- LLM: Google Gemini (several model fallbacks are tried)
- Geocoding: geopy + Nominatim (OpenStreetMap)
- Time zones: manual IANA entry (ZoneInfo); tzdata included for Windows
- Sheets: gspread + google-auth (service account)
- IP/UA: streamlit-javascript + fetch(navigator.userAgent)
Add your project license here (e.g., MIT). If absent, your repository will be treated as “All rights reserved.”
- OpenStreetMap Nominatim
- Streamlit
- Google Gemini
- gspread and google-auth