Climate-aware pedestrian navigation platform that compares fastest walking paths against shade- and cooling-refuge-optimized routes using live thermal, UV, wind, and community Cool Spot telemetry.
| Layer | Technology / Service | Purpose |
|---|---|---|
| Frontend | React 19, TypeScript 6, Vite 8, Leaflet (react-leaflet) |
Gated auth UI, interactive route comparison map, weather/UV widgets, Cool Spots map & moderation UI, Mappy assistant |
| Hosting | AWS Amplify Hosting (frontend/ monorepo root) |
Builds frontend/dist and serves the SPA |
| API Layer | Amazon API Gateway (heat-safe-route-api, REST) |
Exposes /auth/*, /plan-route, /cool-spots*, /admin/cool-spots*, /health, /heat-score with custom JWT TOKEN authorization |
| Compute | AWS Lambda (Python 3.14) | heat-safe-auth, heat-safe-authorizer, heat-safe-planner, heat-safe-cool-spots, heat-safe-route-health, heat-safe-score, heat-safe-routes, heat-safe-weather, plus backend/functions/mappy |
| Data & Media | Amazon DynamoDB & Amazon S3 | HeatSafe_Users, HeatSafe_Sessions, HeatSafe_CoolSpots, HeatSafe_SpotRequests, HeatSafe_RoutePlans; heatsafe-coolspots-media bucket |
| Secrets & Email | AWS SSM Parameter Store, Gmail SMTP / Amazon SES | Stores JWT signing secret, LWA client secret, and SMTP App Password (SecureString); delivers 6-digit 2FA OTP emails |
- Mandatory Auth Gate (
AuthPage.tsx,AuthFormPanel.tsx,AuthContext.tsx): Visitors must sign in or register before accessing route planning or Cool Spot workflows. - Email + Password with Mandatory 2FA OTP (
POST /auth/register,POST /auth/login,POST /auth/verify-otp,POST /auth/resend-otp):- Passwords require at least 12 characters and are hashed with
scrypt. - Registering or signing in dispatches a 6-digit numeric OTP to the user's email (10-minute expiry, 60-second resend cooldown, max 5 attempts per challenge) and returns a signed short-lived challenge token.
- Access/refresh tokens are issued only after
/auth/verify-otpvalidates the code and marksemail_verified = true. - Supports Gmail SMTP (
smtp.gmail.com:465using an SSM-backed App Password) and Amazon SES (email_otp.py).
- Passwords require at least 12 characters and are hashed with
- Login with Amazon (
POST /auth/amazon):- Uses OAuth 2.0 Authorization Code Grant with PKCE (
S256). - Exchanges codes server-side (
amazon_lwa.py), preserves existing DynamoDBrole(useroradmin), and safely links local + Amazon providers on matching verified email without overwritingpassword_hash.
- Uses OAuth 2.0 Authorization Code Grant with PKCE (
- Stateless JWT + Rotating Sessions & Authorizer (
authorizer/lambda_function.py):- Issues short-lived HS256 JWT access tokens (
600sdefault) and opaque rotating refresh tokens (2592000sdefault) stored hashed inHeatSafe_Sessions(mappingsession_idto DynamoDB keysession_Id). - API Gateway TOKEN authorizer enforces valid Bearer JWTs and restricts
POST /cool-spotsand/admin/*endpoints strictly torole == "admin".
- Issues short-lived HS256 JWT access tokens (
- Alternative Route Comparison (
planner/lambda_function.py,RouteCard.tsx,RouteAnalytics.tsx):- Queries OpenRouteService (
foot-walking) and live weather feeds to compare standard fastest routes against heat-safe pedestrian paths. - Evaluates exposure using ambient temperature, humidity, wind cooling, UV index (
WeatherWidget.tsx), and walking duration (heat_safe_score.py), categorizing exposure asLow,Moderate,High, orVery High. - Logs planned route records to DynamoDB (
HeatSafe_RoutePlans).
- Queries OpenRouteService (
- Map Refuges & Nominations (
CoolSpotMapLayer.tsx,CoolSpotPortal.tsx,cool_spots/):- Displays verified canopy parks, hydration stations (
pyau), and shaded refuges on the interactive Leaflet map. - Authenticated users can nominate new Cool Spots (
POST /cool-spots/requests) with coordinates, cooling category, description, and validated JPEG/PNG/WebP images uploaded with AES-256 encryption to S3 (MediaService).
- Displays verified canopy parks, hydration stations (
- Admin Moderation Dashboard (
GET/PATCH /admin/cool-spots*):- Admins review community submissions across
PENDING,APPROVED,REJECTED, andALLtabs synced directly with DynamoDB, and create/edit/delete published spots directly inHeatSafe_CoolSpots. - Includes automatic access-token refresh retry handling on
401insideplannerApi.ts.
- Admins review community submissions across
- Route Companion (
MappyAssistant.tsx,backend/functions/mappy/):- Gemini-backed assistant supporting text queries, optional hands-free voice transcripts, GPS location awareness, and shade/hydration detour suggestions near active walking segments.
heat-safe-route-planner/
├── backend/
│ ├── functions/
│ │ ├── auth/ # Register, login, 2FA OTP verify/resend, LWA, refresh, logout, /auth/me
│ │ ├── authorizer/ # API Gateway REST TOKEN authorizer (JWT + RBAC enforcement)
│ │ ├── cool_spots/ # Modularized Cool Spots Lambda (config, http, validation, repositories, services)
│ │ ├── planner/ # Multi-route heat-aware pedestrian routing + RoutePlans persistence
│ │ ├── mappy/ # Backend Mappy AI agent & Gemini/deterministic providers
│ │ ├── heat_score/ # Standalone heat exposure scoring Lambda
│ │ ├── routes/ # Route geometry helper Lambda
│ │ ├── weather/ # Weather telemetry Lambda
│ │ └── health/ # Health check Lambda
│ ├── shared/
│ │ ├── auth/ # Shared config, tokens, scrypt passwords, LWA client, DynamoDB repo, email_otp, HTTP helpers
│ │ └── aws/ # SSM Parameter Store SecureString loader
│ └── tests/ # Unit tests for auth, authorizer, repository, tokens, cool_spots, heat model, ranking, mappy
├── frontend/
│ ├── src/
│ │ ├── api/ # authApi.ts, plannerApi.ts
│ │ ├── components/ # AuthPage, AuthFormPanel, AuthModal, authBar, Map, RouteControls, RouteCard, CoolSpot*, MappyAssistant, WeatherWidget
│ │ ├── config/ # supportedCities.ts (Indore bounds), indoreCoolSpots.ts
│ │ ├── context/ # AuthContext.tsx (session state, PKCE callback, OTP challenge state, BroadcastChannel sync)
│ │ ├── types/ # auth.ts, route.ts, coolSpot.ts
│ │ └── utils/ # locationValidation.ts
│ ├── package.json
│ └── vite.config.ts
├── infrastructure/
│ ├── auth-storage.yaml
│ ├── cool-spots-storage.yaml
│ └── iam/ # Least-privilege IAM policy templates
├── scripts/ # Lambda zip packaging & AWS setup helper scripts
├── requirements-auth.txt # Runtime auth dependencies (PyJWT)
└── readme.md
| Variable | Required | Description |
|---|---|---|
VITE_API_BASE_URL |
Yes | Deployed API Gateway stage URL (e.g. https://<api-id>.execute-api.us-east-1.amazonaws.com/dev) |
VITE_AMAZON_CLIENT_ID |
For LWA | Amazon Security Profile OAuth2 Client ID |
VITE_GEMINI_API_KEY (or VITE_GOOGLE_API_KEY) |
For Mappy | Gemini API key used by MappyAssistant |
VITE_GEMINI_MODEL |
Optional | Gemini model override (e.g. gemini-3.8-flash) |
VITE_WEATHER_API_URL |
Optional | Weather endpoint override (defaults to https://api.open-meteo.com/v1/forecast) |
- SSM Parameters (
SecureString):/heatsafe/auth/jwt-signing-key(>= 32-byte HS256 secret)/heatsafe/auth/amazon-client-secret(Amazon LWA client secret)/heatsafe/auth/smtp-password(required when using Gmail SMTP for OTP delivery)
- Core Env Vars:
AUTH_USERS_TABLE=HeatSafe_Users,AUTH_SESSIONS_TABLE=HeatSafe_SessionsHEATSAFE_JWT_SECRET_PARAMETER,HEATSAFE_JWT_ISSUER,HEATSAFE_JWT_AUDIENCEALLOWED_ORIGINS(comma-separated origins, e.g.http://localhost:5173,https://<app>.amplifyapp.com)AMAZON_CLIENT_ID,AMAZON_CLIENT_SECRET_PARAMETER,AMAZON_ALLOWED_REDIRECT_URISOTP_SENDER_EMAIL,OTP_TTL_SECONDS(600),OTP_RESEND_COOLDOWN_SECONDS(60),OTP_MAX_ATTEMPTS(5)- Optional SMTP fallback overrides:
SMTP_HOST(smtp.gmail.com),SMTP_PORT(465),SMTP_USER,SMTP_PASSWORD_PARAMETER
# Frontend dev server & production build (Node 20+ recommended for Vite 8 / TS 6)
cd frontend
npm ci
npm run dev
npm run build
# Python syntax verification & packaging (PowerShell on Windows)
python -m compileall -q backend
./scripts/package-auth-lambdas.ps1
./scripts/package-cool-spots-lambda.ps1- Wildcard CORS & Unauthenticated Routing on
heat-safe-plannerbackend/functions/planner/lambda_function.pystill returnsAccess-Control-Allow-Origin: *rather than validatingALLOWED_ORIGINSdynamically likeauthandcool_spots.- Route planning endpoints (
POST /plan-route) should be attached to the custom JWT authorizer cleanly once legacy callers are migrated.
- Missing CORS Header in
heat-safe-route-health.pybackend/functions/health/heat-safe-route-health.pyreturns onlyContent-Type: application/jsonin the Lambda payload; if API GatewayGET /healthdoesn't inject CORS headers at the integration level, cross-origin health probes from Amplify can fail.
- Client-Side Gemini API Key in
MappyAssistant.tsxMappyAssistant.tsxreadsVITE_GEMINI_API_KEYin the browser (pluslocalStorage), which embeds the key into client bundles. All Gemini calls should be proxied exclusively through the server-sidebackend/functions/mappyLambda.
- Offline Fallback Cache Drift in
plannerApi.tsplannerApi.tscontains seededDEFAULT_COOL_SPOTSandlocalStoragecaches; while useful when developing offline, transient network errors can temporarily show stale or fallback data instead of surfacing an explicit sync warning.
- No Unified IaC Pipeline /
amplify.ymlin Repo- Auth and Cool Spots storage stacks live in separate YAML templates (
infrastructure/), while Lambda code/env updates (ALLOWED_ORIGINS,AMAZON_ALLOWED_REDIRECT_URIS) are deployed via packaging scripts/CLI rather than an AWS SAM/CDK/Terraform stack, and Amplify relies on console monorepo settings (AMPLIFY_MONOREPO_APP_ROOT=frontend) instead of a checked-inamplify.yml.
- Auth and Cool Spots storage stacks live in separate YAML templates (
- Root Workspace & Unpackaged Microservice Hygiene
- Several auxiliary functions (
backend/functions/mappy,heat_score,routes,weather,health) lack dedicated packaging scripts matchingpackage-auth-lambdas.ps1, and legacy troubleshooting markdown files / local build zips in the repo root should be archived intodocs/or removed.
- Several auxiliary functions (
- Single Supported City (
supportedCities.ts): Routing bounds and default Cool Spot datasets are currently configured only for Indore, Madhya Pradesh (22.6–22.85° N,75.75–75.98° E). Expanding to new cities requires adding bounding boxes, validation rules, and regional Cool Spot seed data. - Email 2FA Sending Ceiling (Gmail SMTP vs. SES Production): Amazon SES in
us-east-1is currently in Sandbox mode because AWS requires a verified custom domain with DNS DKIM records before unlocking Production Access. Until a custom domain is configured, OTP delivery runs via Gmail SMTP, which is subject to consumer Gmail daily limits (~500 emails/day) and burst throttling. - Manual Admin Role Promotion: Public sign-up and Login with Amazon strictly assign
role: "user". Promoting an account to"admin"currently requires editing the user'sroleattribute directly inHeatSafe_Users(DynamoDB Console or AWS CLI); there is no in-app admin management UI yet. - No WAF / CAPTCHA on Public Auth Endpoints: While
/auth/verify-otpenforces a 60-second resend cooldown and 5-attempt lockout,/auth/registerand/auth/loginrely on standard API Gateway quotas without CAPTCHA or per-IP WAF rate rules. - S3 Direct Media URLs:
MediaServiceuploads AES-256 encrypted images toheatsafe-coolspots-mediaand stores directhttps://<bucket>.s3.<region>.amazonaws.com/<key>URLs rather than serving via CloudFront signed URLs or API-generated pre-signed GET URLs. - Browser Capability Dependency for Live Telemetry: Hands-free voice wake-word/dictation and live off-route GPS checks in
MappyAssistantdepend on browser support and granted permissions for Web Speech API and Geolocation.
backend is fully operational via API gateway, consolidating multiple Endpoints each pointing its different resources, backend directory here has only inference sense of use, to understand and validate, the backend code is done fully on the aws lambda service. to access the api, access to the service is protected behind an authentication layer, ensuring only verified/authorized users can interact with the API. there are few more changes on frontend and backend to commit, will update the code then.., update: found problem on the uv index as its fetching up for the whole city instead of locality, will improve it in future versions.