Get in Touch

Weather Now

A lightning-fast weather dashboard built with React and Material UI, delivering real-time climatic data through a clean, responsive interface.

A screenshot of the Weather Now application interface.

Project Overview

Weather Now is a sleek, single-page application (SPA) designed to provide instant weather updates for any location globally. By leveraging the speed of Vite and the robust component library of Material UI, the app ensures a seamless user experience. It features a dual-API architecture, using OpenStreetMap's Nominatim service for accurate geocoding and OpenWeatherMap for detailed meteorological data.

Core Features

The Logic: Chained API Requests

A key challenge in weather apps is converting a city name into coordinates before fetching weather data. This logic demonstrates how I chained two asynchronous requests: first to `Nominatim` to get the latitude/longitude, and then to `OpenWeatherMap` for the actual data, all while managing loading states.

// SearchBox.jsx - Chained Async Operations

const GEO_CODE_API = "https://nominatim.openstreetmap.org/search";
const WEATHER_API = "https://api.openweathermap.org/data/2.5/weather";

// 1. Fetch Coordinates first (Geocoding)
const getCordinates = async(city) => {
    try {
        const res = await fetch(`${GEO_CODE_API}?q=${city}&format=json`);
        const data = await res.json(); 
        let {lat, lon} = data[0];
        return {lat, lon};
    } catch (err) {
        throw err;
    }
}

// 2. Fetch Weather using Coordinates
let getWeatherInfo = async(lat, lon, city) => {
    try {
        const res = await fetch(`${WEATHER_API}?lat=${lat}&lon=${lon}&appid=${WEATHER_API_KEY}&units=metric`);
        const jsonRespose = await res.json();
        
        // ... processing data (formatting time, etc.)
        
        return result;
    } catch (err) {
        throw err;
    }
}

// 3. Main Handler
const handleGetWeather = async(city) => {
    if(!city) return ;
    try {
        // Chain the requests: City -> Coords -> Weather
        let {lat, lon} = await getCordinates(city);
        let result = await getWeatherInfo(lat, lon, city);
        updateInfo(result); // Update React State
    } catch (err) {
        setError(true);
    }
}

Technology Stack

This project uses a modern frontend stack focused on performance and component reusability.

React.js (v19) Vite Material UI (MUI) OpenWeatherMap API Nominatim API Geolocation API Emotion (CSS-in-JS)

Learning Outcomes

Building Weather Now provided deep insights into handling asynchronous JavaScript and chaining multiple API requests. I learned to effectively use `useEffect` for triggering initial data fetches based on user location and `useState` for managing complex data objects. Implementing Material UI taught me the importance of using a design system for consistent theming and responsiveness across devices.