2.5 KiB
2.5 KiB
PolyWeather Frontend
This directory contains the production web frontend.
Production URL:
Stack
- Next.js App Router
- React (dashboard component architecture)
- Tailwind CSS
- Leaflet (map)
- Chart.js
- Typed dashboard store + typed data client
Runtime Model
- Vercel hosts UI + BFF route handlers.
- FastAPI on VPS provides weather/analysis APIs.
- Browser never calls backend directly in normal flow.
Request path:
- Browser ->
https://polyweather-pro.vercel.app - Frontend -> Next route handlers (
/api/*) - Route handlers -> FastAPI (
POLYWEATHER_API_BASE_URL)
Local Development
cd frontend
cp .env.example .env.local
npm install
npm run dev
Default local URL:
Required Environment Variables
POLYWEATHER_API_BASE_URL=https://<your-fastapi-host>
Optional entitlement variables:
POLYWEATHER_DASHBOARD_ACCESS_TOKEN=
POLYWEATHER_BACKEND_ENTITLEMENT_TOKEN=
Route Handlers
GET /api/citiesGET /api/city/[name]GET /api/city/[name]/summaryGET /api/city/[name]/detailGET /api/history/[name]
Cache behavior:
cities/summary/historyreturnETag+Cache-Control.summary?force_refresh=truereturnsCache-Control: no-store.city/[name]andcity/[name]/detailare dynamic pass-through (no shared HTTP cache).
Frontend State & Local Cache
sessionStorage:- city detail cache bundle (TTL 5 minutes)
localStorage:- selected city
- sidebar risk-group collapse state
- in-flight request de-duplication for city detail/summary/history/market scan
Entitlement
frontend/middleware.tsenforces dashboard/API access whenPOLYWEATHER_DASHBOARD_ACCESS_TOKENis set.- BFF forwards backend entitlement token via
x-polyweather-entitlementheader when configured.
UI Notes
- Left sidebar supports risk-group collapsible sections.
- City rows keep local time and peak-time hints visible.
- Future-date modal requests market scan with
target_date. - Detail panel accessibility uses
inert+ blur when hidden.
Icons & Manifest
frontend/app/favicon.icofrontend/app/favicon-16x16.pngfrontend/app/favicon-32x32.pngfrontend/app/apple-touch-icon.pngfrontend/app/site.webmanifest
Vercel Deployment
- Import repo into Vercel
- Set Root Directory =
frontend - Set env vars
- Deploy
Verification
./scripts/validate_frontend_cache.sh "https://polyweather-pro.vercel.app"
Last updated: 2026-03-12