A React-based single-page application that displays data about countries and provides real-time weather information for each country's capital city. The app integrates both the Countries GraphQL API and OpenWeatherMap API to showcase country details and weather data.
-
Country Search:
- Search countries by name.
- Displays matching countries with essential details: country name, capital, region, and flag.
-
Country Details with Weather Information:
- Shows detailed information like languages, currencies, population, neighboring countries, and time zones.
- Displays real-time weather data for the capital city, including temperature, weather conditions, and an icon.
-
Filter and Sort:
- Filter countries by region or language.
- Sort the list of countries by name, population, or area.
-
Responsivity:
- Fully responsive layout for mobile, tablet, and desktop devices.
- Frontend: React, TypeScript, CSS, Styled Components
- GraphQL: Apollo Client for querying data from the Countries GraphQL API
- REST API: Fetches weather data from the OpenWeatherMap API
- Testing: React Testing Library, Jest
- Build Tool: Vite/Webpack
- Version Control: GitHub/GitLab
- Node.js (v14 or higher) and npm.
- A free API key from OpenWeatherMap API.
-
Clone the Repository:
git clone <repository-url>
-
Install Dependencies:
npm install
-
Set up Environment Variables:
- Create a .env file in the project root.
- Add your OpenWeatherMap API key.
-
Run the Application:
npm start
- To run tests, execute:
npm test
- Searching for Countries: Use the search bar on the homepage to find countries by name.
- Viewing Country Details: Click on a country card to view more details, including the weather.
- Filtering/Sorting: Use the filter dropdown to filter countries by region or language. Use the sort option to arrange countries by name, population, or area.
- API Rate Limiting: Implemented error handling for API rate limits to notify users if the weather data cannot be fetched due to API restrictions.
- Integrating GraphQL and REST APIs: Combining data from both GraphQL (Countries API) and REST (OpenWeatherMap) required careful asynchronous handling and state management.
- Caching: Use a caching strategy for API responses to improve performance.
- Pagination: Implement pagination for the list of countries.
- Improved Error Handling: Add user-friendly messages for different types of errors (e.g., network failures, invalid API responses).