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
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.
- 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_dataand@st.cache_resource, typed helpers, graceful errors, MongoDB indexes, and input validation. - Clean architecture:
services/for APIs & DB,components/for share-card, single entrypointapp.py.
- πΌοΈ 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.
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
- 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).
-
Create & activate a virtual environment:
python -m venv .venv # Windows: .venv\Scripts\activate # macOS/Linux: source .venv/bin/activate -
Install dependencies:
pip install -r requirements.txt
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).
Run locally:
streamlit run app.py
Workflow:
- Use the sidebar Pages to switch: APOD, Space Search Gallery, Earth Events, NEOs This Week.
- In APOD, pick a date or random β preview β export a share card β β to save in favorites.
- In Gallery, search e.g., βAuroraβ β open original β (optional) save as favorite.
- In Earth Events, filter and explore on the map; open event detail links.
- In NEOs, search by single date or a β€7-day range; sort table; open βMore infoβ.
-
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;
/searchand/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
Nativesecrets.tomlkeeps keys out of your repo locally, and Streamlit Cloud provides a secure Secrets UI on deploy. -
Caching strategy
@st.cache_datafor pure fetch/transform;@st.cache_resourcefor the MongoDB client. This keeps UI snappy while avoiding redundant connections. -
Share card design
Pillow+qrcodeto render a social-ready PNG (1200Γ630) with title/date/caption overlay and a QR deep link.
- 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.
- 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.
This project is licensed under the MIT License. See the LICENSE file for details.
For questions or feedback:
- LinkedIn: https://www.linkedin.com/in/brejesh-balakrishnan-7855051b9/
- GitHub: https://github.com/brej-29
- NASA API Portal (APIs & key registration): https://api.nasa.gov/
- NASA Image & Video Library API (search & asset): example collection docs / Postman overview.
- EONET v3 (events, categories): https://eonet.gsfc.nasa.gov/docs/v3 and live categories endpoint.
- Asteroids NeoWs (feed, lookup, browse): dataset/API description. https://data.nasa.gov/dataset/asteroids-neows-api
- Streamlit secrets (secrets.toml & Cloud secrets): docs pages.