WeatherCast is a web-based application that provides real-time weather information for any location worldwide. The app is designed to help users search accurate and up-to-date weather information. With WeatherCast, users can quickly access current weather conditions and Save for any city, allowing them to make informed decisions based on the weather.
- Search and view real-time weather information for any location worldwide.
- Save favorite cities for quick access to weather updates.
- Display a 3-hour forecast with temperature and weather icons.
- Display a 5-day forecast with temperature ranges and weather icons.
- Fetch weather data using the OpenWeatherMap API.
- Store user data and favorite cities in a PostgreSQL database.
- Java
- Spring Boot
- Thymeleaf (HTML templating engine)
- PostgreSQL (Relational Database Management System)
- OpenWeatherMap API
- Java Development Kit (JDK) 8 or above installed.
- PostgreSQL database server installed.
- OpenWeatherMap API key. (Register at https://openweathermap.org/ and obtain an API key)
- Clone the WeatherCast repository to your local machine:
git clone https://github.com/umangptl/weatherCast.git
- Navigate to the project directory:
cd weathercast
- Open the src/main/resources and create a application.properties file and configure the following properties:
spring.datasource.url=jdbc:postgresql://localhost:5432/weathercast_db
spring.datasource.username=your-username
spring.datasource.password=your-password
spring.jpa.show-sql=true
spring.jpa.hibernate.ddl-auto=update
Open the src/main/java/com/example/weatherast/controller/WeatherDataController
public static final String API_KEY = "Api_Key";
Replace your-username, your-password, and your-api-key with your PostgreSQL credentials and OpenWeatherMap API key, respectively.
-
Create a new database named weathercast_db in your PostgreSQL server.
-
Build the project using Maven:
mvn clean install
- Run the application:
mvn spring-boot:run
- Access the application in your web browser at http://localhost:8080
- On the WeatherCast home page, enter the name of a city in the search bar and click the "Search" button. and use the switch button to change the units metric or imperial
- View the current weather conditions for the searched city, including temperature, humidity, wind speed, and weather description. 3-hour forecast, 5-day forecast.
- click Save on the header see your Favorites cities and search a city to save.
- Get current weather for a specific city:
- Endpoint: /weather
- Method: POST
- Request Parameters:
- search-city: Specifies the name of the city for which you want to retrieve the current weather information.
- units (optional): Specifies the unit of measurement for the temperature. Defaults to "metric".
- Description: Retrieves the current weather information for the specified city.
- Save weather data for a city:
- Endpoint: /save
- Method: POST
- Request Parameters:
- add-city: Specifies the name of the city to save.
- units (optional): Specifies the unit of measurement for the temperature. Defaults to "metric".
- Description: Saves the weather data for the specified city in the database.
- Get all saved weather data:
- Endpoint: /list
- Method: GET
- Request Parameters:
- units (optional): Specifies the unit of measurement for the temperature. Defaults to "metric".
- Description: Retrieves all saved weather data from the database.
4.Delete weather data for a city:
- Endpoint: /delete
- Method: POST
- Request Parameters:
- cityToDelete: Specifies the name of the city to delete from the saved weather data.
- Description: Deletes the weather data for the specified city from the database