This project is a real-time data processing system that monitors weather conditions for major metros in India and provides summarized insights using rollups and aggregates. The backend fetches weather data from the OpenWeatherMap API, processes it, and stores daily summaries in a database. Users can also set configurable thresholds for alerts based on weather conditions.
- Real-Time Weather Monitoring: The system continuously fetches weather data at configurable intervals (e.g., every 5 minutes) for cities like Delhi, Mumbai, Bangalore, and more.
- Daily Weather Summaries: Aggregates are generated daily, including average, maximum, and minimum temperatures, along with the dominant weather condition.
- Custom Alert Thresholds: Users can set temperature thresholds, and the system will trigger alerts if breached.
- Visualizations: The frontend, built with React.js, displays weather trends and alerts through interactive charts and data summaries.
- Backend: Java, Spring Boot
- Frontend: React.js
- Database: MySQL
- API: OpenWeatherMap API
- Visualization: Chart.js (for graphical data representation)
- Framework: Spring Boot for its scalability, flexibility, and ease of integration with MySQL and external APIs.
- API Integration: OpenWeatherMap API provides weather data that is fetched and processed by the backend every 5 minutes (or as configured).
- Data Processing: Temperatures are converted from Kelvin to Celsius (or Fahrenheit based on user preferences), and daily summaries are computed by aggregating data over time.
- Alerting: Alerts are set by users and triggered when real-time weather data exceeds configured thresholds.
- Persistence: MySQL is used for storing historical weather data, daily summaries, and user-configured thresholds.
- Framework: React.js was chosen for building an interactive and dynamic UI.
- Visualization: Chart.js is used to create weather data visualizations, including temperature trends and alerts.
- API Consumption: The frontend consumes RESTful APIs exposed by the backend to display real-time weather data and manage alerts.
-
Weather Data Retrieval:
- Retrieves weather data from the OpenWeatherMap API for multiple cities.
- Converts temperature from Kelvin to Celsius or Fahrenheit (based on user preference).
- Stores weather data in a MySQL database.
-
Data Aggregation:
- Generates daily summaries including:
- Average temperature
- Maximum temperature
- Minimum temperature
- Dominant weather condition (calculated using the most frequent condition during the day).
- Generates daily summaries including:
-
Alert System:
- Users can configure thresholds (e.g., alert if temperature exceeds 35°C).
- System continuously monitors weather conditions and triggers alerts when thresholds are breached.
-
API Endpoints:
/viz/{city}: Collects data for visualisation based on the average temperature of the city./setAlert: Sets alert configurations and checks against real-time data./weather: Provides daily weather summary.
-
Dashboard:
- Displays real-time and historical weather data.
- Uses Chart.js to visualize daily weather summaries (average, max, min temperatures).
-
Alert Configurations:
- User interface to set alert thresholds for temperature.
- Displays triggered alerts based on configured thresholds.
The MySQL database stores:
- Weather data (timestamp, temperature, condition, etc.)
- Daily summaries (average, max, min temperature, dominant condition)
- User-configured alert thresholds
- Java 11+
- Node.js (for React frontend)
- MySQL database
- OpenWeatherMap API key
-
Clone the repository:
git clone https://github.com/your-repository.git cd your-repository/backend -
Update the
application.propertiesfile with your MySQL credentials and OpenWeatherMap API key:spring.datasource.url=jdbc:mysql://localhost:3306/weather_db spring.datasource.username=root spring.datasource.password=yourpassword openweathermap.api.key=your_openweathermap_api_key
-
Build and run the backend application:
./mvnw spring-boot:run
-
Navigate to the frontend directory:
cd ../frontend -
Install dependencies:
npm install
-
Start the React application:
npm start
-
Create a MySQL database:
CREATE DATABASE weather_db;
-
The application will automatically create the required tables on startup.
-
System Setup:
- Ensure the application connects to the OpenWeatherMap API using the API key.
-
Weather Data Retrieval:
- Simulate API calls at intervals and ensure data is correctly fetched and parsed.
-
Temperature Conversion:
- Verify the system correctly converts temperatures from Kelvin to Celsius/Fahrenheit.
-
Daily Weather Summary:
- Test if daily summaries (average, max, min temperatures) are correctly computed.
-
Alert Thresholds:
- Set user-configurable thresholds and simulate threshold breaches to verify alerts.
- Configured a an alerting system using the JavaMailSender annotation which sends an email to a pre-existing email account whenever the user configured temperature threshold is breached in the respectively configured city.
- The credentials for the pre-exisiting :- email - [email protected] password - johndoe1234