Skip to content

Streamlit app to explore NASA data: APOD with share cards & MongoDB favorites, NASA Image & Video Library search gallery, live Earth events map (EONET), and Near-Earth Objects digest with date search. Dark/light toggle, caching, deep links, downloads. Built to showcase modern Streamlit UI/UX for recruiters.

License

Notifications You must be signed in to change notification settings

brej-29/streamlit-space-explorer

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

9 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

πŸ›°οΈ Streamlit Space Explorer

Explore NASA data in one elegant app: APOD with share cards & favorites, a NASA Images search gallery, a live Earth events map (EONET), and a Near-Earth Objects mini-terminal β€” built with Streamlit



Built with the tools and technologies:

Python | Streamlit | Pandas | PyDeck | Requests | Pillow | qrcode | PyMongo

Screenshot

image image image image

Table of Contents


Overview

Streamlit Space Explorer is a recruiter-friendly Streamlit app showcasing practical API integration, caching, and persistence:

  • APOD (Astronomy Picture of the Day): browse by date, random picks; export branded share cards; save favorites to MongoDB.
  • Space Search Gallery (NASA Images & Video Library): search 140k+ public assets (no key); open full-resolution originals.
  • Earth Events (EONET v3): live natural events (wildfires, storms, volcanoes, sea/ice) with a map and filters.
  • NEOs This Week (NeoWs): digest of near-Earth objects with date search, sizes, miss distance (km/LD), and speed.

Secrets are stored via Streamlit secrets.toml locally and through Streamlit Community Cloud on deploy.


Project Highlights

  • Polished UX: sidebar page switcher, tabs, expander help, toasts, dark/light toggle, deep links via query params, and PNG share-card export.
  • Robust engineering: @st.cache_data and @st.cache_resource, typed helpers, graceful errors, MongoDB indexes, and input validation.
  • Clean architecture: services/ for APIs & DB, components/ for share-card, single entrypoint app.py.

Features

  • πŸ–ΌοΈ APOD: daily image/video, description, copyright; share-card export (QR + overlay); MongoDB favorites.
  • πŸ”Ž NASA Images Gallery: query by keyword; preview grid; open originals; optional favorite save.
  • 🌍 EONET (v3): filter by category, status (open/closed), and look-back window; map and list with links to details.
  • πŸͺ¨ NeoWs: choose a single date or ≀7-day range; table with Potentially Hazardous?, diameter min/max (m), closest time, miss distance (km/LD), relative speed (km/s), and More info link; inline glossary.
  • πŸŒ“ Theme toggle: runtime dark/light switch (demo-friendly).
  • πŸ’Ύ Persistence: favorites stored in MongoDB Atlas with unique index (user_id, apod_date).
  • πŸš€ Performance: strategic caching and pagination; requests tuned with timeouts; minimal reruns.

Getting Started

Project Structure

streamlit-space-explorer/
β”œβ”€ app.py
β”œβ”€ components/
β”‚  └─ share_card.py
β”œβ”€ services/
β”‚  β”œβ”€ apod.py
β”‚  β”œβ”€ db.py
β”œβ”€ .streamlit/
β”‚  β”œβ”€ config.toml
β”‚  └─ secrets.toml          # local only; do NOT commit
β”œβ”€ requirements.txt
└─ README.md

Prerequisites

  • Python 3.9+
  • NASA API key (free) for APOD/NeoWs/EONET if rate limits apply β€” generate at api.nasa.gov.
  • MongoDB Atlas free cluster (optional; used for favorites).

Installation

  1. Create & activate a virtual environment:

     python -m venv .venv
     # Windows:
     .venv\Scripts\activate
     # macOS/Linux:
     source .venv/bin/activate
    
  2. Install dependencies:

     pip install -r requirements.txt
    

Configuration

Create .streamlit/secrets.toml (local) and paste your keys (example):

    [api]
    nasa_apod_key = "YOUR_NASA_KEY"

    [mongo]
    uri        = "mongodb+srv://apod_app:YOUR_PASSWORD@cluster0.xxxxx.mongodb.net"
    db_name    = "space_gallery"
    collection = "favorites"
  • Access in code with st.secrets["section"]["key"] or attribute style (st.secrets.api.nasa_apod_key).
  • On Streamlit Community Cloud, paste the same TOML content in your app’s Secrets (do not commit the file).

Usage

Run locally:

    streamlit run app.py

Workflow:

  1. Use the sidebar Pages to switch: APOD, Space Search Gallery, Earth Events, NEOs This Week.
  2. In APOD, pick a date or random β†’ preview β†’ export a share card β†’ ⭐ to save in favorites.
  3. In Gallery, search e.g., β€œAurora” β†’ open original β†’ (optional) save as favorite.
  4. In Earth Events, filter and explore on the map; open event detail links.
  5. In NEOs, search by single date or a ≀7-day range; sort table; open β€œMore info”.

Design Notes

  • APIs chosen for broad appeal & low friction

    • APOD: iconic daily image/video, small JSON schema; great for demos.
    • NASA Images & Video Library: no key required; /search and /asset/{nasa_id} cover most gallery needs.
    • EONET v3: human-readable categories & events; works well with maps.
    • NeoWs: approachable feed with dates and close-approach details (≀7-day windows).
  • Secrets & deployment
    Native secrets.toml keeps keys out of your repo locally, and Streamlit Cloud provides a secure Secrets UI on deploy.

  • Caching strategy
    @st.cache_data for pure fetch/transform; @st.cache_resource for the MongoDB client. This keeps UI snappy while avoiding redundant connections.

  • Share card design
    Pillow + qrcode to render a social-ready PNG (1200Γ—630) with title/date/caption overlay and a QR deep link.


Limitations

  • Rate limits: free NASA keys (and DEMO_KEY) may throttle; APOD/NeoWs/EONET calls include timeouts and user-facing errors. :contentReference[oaicite:13]{index=13}
  • Data availability: some dates have videos (APOD) or no imagery (gallery queries) β†’ UI handles fallbacks gracefully.
  • Local QR links: on localhost, QR deep links are rewritten to LAN IP for phone testing; in Cloud they use the public URL.

Roadmap

  • Gallery favorites with tags/notes (Mongo).
  • EONET cluster markers & time slider.
  • NEOs: hazard filters, color-coded LD risk bands, mini charts.
  • Optional EPIC β€œBlue Marble Today” page.

License

This project is licensed under the MIT License. See the LICENSE file for details.


Contact

For questions or feedback:


References

About

Streamlit app to explore NASA data: APOD with share cards & MongoDB favorites, NASA Image & Video Library search gallery, live Earth events map (EONET), and Near-Earth Objects digest with date search. Dark/light toggle, caching, deep links, downloads. Built to showcase modern Streamlit UI/UX for recruiters.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages