DEV Community

Abhinav Nayak
Abhinav Nayak

Posted on

SafeAir Walk: Find Your Clean-Air Window to Step Outside Today

Hacktoberfest Open-Source AI Challenge Week 1: Touch Grass Submission 🌿


This is a submission for the Hacktoberfest Open-Source AI Challenge Week 1: Touch Grass

What I Built

SafeAir Walk tells you the single best 1-hour window to step outside today β€” based on real air quality forecasts and heat β€” tailored to your health profile. Then a local open-source AI explains why in plain language, in your language of choice.

Air pollution and heat are invisible threats that people routinely ignore because the data is buried in dense charts. SafeAir Walk turns hourly AQI + apparent temperature forecasts into one clear, colour-coded verdict:

  • βœ… Go for it β€” conditions are safe, head out now
  • 🟑 Short walk only β€” keep it to 20–30 minutes
  • β›” Skip today β€” air or heat is too high, try tomorrow

It is built for four health profiles: General, Child πŸ‘Ά, Elder πŸ‘΄, and Asthma / Respiratory πŸ’¨ β€” each with tighter safety thresholds where it matters. The app uses your GPS or lets you search any city, then streams a warm, practical 2-sentence AI explanation β€” not a wall of warnings, just what to do and why.

The whole idea is to get people off the screen and safely into the world. When conditions are good, SafeAir Walk simply says "Go for it" and gives you a time. When they're bad, it suggests an indoor alternative and shows when tomorrow looks better.

No sign-ups. No API keys. No ads. Just open data and a fast, private Ollama LLM.


Demo

🌐 Live app: https://safeair-walk.onrender.com/

Search your city (or tap "Use my location") and you'll see:

  • The best hour to walk today
  • AQI, PM2.5, and feels-like temperature for that window
  • A streaming AI explanation personalised to your health profile powered by Ollama
  • An hourly dot-strip showing how the whole day looks at a glance

Code

SafeAir Walk

Find your clean-air window to go outside. Checks AQI and heat for your area and picks the best 30–60 min window today.

Stack: React + Vite + Open-Meteo (no API key) + Ollama (local AI, optional)


Run locally

pnpm install
pnpm dev
Enter fullscreen mode Exit fullscreen mode

Open http://localhost:5173

Enable AI explanations (optional)

# Windows PowerShell
$env:OLLAMA_ORIGINS="*"; ollama serve
Enter fullscreen mode Exit fullscreen mode

The app auto-detects Ollama and uses it. Falls back to templates if offline.


Deploy (Free)

Two services:

  1. HuggingFace Space β†’ runs Ollama API (free Docker Space)
  2. Render Static Site β†’ hosts the React app (free)

Step 1 β€” Deploy Ollama to HuggingFace Spaces

  1. Go to https://huggingface.co/new-space
  2. Set:
    • Space name: safeair-ollama
    • SDK: Docker
    • Visibility: Public
  3. Upload the three files from the hf-space/ folder:
    • Dockerfile
    • hf_start.sh
    • README.md
  4. Wait ~5 min for the build + model download to finish
  5. Your Ollama URL will be:
    https://YOUR-HF-USERNAME-safeair-ollama.hf.space
    
    Test it: curl https://YOUR-HF-USERNAME-safeair-ollama.hf.space/api/tags

Step

…

How I Built It

Open-source AI: Ollama + Qwen 2.5 (Local Inference)

The AI layer runs entirely on Ollama with open-weight models β€” no external proprietary APIs, no OpenAI, no Anthropic.

  • Model: qwen2.5:1.5b / qwen2.5:7b β€” ultra-fast open-weight models capable of running seamlessly on consumer hardware.
  • Inference runtime: Ollama β€” models are served directly via ollama serve, exposing a streaming /api/generate and /api/tags endpoint with CORS enabled (OLLAMA_ORIGINS=*).
  • Streaming integration: The React frontend connects directly to Ollama's HTTP API, consuming NDJSON chunks via ReadableStream and TextDecoder to render tokens with a real-time typing effect.

The Scoring Engine & Deterministic Thresholds

To guarantee safety and scientific consistency, SafeAir Walk does not rely on LLM guesswork for health boundaries. All safety decisions are evaluated deterministically in src/safeair-core.js β†’ PROFILES before any prompt is generated:

Profile GO SHORT SKIP
General AQI ≀ 100, Feels like ≀ 32Β°C AQI ≀ 150, Feels like ≀ 36Β°C Above thresholds
Child AQI ≀ 75, Feels like ≀ 30Β°C AQI ≀ 100, Feels like ≀ 34Β°C Above thresholds
Elder AQI ≀ 75, Feels like ≀ 30Β°C AQI ≀ 100, Feels like ≀ 34Β°C Above thresholds
Asthma AQI ≀ 50, Feels like ≀ 32Β°C AQI ≀ 100, Feels like ≀ 36Β°C Above thresholds
  1. Fetch β€” two parallel requests to Open-Meteo (free, no API key): air quality API for US AQI + PM2.5, and weather API for apparent temperature across 48 forecast hours.
  2. Rate β€” each hour is evaluated against the selected profile's limits. If temperature is unsafe even when AQI is low (or vice versa), the app strictly selects the safer, conservative rating.
  3. Pick β€” the algorithm evaluates today's daytime hours (5 AM–8 PM), selects the optimal window, and alerts the user if conditions deteriorate soon after.
  4. AI Role β€” Ollama receives these structured verdicts to craft warm, supportive, plain-language advice without hallucinating risk limits.
  5. Fallback β€” if Ollama is offline or unavailable, deterministic templates instantly respond with zero downtime.

Frontend & Deployment

  • React 19 + Vite β€” fast single-page app.
  • Vanilla CSS β€” dark glassmorphism theme with accessible contrast and micro-animations.
  • Render β€” static web app hosting with automated build pipelines (pnpm install && pnpm build).
Layer Technology Cost
AI Engine Ollama (qwen2.5) Free & Open Source
Web App Hosting Render Static Site Free
Weather & AQI Open-Meteo API Free, no key required
Geocoding Open-Meteo Geocoding API Free, no key required

Why Does Open Innovation Matter?

With a closed API, I would have had to pay per token, accept rate limits, and transmit every user's health profile and location data to an external provider's servers.

Open innovation with Ollama made three critical things possible:

  1. Privacy by architecture. Ollama runs locally and independently. User queries, locations, and personal health profiles never leave the user's control. There are no tracking scripts, user accounts, or cloud telemetry pipelines.
  2. Zero subscription / API fees. Because Ollama runs open-weight models, developers and users are completely free from monthly subscription tiers, credit card requirements, or surprise billing spikes. Anyone can clone the repo and run the entire AI stack for free.
  3. Complete prompt & latency ownership. With Ollama, we have full control over sampling parameters (temperature, num_predict), token streaming, and response structure. There are no unexpected model deprecations, forced safety overrides, or arbitrary rate limit throttling.

Open innovation turned what would normally be an expensive, privacy-invasive cloud service into a fast, private, community-owned tool that gets people safely outdoors.


Prize Categories

  • Ollama β€” Open-weight model inference (qwen2.5) with streaming API served entirely via Ollama
  • Render β€” React frontend deployed as a Render Static Site

Top comments (0)