Weather Alert & Assistance

mukeshaec

mukesh-aec

Posted on November 9, 2020

Weather Alert & Assistance

Everyday is an API day

Welcome to weather alert application inspired by the mulesoft integration platform which provides an easy way to integrate multiple APIs, call in parallel, Apply transformation and aggregate the result to expose as a single API.
While going for outdoor activities or outside travel, knowing weather conditions is a must. Sometimes we gone through sudden weather changes which put us in trouble. Getting assistance is very difficult in unfavorable situation whether the place is known or unknown. No worry this application has been designed to Keep in mind to provide help whenever you need . 

Alt Text

What is weather, Air quality and weather-alert Api?

There are various APIs are available that provide weather information & Air quality level. These APIs are available in a rest or Soap format but it's in bits and pieces.

openweathermap provides essential weather parameters such as temperature, precipitation, probability of precipitation, humidity, feels like, pressure, cloudiness, wind, etc.

aircheckr provides the available outside air quality information of the particular location.

weather-alert provides the recommendation based on outside available air quality and weather information. This application, runs a custom algorithm to derive recommendations based on the permissible limit of human life. It also allow user to send an alert at the time when situation is not in his favor and need help. Alert response includes message, weather condition and current location of the needy people.
     > For visualization and demonstration purposes web UI has been used. In real implementation it would be a mobile application. User location will be auto detected and alert generated in abnormal situation.

About the mule-weather-alert application

Alt Text

In this application we have collected information from various sources of(Weather & Air) API and run a custom algorithm to provide weather & Air recommendation.
Weather & Air provides information like temperature, visibility, humidity, wind speed, direction and air quality. By applying a custom algorithm we calculate heat index, wind index, Recommendation(Non-Sensitive Group) and Recommendation(Sensitive Group). All calculations are based on current location or provided location(by latitude and longitude).
It also has the capability to send an alert or notification to your near and dear when you are in trouble and you are seeking for a help.
In an alert response we  send custom messages, weather information and geo location so that you would get assistance as soon as possible. Geo location helps to traverse exact locations on map and and surrounding weather information. It helps to understand the kind of help you need. Rescuer can prepare a better plan using this information.

1. API Specification (RAML)

/weather-app:
/get-weather-data:
This end point is used to forecast weather information by clubbing weather and Air quality api. Latitude and longitude of current and provided location received in request. The response includes details of temperature, visibility, humidity, wind speed, direction and air quality. Based on our analysis calculate heat index, wind index, Recommendation(Non-Sensitive Group) and Recommendation(Sensitive Group)

/weather-app:
/send-email-alert:
This end point is used to send an alert. When we come to know that our surrounding weather is not appropriate and we need help from our loved ones. API receives message & email of the person to be notified and detects the coordinate of your location  and sends the alert. email details and message receive in request and alert sends with message, current weather information and google link of the location. confirmation message send as a response.

#%RAML 1.0
baseUri: https://anypoint.mulesoft.com/mocking/api/v1/links/65f94373-f769-4504-89e5-67ac9da63ede/ # 
title: weather-alert-specification
types:
  alert:
    type: Alert
  Alert:
    properties:
      email: string
      message: string

/weather-app:
  /get-weather-data:
    get:
      description: This end point is used to forecast weather information by clubbing weather and Air api. Latitude and longitude of current and provided location received in request. The  response includes details of temperature, visibility, humidity, wind speed, direction and air quality. Based on our analysis calculate heat index, wind index, Recommendation(Non-Sensitive Group) and Recommendation(Sensitive Group)
      queryParameters:
        latitude:
          type: string
          example: "51.5052986145"
        longitude:
          type: string
          example: "0.0552779995"
      responses:
        200:
          body:
            application/json:

              example: !include examples/weather-api-response.raml
  /send-email-alert:
    post:
      description: This end point is used to send an alert. When we come to know that our surrounding weather is not appropriate and we need help from our loved ones. API receives message & email of the person to be notified and detects the coordinate of your location  and sends the alert. email details and message receive in request and alert sends with message, current weather information and google link of the location. confirmation message send as a response.
      body:
        application/json:
          type: alert
          example: !include examples/alert-request.raml

      responses:
        201:
          body:
            application/json:
              example:
                {
                "response": "Alert sent successfully"
                }



Enter fullscreen mode Exit fullscreen mode

2. API Implementation (Mule application)

Home page : A html web page where either we can provide a location as latitude and longitude and submit button Use This Location or Use Current Location for auto detect current location

Alt Text

get-weather-data : A mule flow receive GET request with query parameter latitude and longitude. Based on latitude and longitude weather and Air quality has been called. weather and Air quality information send as a json object in response. Web page show the detail data.

Alt Text

send-email-alert : A mule flow is being trigger as a POST with payload having email id and message to be sent to the notified person with the location of the notifier.

Alt Text

**Note** : Update email user name and password in configuration file.

3. Test application

CloudHub URL :Home page
Note

  1. For quick demo use latitude:51.5052986145 & longitude :0.0552779995
  2. If you face issue when use current location, use work around given here Enable the unsecure origin

**Home page**

Alt Text


**Weather detail page**

Alt Text

**Alert page**

Alt Text

**Email detail**

Alt Text


Color visualization

Alt Text

4. References and Code

Source code refrence
Clone

Asset (RAML) refrence

5. About the author

Mukesh Thakur worked as a solution Architect at Persistent System Ltd. He is a hands on Technology evangelist & Integration Architect with expertise in conceptualizing and implementing end to end solutions. He has the right blend of Developer, Architecture, Technology Consulting, agile practitioner and diverse cultural experiences gained through the implementation experiences across complex Integration roll outs around the globe. He also leads Pune MuleSoft Meetup and loves to speak in various meetup events.
Email me: mukesh.aec@gmail.com
LinkedIn: https://www.linkedin.com/in/mukesh-thakur-3b9720a/
DZone: https://dzone.com/users/3365003/mukeshaec.html

💖 💪 🙅 🚩
mukeshaec
mukesh-aec

Posted on November 9, 2020

Join Our Newsletter. No Spam, Only the good stuff.

Sign up to receive the latest update from our blog.

Related

Weather Alert & Assistance
mulesofthackathon Weather Alert & Assistance

November 9, 2020