Skip to content

🌦️ Kerala Weather Application is a Java desktop app that fetches, stores, and displays weather data for Kerala's districts. Leveraging the Open-Meteo API and MySQL database, it provides real-time weather information, historical data, and key metrics such as temperature, humidity, wind speed, and rainfall.

License

Notifications You must be signed in to change notification settings

eternalflame02/KeralaWeatherApp

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

2 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

README.md

🌧️ Kerala Weather Application 🌞

A Java desktop application for fetching, storing, and displaying weather data for Kerala's districts. This app uses the Open-Meteo API and a MySQL database to display both current and past weather conditions for each district.

πŸš€ Features

  • Real-Time Data: Fetches real-time weather data for Kerala's districts.
  • Historical Tracking: Stores weather data in a SQL database for history tracking.
  • District Search: Quickly find weather data by district name.
  • Current Metrics: View temperature, humidity, wind speed, and rainfall.
  • Weather History: Explore past weather trends in a clean tabular format.

πŸ”§ Prerequisites

Before you get started, ensure you have the following installed:

  • Java Development Kit (JDK): Version 11 or higher.
  • MySQL Database: Installed and configured locally.
  • Visual Studio Code: Recommended IDE, but feel free to use any Java-compatible IDE.
  • Dependencies:
    • org.json.JSONObject for parsing JSON from the weather API.
    • javax.swing for creating a user-friendly graphical interface.
    • MySQL Connector/J: Essential for database connectivity (included in the lib folder).

πŸ› οΈ Setup Instructions

Step 1: Clone the Repository

git clone https://github.com/your-username/KeralaWeatherApp.git
cd KeralaWeatherApp

Step 2: Set Up the Database

  1. Launch MySQL via command line or a GUI tool like MySQL Workbench.

  2. Create the weather_db database:

    CREATE DATABASE weather_db;
    USE weather_db;
  3. Create the weather_data table:

    CREATE TABLE weather_data (
        id INT PRIMARY KEY AUTO_INCREMENT,
        district VARCHAR(50),
        temperature DOUBLE,
        wind_speed DOUBLE,
        humidity DOUBLE,
        rain DOUBLE,
        timestamp TIMESTAMP DEFAULT CURRENT_TIMESTAMP
    );

Step 3: Configure Database Connection in Code

  1. Open src/KeralaWeatherApp.java.

  2. Update your database credentials in the connectToDatabase method:

    connection = DriverManager.getConnection("jdbc:mysql://localhost:3306/weather_db", "your_username", "your_password");

Step 4: Obtain and Set Up Weather API Access

  1. No sign up required for Open-Meteo or use another weather API that supports latitude-longitude data.
  2. Update the apiUrl in fetchWeatherData with your API endpoint and key, if necessary.

Step 5: Compile and Run the Application

Execute the following commands to get your app running:

javac -cp ".:lib/*" src/KeralaWeatherApp.java
java -cp ".:lib/*:src" KeralaWeatherApp

πŸ“š Usage

  1. Fetch All Districts' Weather: Click β€œFetch Weather for All Districts” to see real-time data.
  2. Search by District: Enter the district name and hit β€œSearch District” to retrieve weather info.
  3. View Weather History: Click β€œShow Weather History” for past weather data.
  4. Refresh Data: Click β€œRefresh” to update the weather for your selected district.

πŸ“‚ Project Structure

KeralaWeatherApp/
β”œβ”€β”€ src/
β”‚   └── KeralaWeatherApp.java    # Main application code
β”œβ”€β”€ lib/                         # Libraries (e.g., MySQL connector)
β”œβ”€β”€ elements/                    # Weather icons (sunny, cloudy, rainy)
└── README.md                    # Project README

πŸ“¦ Dependencies

  • JDK: For running Java applications.
  • MySQL JDBC Driver: Place the MySQL JDBC driver (e.g., mysql-connector-java) in the lib folder for database access.
  • org.json: For parsing JSON responses from the API.

🌟 Future Enhancements

  • Enable automatic data refresh at defined intervals.
  • Improve the user interface with weather icons and trends.
  • Add advanced search and filter options for historical data.

πŸ“ License

This project is licensed under the MIT License. See the LICENSE file for details.

About

🌦️ Kerala Weather Application is a Java desktop app that fetches, stores, and displays weather data for Kerala's districts. Leveraging the Open-Meteo API and MySQL database, it provides real-time weather information, historical data, and key metrics such as temperature, humidity, wind speed, and rainfall.

Topics

Resources

License

Stars

Watchers

Forks

Languages