Retrieval-augmented AI for climate and air quality
Most chatbots answer from memory and hope for the best. This one searches a library of environmental science first, answers only from what it finds, shows you the passages, and adds today’s weather and air quality for where you are.
No card, no tracking. Sign in with email or Google.
0
passages in the library
from 7 documents, 600-character pieces
0
numbers describe each passage
its meaning as a vector
0.0%
right passage ranked first
on our own 33-question test
0
paid services needed
runs on free tiers
How an answer is made
Nothing here is hidden. This is the actual path every question takes, with the real settings the code uses.
Step 1
You ask a question
Your question travels to our API over the same website, carrying your private session cookie. Each account is limited to 12 questions a minute and 150 a day so nobody can drain the shared AI quota.
POST /api/chats/{id}/messages · httpOnly cookie · rate limit 12/min, 150/day per user
Step 2
Words become numbers
The question is turned into a list of 384 numbers that capture its meaning. That is why “how harmful are tiny particles?” can match a passage about PM2.5 even though they share almost no words. This runs on our own server, so your question is not sent to a third party for this step.
all-MiniLM-L6-v2 · fastembed (ONNX runtime) · 384 dimensions
Step 3
Two searches run side by side
A meaning search finds passages whose numbers sit closest to the question’s. A keyword search finds passages containing the exact words, which catches names and figures like “Kigali Amendment” or “45 μg/m³” that meaning search can blur. Each returns its best 20.
pgvector cosine distance on an HNSW index · Postgres full-text search (tsvector + GIN)
Step 4
The results are merged
Both rankings are combined with reciprocal rank fusion: a passage near the top of both lists wins. Keyword matches count half as much, because plain keyword ranking over-rewards common words. The best 5 passages go forward.
score = weight ÷ (60 + rank) · keyword weight 0.5 · top 5 of 62 passages
Step 5
It decides whether it can answer
If even the best passage is not similar enough to your question, the app says so and stops. It never calls the AI to improvise an answer from nothing. That is why asking for a pizza recipe gets a polite refusal instead of an invention.
best cosine similarity < 0.30 → refuse, no model call
Step 6
Live readings are added for the place you mean
If your question names a place (“is the air safe in Lincoln today?”), that place is looked up; otherwise your selected or current location is used. Today’s temperature, wind, humidity and air quality are fetched and attached, clearly labelled as live measurements rather than library facts.
Open-Meteo forecast + air-quality APIs · no key required
Step 7
The model answers plainly, from your sources
The passages, live readings and your question go to Google Gemini, with an air-quality guide and instructions to answer directly first (for example, yes, no or it depends), explain why in plain language, use only what was supplied, say which place the readings are for, and cite file names.
Gemini Flash · Interactions API · nothing stored by Google · up to 2,048 tokens · free tier
Step 8
It streams back, with receipts
Words arrive as they are written. The passages used, with how closely each matched, are saved alongside the answer so your history always shows where it came from.
server-sent events · sources stored as JSON with each message in Postgres
Live data
1
Your browser asks permission
When you open Live conditions, the browser asks if it may use your location. Say no and you can search any city instead.
2
Coordinates become a place name
Our server asks a free reverse-geocoding service what is at those coordinates, sending only the numbers. Nothing is stored; the result is kept in your own browser.
3
Weather and air quality are fetched
Current conditions, the next 24 hours and six pollutants come from Open-Meteo, a free open data service that needs no key. Your browser asks it directly, with our server as a backup.
4
Readings are explained, not just shown
PM2.5 and PM10 are placed on the WHO 2021 guideline bands, and plain-language guidance is shown for air, heat and UV.
Measured, not claimed
33 hand-written questions, each paired with a phrase that must appear in a retrieved passage. We compared meaning-only search with the merged keyword + meaning search used here.
Read it carefully: 33 questions is small (one question is about 3 points), and the keyword weight was chosen on this same set. Treat the gain as encouraging, not proven. Merging the two rankings with equal weight did not beat meaning-only at rank 1, which is why the weight exists.
Right passage ranked #1
In the top 3
In the top 5
Mean reciprocal rank: 0.818 → 0.851
Security and privacy
Passwords are never stored
Only an argon2id hash is saved. Logging in with an unknown email takes the same time and shows the same message as a wrong password.
Sessions JavaScript can’t read
Sign-in uses httpOnly cookies: a 30-minute access token and a 14-day refresh token that is only sent to the refresh endpoint.
Google sign-in checked server-side
Google’s token is verified for signature, audience and expiry, and the email must be verified before an account is created or linked.
Throttled against abuse
Eight wrong passwords a minute locks an account briefly; chat is capped per user so one person can’t use up the AI quota.
Your chats are yours
Every conversation and saved place belongs to one account. Asking for someone else’s returns “not found”, not “forbidden”.
No ads, no trackers
The only things that leave our server: your question and the retrieved passages go to Gemini, and coordinates go to Open-Meteo and a reverse-geocoding service.
Under the hood
- Next.js 16 + TypeScript
- The interface. /api calls are proxied to the backend so login cookies stay first-party.
- FastAPI (Python 3.12)
- The API: auth, retrieval, streaming, rate limits. Typed, tested, and auto-documented.
- PostgreSQL + pgvector
- One database for users, chats and the vector index, so there is one thing to run and back up.
- fastembed (ONNX)
- Turns text into vectors without PyTorch, keeping the server small enough for a free tier.
- Google Gemini
- Writes the final answer from the retrieved passages, streamed word by word.
- Open-Meteo
- Free, key-less weather, air quality and city search.
Honest limits
- 01The library is small: 7 documents, 62 passages. If a topic isn’t in it, the answer will say so rather than guess.
- 02It is not a medical or legal adviser. Health tips on the dashboard are general guidance only.
- 03Air-quality bands follow WHO guideline values and are illustrative, so check your local authority for official AQI.
- 04The search test used 33 questions written by the builder, which is useful but not independent.
- 05On the free hosting tier the first request after a quiet spell can take about a minute.
Create a free account to keep your conversations and follow the places you care about.