Other
•
Nov 14, 2025
Build a Cross Platform Air Quality and Carbon Tracking App
Hey there!
This guide shows how to build a cross platform mobile and web app that displays real time air quality, lets users save locations, track trips, estimate carbon savings and connect with friends. It is technical, but simple enough to follow step by step.



You will build:
Real time AQI display
Multi location management
Carbon tracking with trip logging
Friends and a private leaderboard
Weekly CO2 trends
JWT login on all platforms
Dark glass morphism UI theme
Let’s get into it.
System Overview
Frontend: Expo (React Native) for iOS, Android and Web
Backend: FastAPI with MongoDB
APIs: OpenAQ v3 for air quality, Nominatim for geocoding, RapidAPI for carbon estimates
Auth: JWT email login, test user mode, optional session id login
Flow:
User logs in
App fetches current and saved locations
Backend fetches station data and returns AQI
User logs trips and sees CO2 stats
Friends and leaderboard update automatically
Core Features
Home
AQI cards
Switch between current and saved locations
Autocomplete search using Nominatim
Edit and delete locations
Smart fallback that picks the first valid PM2.5 value
Modal with full pollutant details
Profile
Total CO2 saved
Weekly CO2 trend chart
Friend code display
Logout modal
Friends
Add friends using an 8 character code
View name, status and CO2 saved
Your code displayed for sharing
Leaderboard
Top 3 podium
Friends only ranking list
Trip Logging
Select a transport mode
Input distance
See color coded summary
Backend calculates CO2 savings
Exact Prompt to Use
Paste this directly into Emergent:
Key Implementation Steps
1. Auth with JWT
Use bcrypt to hash passwords.
Issue JWTs with sub, iat, exp.
Validate tokens in a get_current_user helper.
2. Locations and Geocoding
Use expo-location on mobile for GPS.
Use Nominatim for autocomplete on all platforms.
3. Air Quality Data
Query
/v3/locations?coordinates=[lat,lon]Extract a
locations_idFetch
/v3/locations/[id]/latestLoop stations to find valid PM2.5
This improves accuracy in regions where the first reading is invalid.
4. Trip and CO2 Calculations
Store trips in MongoDB.
Call RapidAPI or your own formula for CO2 per kilometer.
5. Cross Platform UI
Use Expo, LinearGradient and frosted cards.
Replace Alert.alert with custom modals since alerts do not work well on web.
Use react-native-chart-kit for the weekly line chart.
Common Issues and Fixes
Geocoding fails on web
Do not use Location.geocodeAsync. Use Nominatim.
AQI shows 0 or -9999
Implement a fallback loop to pick the first valid PM2.5 value.
JWT works on one endpoint but not others
Update token validation to support both JWT and session tokens.
Metro or backend cache stuck
Clear Metro cache and Python __pycache__ before restarting services.
OpenAQ v2 → v3
Use the new two step flow: metadata first, measurements second.
Design Choices
Friend codes instead of email: simple and private
JWT login: works everywhere
Nominatim: free and cross platform
Custom modals: consistent UX across devices
Dark glass morphism: readable and modern
What You Can Add Next
Air quality alerts
Offline caching
Map of nearby stations
More transport modes
Achievements or streaks
Wrapping Up
That's it!
You now have a well structured cross platform air quality and carbon tracking app running on Emergent.
You described the requirements and Emergent generated:
The backend architecture
The data pipelines
The React Native screens
The location and air quality system
The carbon tracking and social features
Once deployed, your app is live and ready to explore.

