Back to projects
Projectbeginner 8 steps ~80 min

Weather Dashboard

Build a weather dashboard with real data from Open-Meteo: a status union for every outcome, a tested response normalizer, city disambiguation, latest-search-wins with AbortController, a TTL cache, unit switching, and server-side API keys.

What you'll build

A weather dashboard with live data where the latest search always wins, even on a slow network.

  • React
  • fetch
  • AbortController
  • caching
  • status unions
Project briefrequirements and design decisions

Requirements

  • Search a city and show current conditions
  • Show loading, error, and empty states
  • The latest search wins, even if an earlier request is slower

Architecture decisions

  • Model the request as a status union: idle, loading, success, error
  • Ignore stale responses so results always match the latest query
  • Keep API access in one function so it's easy to swap or mock

Stretch goals

  • Cache results per city for 10 minutes
  • Use the browser's geolocation for the default city
  • Add a 5-day forecast chart

Production checklist

  • Never expose a secret API key in the browser; proxy through a server
  • Retry transient failures with backoff
  • Units and dates formatted for the user's locale

1What we're building

You'll build a weather dashboard with real data from Open-Meteo, a free weather API that needs no key. Search a city and see current conditions plus a 5-day forecast.

Fetching data is easy. Fetching it well is what this project is about. These are the problems every data-driven UI has:

  • Every request can be slow, fail, or return nothing. The UI needs a clear state for each case, and no impossible ones (a spinner and an error).
  • Responses arrive out of order. Search "Par", then "Paris": if the first request is slower, the wrong city wins. This bug is everywhere: search boxes, filters, tabs.
  • API responses aren't shaped for your UI, and they change. Converting them in one place keeps the rest of the app stable.
  • Names are ambiguous. There are dozens of places called Springfield.
  • Re-fetching unchanged data wastes the user's battery and your API quota.
1api.js the only code that talks to the weather service 2normalize.js API response -> the shape the UI wants 3weatherCodes.js WMO weather codes -> labels and icons 4useWeatherSearch.js requests, cancellation, and status 5cache.js a small time-based cache 6WeatherPanel.jsx one view per status 7CurrentConditions.jsx, Forecast.jsx, CityChoices.jsx, SearchForm.jsx 8App.jsx wiring, units, slow-network switch

What you'll learn: modeling async UI as a status union, normalizing API data at the edge, race conditions and AbortController, disambiguation UX, caching with a TTL, locale-aware dates, and why API keys never go in frontend code.

Weather Dashboard project | Bloom