⚠️ Note: The backend is hosted on Render's free tier, which may take a few seconds to wake up when you first access the app. Thanks for your patience! 😅
This is a full-stack weather application built with modern React architecture and best practices. It fetches weather data from the OpenWeatherMap API and displays it in a beautiful, responsive UI with glassmorphism design.
If you would like to check out the legacy command-line interface version, please refer to the feature/legacy-weather-cli branch.
The application consists of:
- A backend built with Node.js and Express to handle API requests and serve weather data.
- A frontend built with React 19 and Tailwind CSS v4 with a modern, scalable architecture.
- Fetches weather data from the OpenWeatherMap API
- Handles API requests with Express
- Implements dynamic CORS for local and production environments
- Provides detailed weather information, including:
- Temperature
- Feels like temperature
- Weather conditions
- Humidity
- Wind speed
- Sunrise and sunset times
- Cloud cover and visibility
- Modern Architecture: Custom hooks, API service layer, and atomic components
- Glassmorphism UI: Beautiful, modern design with Tailwind CSS v4
- Dynamic Backgrounds: Changes based on weather conditions
- Responsive Design: Works on all screen sizes
- Loading States: Skeleton loading for better UX
- Error Handling: Graceful error messages
frontend/src/
├── api/ # API Layer
│ ├── axios.js # Axios instance with interceptors
│ ├── weatherApi.js # Weather-specific API functions
│ └── index.js # Barrel export
│
├── components/
│ ├── ui/ # Atomic UI components
│ │ ├── Button.jsx # Reusable button
│ │ ├── Input.jsx # Reusable input
│ │ ├── Card.jsx # Glassmorphism card
│ │ ├── Skeleton.jsx # Loading skeleton
│ │ └── index.js # Barrel export
│ │
│ ├── weather/ # Feature components
│ │ ├── WeatherCard.jsx # Main weather display
│ │ ├── WeatherSearch.jsx # Search form
│ │ ├── WeatherDetails.jsx # Detailed weather info
│ │ ├── WeatherIcon.jsx # Dynamic weather icons
│ │ └── index.js # Barrel export
│ │
│ └── layout/ # Layout components
│ ├── Header.jsx # App header
│ ├── Container.jsx # Responsive container
│ ├── Background.jsx # Dynamic background
│ └── index.js # Barrel export
│
├── hooks/ # Custom React hooks
│ ├── useWeather.js # Weather data fetching
│ ├── useLocalStorage.js # Persist preferences
│ └── index.js # Barrel export
│
├── utils/ # Utility functions
│ ├── formatters.js # Temperature, date formatters
│ ├── weatherCodes.js # Weather code mappings
│ ├── constants.js # App constants
│ └── index.js # Barrel export
│
├── App.jsx # Main app component
├── main.jsx # Entry point
└── index.css # Tailwind imports & custom styles
- Custom Hooks:
useWeatherencapsulates all weather-related state and logic - API Service Layer: Axios instance with interceptors for consistent error handling
- Atomic Components: Small, reusable UI components with single responsibility
- Barrel Exports: Clean imports with index.js files
- Node.js 18+ installed on your machine
- Basic understanding of JavaScript, React, and terminal commands
git clone https://github.com/<your-username>/weather-app.git
cd weather-app-
Navigate to the
backendfolder:cd backend -
Install dependencies:
npm install
-
Create a
.envfile for environment variables:KEY=your_actual_api_key_here PORT=3003 FRONTEND_URL=http://localhost:5173 -
Start the backend server:
npm start
-
Navigate to the
frontendfolder:cd ../frontend -
Install dependencies:
npm install
-
Create a
.envfile for environment variables:VITE_API_BASE_URL=http://localhost:3003 -
Start the frontend development server:
npm run dev
- GET
/weather/:city- Fetches weather data for the specified city.
- Query Parameters:
unit(optional):metric(default) orimperial.
- The frontend is deployed on GitHub Pages and connects to:
- the backend hosted on Render
- the OpenWeatherMap API for weather data
⚠️ Note: The backend is hosted on Render's free tier and may take a few seconds to spin up when first accessed.
- Frontend runs at:
http://localhost:5173/
- Deploy the backend to a service like Render, Heroku, or AWS.
- Set the
FRONTEND_URLin the backend.envfile to match your deployed frontend URL.
- Build the frontend:
npm run build
- Start the backend server.
- Start the frontend development server.
- Open the frontend in your browser (default:
http://localhost:5173). - Enter a city name in the search bar to fetch and display weather data.
- React 19 - UI library
- Tailwind CSS v4 - Utility-first CSS
- Axios - HTTP client
- React Icons - Icon library
- Vite - Build tool
- Node.js - Runtime
- Express - Web framework
- node-fetch - HTTP requests
-
Add Forecast Data
- Extend the backend to fetch and display multi-day weather forecasts.
-
User Preferences
- Allow users to save their preferred cities and units (metric/imperial).
- Use
useLocalStoragehook for persistence.
-
Geolocation
- Auto-detect user location for instant weather display.
-
Weather Maps
- Integrate weather radar and satellite imagery.
-
PWA Support
- Add service worker for offline functionality.
- Node.js Documentation
- React Documentation
- OpenWeatherMap API
- Express Documentation
- Tailwind CSS Documentation
- Axios Documentation
This project was developed as a learning exercise to integrate external APIs, build a full-stack application, and deploy it for public use. Contributions and suggestions are welcome!
If you would like to check out the legacy command-line interface version, please refer to the feature/legacy-weather-cli branch.
Thanks for smiling ! 😆