Health-Optimized Urban Navigation
Urban air pollution varies by location. Traditional navigation apps prioritize speed/distance but may route users through high-pollution zones like highways and industrial areas, increasing health risks.
BreathClean computes health scores (0-100) for routes by integrating:
- Real-time AQI data from AQICN
- Weather data from OpenWeather
- Traffic data from Mapbox
-
Health-First Routing
Routes scored by PM2.5, O3, temperature, humidity, and traffic congestion -
Route Comparison
Three options: "Cleanest Path", "Fastest", and "Balanced" -
Multi-Modal Support
Walking, cycling, and driving with mode-specific metrics -
Saved Routes
Store and favorite routes with auto-refreshed health scores (every 30 minutes) -
Secure Authentication
Google OAuth 2.0 with JWT token management -
Data Caching
Redis caching for API results (30min scores, 1hr breakpoints)
- React 19 with hooks-only state management
- TypeScript 5 (strict mode)
- Tailwind CSS 4 + shadcn/ui
- Mapbox GL JS for interactive maps
- Redis caching integration
- TypeScript 5 with strict compiler options
- MongoDB with geospatial indexing (2dsphere)
- Upstash Redis for serverless caching
- Google OAuth via simply-auth
- Rate limiting (10 req/min on scoring endpoint)
- Django 5.x microservice for batch processing
- Pathway framework for streaming pipelines
[Client] → Express API → Redis Cache → MongoDB
↘ ↘
→ Django/Pathway (background scoring)
-
User Request
- Mapbox returns 3 route geometries
- Client sends routes to
/score/computeendpoint
-
Breakpoint Extraction
- 3-4 evenly spaced points per route
-
Parallel Data Fetch
- AQICN + OpenWeather for each breakpoint
- 5 concurrent requests with 8s timeout and 2 retries
-
Score Calculation
- Weather (40%): Temperature, Humidity, Pressure
- AQI (30%): Inverse scale from 20→100 to 200→0
- Traffic (30%): Congestion level (0-3)
-
Caching & Storage
- Redis cache for 30min
- MongoDB for persistent user data
| Method | Endpoint | Description |
|---|---|---|
| GET | /auth/google/link |
Initiate Google OAuth flow |
| GET | /auth/google/callback |
Handle OAuth redirect |
| GET | /auth/user |
Retrieve authenticated user |
| GET | /auth/logout |
Clear authentication cookies |
POST /score/compute
- Request: Route geometries + traffic data
- Response: Scores for each route with pollution reduction % and health metrics
| Method | Endpoint | Description |
|---|---|---|
| GET | /saved-routes |
List user's saved routes |
| POST | /saved-routes |
Save new route |
| DELETE | /saved-routes/:id |
Delete route |
| PATCH | /saved-routes/:id/favorite |
Toggle favorite status |
{
"googleId": "string",
"email": "string",
"name": "string",
"picture": "string",
"emailVerified": "boolean"
}{
"userId": "ObjectId",
"from": { "address": "string", "location": [lng, lat] },
"to": { "address": "string", "location": [lng, lat] },
"routes": [
{
"distance": "number",
"duration": "number",
"travelMode": "string",
"lastComputedScore": "number",
"lastComputedAt": "Date"
}
]
}{
"routeId": "ObjectId",
"location": [lng, lat],
"aqiData": "object",
"weatherData": "object"
}- Node.js 20+
- Python 3.10+ (optional for data processing)
- MongoDB (local or Atlas)
- Upstash Redis (free tier available)
- API keys for Mapbox, AQICN, OpenWeather, and Google OAuth
# 1. Clone and install
git clone https://github.com/kaihere14/BreathClean.git
npm install
# 2. Install Python dependencies (optional)
cd data-processing/dataProcessingServer
pip install -r requirements.txtCreate .env files in each service directory:
Client
NEXT_PUBLIC_BACKEND_URL=http://localhost:8000
NEXT_PUBLIC_MAPBOX_TOKEN=your-tokenServer
MONGODB_URI=mongodb://localhost:27017
GOOGLE_CLIENT_ID=your-id
GOOGLE_CLIENT_SECRET=your-secret
AQI_API_KEY=your-aqicn-token
WEATHER_API_KEY=your-openweather-tokenData Processing Server
DJANGO_SECRET_KEY=your-secret
PATHWAY_URL=http://localhost:8001# Terminal 1 - Frontend
npm run dev:client
# Terminal 2 - Backend
npm run dev:server
# Terminal 3 - Optional data processor
cd data-processing/dataProcessingServer
python manage.py runserver 8001Access at http://localhost:3000
| Command | Purpose |
|---|---|
npm run dev:client |
Start frontend development server |
npm run dev:server |
Start backend development server |
npm run build:client |
Build frontend for production |
npm run build:server |
Compile backend TypeScript |
npm run lint |
Lint all code |
npm run format |
Format code with Prettier |
- TypeScript: Strict mode with
noUncheckedIndexedAccess - Prettier: Double quotes, 80-char line limit
- Tailwind: 2dsphere indexing for geospatial data
- Auto-formatted imports and classes
- Fork the repository
- Create a feature branch:
git checkout -b feature/your-feature - Commit changes:
git commit -m "feat: add your feature" - Push branch:
git push origin feature/your-feature - Open a Pull Request
ISC License
Built with care for a healthier urban future.