Skip to content

TahsinAnwarAkif/weather-forecast

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

22 Commits
 
 
 
 
 
 

Repository files navigation

Weather Checking Service

Table of contents

General info

A simple weather checking API service.

Technologies

  • Java 1.8
  • Spring Boot 2.4.3
  • MySQL 5

Functionalities

Case User Story
Search for today's weather of a specific city As an API consumer, one should be able to search for today's weather by inputting the city name.
Get historical weather data by ID As an API consumer, one should be able to look for weather data from past periods
Get historical saved weather data by city AND/OR Generation Date As an API consumer, one should be able to look for earlier saved weather data for a specific city with/without mentioning Generation Date
Get latest saved weather data by city As an API consumer, one should be able to look for the latest saved weather data for a specific city
Save weather data As an API consumer, one should be able to save weather data for retrieval
Save current weather data for a specific city As an API consumer, one should be able to save directly the current weather data for a specific city for later retrieval
Update historical weather data As an API consumer, one should be able to update an existing weather record
Delete historical weather data As an API consumer, one should be able to delete an existing weather record
Able to ensure existing functionality is working This design ensures that any changes to the retrieved JSON object from API won't break existing functionality

Weather API Provider

https://openweathermap.org/current

Access current weather data for any location on Earth including over 200,000 cities! We collect and process weather data from different sources such as global and local weather models, satellites, radars and vast network of weather stations. Data is available in JSON, XML, or HTML format.

Instructions on Using Application

  1. Run the queries in pre-ddl.sql, dml.sql in this mentioned order in MySQL. Follow DB credentials specified in application.properties.
  2. Run the queries in pre-ddl.sql, dml.sql in this mentioned order.
  3. Run the project in your IDE.

Functionality Documentation

  1. Use /getCurrentWeather?city={city} [GET] to find the latest weather of a city. city is a required parameter here.
  2. Use /getSavedWeather?id={id} [GET] to find a saved weather entry by id. id is a required parameter here, specifying the DB id of that record. [GET
  3. Use /getSavedWeatherList?city={city} [GET] to find all saved weather entries of a particular city. city is a required parameter here.
  4. Use /getSavedWeatherList?city={city}&created={created} [GET] to find all saved weather entries of a particular city, on a particular date, created. It's just a variation of the previous URL.
  5. Use /getLatestSavedWeather?city={city} [GET] to find the latest saved weather entry for a specific city. city is required.
  6. Use /saveWeather [POST] to save an inputted weather entry (as request body) upon validation. The fields' specifications are given below -
   {
   "coord": {
        "lat":  Double [non-empty, minValue = -90, maxValue = 90],
        "lang"/"lon": Double [non-empty, minValue = -180, maxValue = 180]
   },
   
   "weatherSummaryList"/"weather": [
   {
         "id": long [if it is provided, then the rest fields should remain empty],
         "summary"/"main": String [non-empty if id not given, minLength = 1, maxLength = 255],
         "description": String [non-empty if id not given, minLength = 1, maxLength = 1024],
         "icon": String [non-empty if id not given, minLength = 7, maxLength = 7, should match this pattern: **[A-Za-z0-9]{3}.png$**, e.g. _01n.png_]
   }
   ...
   ],
   
   "weatherDetail"/"main": {
         "temperature"/"temp": Double [non-empty],
         "feelsLike"/"feels_like": Double [non-empty],
         "minTemperature"/"temp_min": Double [non-empty],
         "maxTemperature"/"temp_max": Double [non-empty],
         "pressure": Integer [non-empty],
         "humidity": Integer [non-empty, minValue = 0, maxValue = 100],
         "seaLevel"/"sea_level": Integer [optional],
         "groundLevel"/"grnd_level": Integer [optional]
   },
   
   "wind": {
         "speed": Double [non-empty],
         "degree"/"deg": Integer [non-empty, minValue = 0, maxValue = 360],
         "gust": Double [optional]
   },
   
   "cloud": {
         "cloudiness"/"all": Integer [non-empty, minValue = 0, maxValue = 100]
   },
   
   "rain": {
        "volumeInLastHr"/"1h": Double [optional],
        "volumeInLast3Hrs"/"3h": Double [optional]
   },
   
   "snow": {
        "volumeInLastHr"/"1h": Double [optional],
        "volumeInLast3Hrs"/"3h": Double [optional]
   },
   
   "name": String [non-empty, minLength = 1, maxLength = 255],
   
   "timezone": Long [non-empty]
   }
  1. Use /saveCurrentWeather?city={city} [POST] to save the current weather of a specific city directly to the system. No request body is needed to save here, provide the city only!
  2. Use /updateWeather?id={id} [PUT] to update a saved weather entry upon validation. id is required here. Moreover, the request body like the above structure should be given too.
  3. Use /deleteWeather?id={id} [DELETE] to delete a saved weather entry.

Future Enhancements

  1. Will add User Registration and Authentication such that one can register in our system, then use the aforementioned functionalities based on his/her accessibility. That is, if a weather data is not created by him/her, s/he cannot access (read/save/update) it.
  2. For the update action, a user has to input all the fields currently. Will develop a handler such that, user only needs to input one or more fields (with id in request parameter surely), and only those fields would be updated in the existing object, the rest would remain the same.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages