A simple weather application that allows users to search for current weather conditions in any city around the world. This app fetches real-time data from the OpenWeatherMap API and displays essential weather information like temperature, humidity, and more.
- ๐ Search by City: Get real-time weather data for any city.
- ๐ก๏ธ Current Weather Information: Displays temperature, humidity, and weather description.
- ๐งช Unit Tests: Includes testing setup with Vitest and React Testing Library.
- ๐๏ธ Theme Toggle: Uses a switch component to toggle between themes (light/dark mode).
- React: For building the user interface.
- Vite: A fast build tool for modern web projects.
- React Router DOM: For client-side routing.
- React Switch: For the theme toggle feature.
- Vitest: For unit testing.
- Testing Library: For testing React components.
- ESLint: For linting JavaScript/JSX files.
- dotenv: For managing environment variables.
- The user enters a city name to search.
- The app makes a request to the OpenWeatherMap API and retrieves current weather data.
- Weather details such as temperature, humidity, and description are displayed.
Ensure you have the following installed:
- Node.js
- npm or yarn
-
Clone the repository:
git clone https://github.com/your-username/climate-app.git cd climate-app
-
Install dependencies:
npm install # or yarn install
-
Set up environment variables by creating a
.env
file in the root directory with your OpenWeatherMap API key:REACT_APP_WEATHER_API_KEY=your_api_key_here
-
Start the development server:
npm run dev # or yarn dev
To run the test suite:
npm run test
For test coverage:
npm run coverage
dev
: Start the development server using Vite.build
: Build the project for production.lint
: Run ESLint to lint the code.preview
: Preview the production build.test
: Run the test suite with Vitest.coverage
: Generate a test coverage report.
/src
โโโ /assets
โโโ /components
โโโ /context
โโโ /helper
โโโ /hooks
โโโ /pages
โโโ /services
โโโ /test
โโโ /utility
โโโ App.jsx
โโโ App.module.css
โโโ main.jsx
โโโ main.jsx
.env
vite.config.js
package.json
README.md
This app uses the OpenWeatherMap API to retrieve weather data. You can get an API key by signing up here.
Example API call:
https://api.openweathermap.org/data/2.5/weather?q=London&appid=your_api_key&units=metric
Feel free to fork this repository and submit pull requests. Any contributions are welcome!
This project is licensed under the MIT License - see the LICENSE file for details.