Weather App TS is a single-page React application written in TypeScript and styled with Tailwind CSS. All shared state lives in a singleDocumentation Index
Fetch the complete documentation index at: https://mintlify.com/cristhianblaffita-web/Weather-App-Ts/llms.txt
Use this file to discover all available pages before exploring further.
WeatherContext provider that is mounted at the application root, so every component in the tree can read city selection, loading state, and transformed weather data without prop-drilling. Data fetching is delegated to two custom hooks — useWeather and useGeocoding — while a third hook, useWeatherTheme, handles automatic day/night theming. Utility functions in src/utils/ handle date formatting, weather-code classification, cloud-coverage labelling, and the hour-level day/night calculation that enriches each hourly forecast card.
Component Tree
The following tree shows how React elements are nested at runtime.WeatherProvider wraps the entire application so context is available everywhere beneath it.
WeatherNav owns the search input and the city-name/date header. CurrentWeather renders the headline temperature alongside apparent temperature, humidity, wind speed, and cloud coverage. HourlyWeather shows a scrollable row of the next seven hours, and DailyWeather presents a seven-day outlook beneath it.
Directory Layout
Design Decisions
- React Context over a state-management library — the app has a single data domain (one city, one forecast) and a shallow component tree. React Context with
useMemo-derived values avoids the overhead of Redux or Zustand while keeping the state model easy to trace. - Open-Meteo as the weather API — Open-Meteo is entirely free, requires no API key, and provides reliable global coverage including current conditions, hourly forecasts, and daily summaries in a single request. This removes the need for environment-variable management or account sign-up for anyone running the project locally.
- Debounce on search input — the search string is passed through
useDebouncewith a 300 ms delay before being forwarded touseGeocoding. This prevents a geocoding API call on every keystroke and keeps network traffic minimal without noticeably affecting responsiveness. - localStorage persistence — when the user selects a city it is serialised to
localStorageunder the keyselectedCity. On the next visit the stored value is parsed back as the initial state, so the app opens on the last-used city rather than the default. - Automatic day/night theming —
useWeatherThemereceives theis_dayboolean from the current weather response and callsdocument.documentElement.classList.toggle('dark', !isDay). Tailwind’s dark-mode variants then respond to the presence or absence of that class on the<html>element, requiring no user interaction to switch themes.
Explore the Architecture
Overview
Component tree, directory layout, and design decisions.
Weather Context
Global state shape, data transformation, and city persistence.
Data Flow
End-to-end trace from search input to rendered weather UI.