Skip to content

A modern weather web application that provides real-time weather data, forecasts with location and voice search user experience

License

Notifications You must be signed in to change notification settings

ShubhamOulkar/weather

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

60 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

Weather App

A modern weather web application that provides real-time weather data, forecasts, and interactive features to enhance the user experience. Design is focused on separation of concerns and maintainability.

Powered by Vercel Build and Analysis Checks


Table of Contents


Overview

Screenshot

Project Preview

Links

Features (The Challenge)

Users can:

  • πŸ” Search for weather by entering a city or using device geolocation.
  • 🌑 View current conditions: temperature, weather icon, and location details.
  • πŸ“Š Explore metrics: "feels like", humidity, wind speed, precipitation, AQI.
  • πŸ“… Check a 7-day forecast with highs/lows and weather icons.
  • πŸ•’ Browse hourly forecasts with temperature trends.
  • πŸ“Œ Switch between days in the hourly forecast.
  • πŸ”„ Toggle between Metric and Imperial units (CΒ°/FΒ°, km/h/mph, mm/inch).
  • πŸ“± Enjoy responsive layouts optimized for all devices.
  • πŸ–± Experience hover/focus states for all interactive elements.
  • πŸ“ Detect current location automatically (first visit).
  • ⭐ Save favorite locations for quick access.
  • πŸŽ™ Use voice search to find weather quickly.

My Process

Built With

  • Vite (bundler)
  • React + React Query (TanStack)
  • CSS Modules with custom properties & variable fonts
  • Mobile-first workflow
  • Light/Dark mode via system preference
  • Vitest + React Testing Library for testing

Keyboard search functionality

The SearchForm component is a feature-rich, interactive input for location-based search. It combines immediate feedback (live search), client-side validation, accessibility features, and GPS integration to provide a robust user experience.

Key Features:

  • Live Search with Debouncing: Provides real-time suggestions as the user types, using the useLiveSearch hook to efficiently query data. The search query is debounced by 500ms to prevent excessive API calls while the user is actively typing.

  • Form Validation: Uses SearchSchema for client-side validation of the search input, displaying immediate error messages when invalid input is detected.

  • Dismissal Outside: Uses the useDismissalOutside hook to close the live search dropdown when the user clicks or focuses anywhere outside the search input and dropdown area.

  • GPS Integration: Allows users to automatically use their current location with the "Locate me" button, utilizing the useGpsLocation hook.

  • Speech Recognition: Includes a dedicated button for voice input, enhancing accessibility and ease of use.

  • Location Context Management: Updates the global application state for the user's current location (city and/or coords) via the useLocation context.

useDismissalOutside hook

A React hook to manage the dismissal of components (like dropdowns, modals, or tooltips) when a user clicks or focuses outside of the component and its associated trigger element. This hook is reusable on all dropdowns from search dropdowns to any select dropdown.

Voice search features

  • Starts listening when the button is clicked.
  • Automatically stops after 10 seconds.
  • Updates the search query live while listening.
  • Validates the search input using SearchSchema.
  • Shows toast notifications for errors and info.

useSpeechRecognitionNative hook

A custom React hook that provides continuous speech recognition using the native Web Speech API (webkitSpeechRecognition). This hook manages the entire speech recognition lifecycle β€” including setup, start/stop control, cleanup, and automatic text updates.

Support: - βœ… Chrome (desktop & Android) - ⚠️ Edge (Chromium-based) - ⚠️ Safari (partial, experimental) - ❌ Firefox (not supported)

Error handling

Used a class-based ErrorBoundary integrated with React Query’s QueryErrorResetBoundary and useQueryErrorResetBoundary hook. This setup ensures query errors and runtime errors are gracefully isolated to their component scope. The Retry button in the fallback UI calls both the local ErrorBoundary.reset() and React Query’s reset() to trigger automatic re-fetching of failed data.

SSR with expressjs

To ensure optimal performance, particularly for initial load speed and SEO, the website utilizes a Server-Side Rendered (SSR) architecture powered by Express.js. This approach resulted in a huge difference in performance compared to a purely Client-Side Rendered (CSR) setup, especially for high-speed metrics like First Contentful Paint.

Note: Keep separate for learning purpose. And I am still learning and experimenting with react API renderToPipeableStream().

Testing

  • Unit Test : Written using Vitest and React Testing Library to validate core utility functions and reusable hooks.
  • Integration Test : Focused on user behavior and component interactions. Most of the components are are covered through integration testing.
  • Test coverage is tracked continuously on codecov.io

What I Learned

  • Efficient data fetching and caching using React Query.
  • Managing geolocation APIs and permissions.
  • Creating a scalable and responsive UI with CSS Grid and Flexbox.
  • Implementing accessibility best practices for interactive UI elements.
  • Testing react query
  • Error Boundaries : Error handling in react query. Catching runtime errors that happen during rendering, and react properly to them by displaying a fallback UI instead.

Useful Resources


Installation

Clone and set up the project locally:

# Clone the repository
git clone https://github.com/ShubhamOulkar/weather.git

# Navigate to project
cd weather/app

# Install dependencies
pnpm install

# Create .env file and add your API keys if needed
cp .env.example .env

# Start development server
pnpm dev

for formating and linting

pnpm format:lint

for testing

pnpm test 

for build and preview

pnpm preview

Changelog

Author

License

Content submitted by shubham oulkar is Creative Commons Attribution 4.0 International licensed, as found in the LICENSE file.

About

A modern weather web application that provides real-time weather data, forecasts with location and voice search user experience

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published