Weather Forecast App is a responsive React application that provides real-time weather data, hourly forecasts, and multi-day predictions using WeatherAPI.com.
The project focuses on component-based architecture, custom React hooks, dynamic theming, and responsive UI development using React and SCSS.
- React
- Vite
- SCSS (Sass)
- Vitest (unit testing)
- Weather API (WeatherAPI.com)
- Component-based React architecture
- Custom React hooks for state and logic separation
- Dynamic weather-based theming system
- Responsive SCSS architecture
- API integration with asynchronous data handling
- Unit testing with Vitest
- Shows current weather and hourly forecast for the selected city.
- Shows multi-day forecast with tabs (
5 / 10 / 14 days). - Supports city search with suggestions.
- Updates local time based on the selected location timezone.
- Dynamically changes visual theme/background based on weather condition and day/night.
- Includes responsive layouts for desktop and mobile.
- Node.js (LTS recommended, >= 20)
- npm (comes with Node.js)
- Install dependencies:
npm install- Create a
.envfile in the project root and add:
VITE_WEATHER_API_KEY=your_api_key_here- Start development server:
npm run dev- Optional checks:
npm run lint
npm run build
npm run previewThe project includes basic unit tests using Vitest.
Tested parts:
- utility functions (weather normalization, time calculations)
- theme resolution logic
- custom React hooks (
useForecastTabs)
Run tests:
npm run testApp.jsxorchestrates page composition and passes data to feature components.- Weather UI is split into focused components:
SidebarTopContent(search + current metrics)HourlyForecast(hourly cards)Sidebar+DailyList(next-days forecast)
useWeatherhandles API requests, loading/error states, city input, and suggestions.useClockprovides ticking time for location-aware clock rendering.useForecastTabscontrols forecast range and active day.useWeatherThemederives theme + weather label + day/night mode from active weather data.
- Mapping and normalization are moved into
utils/*andconstants/weatherThemes.js. - This keeps rendering components smaller and easier to maintain.
- SCSS is split by concern:
styles/abstracts(variables, mixins)styles/base(typography, responsive)styles/components(feature styles)styles/themes(day/night visual behavior)
-
State-driven UI architecture
- UI is derived from a minimal set of state variables (
weatherData,activeDay,activeHour). - Forecast navigation updates both hourly and sidebar data, keeping all sections synchronized.
- UI is derived from a minimal set of state variables (
-
Weather data processing & theming
- API weather conditions are normalized into a limited internal set (
rain,cloudy,clear, etc.). - A configuration-based theme system maps weather types to UI variants (day/night).
- Business logic is separated from UI via hooks and utility functions.
- API weather conditions are normalized into a limited internal set (
-
Progressive enhancement approach
- Core functionality (data fetching + rendering) was implemented first.
- Visual enhancements (glass UI, transitions, dynamic backgrounds) were layered on top afterward.




