This project is a proof of concept (POC) for managing climate data. It provides endpoints for saving, retrieving, and calculating climate data deltas for different climate conditions and areas. The system uses Node.js and MongoDB for data storage.
This Is the Example of API Call Click Here
Follow the instructions below to set up and run the climate data management system on your local machine.
- Node.js: Download and install Node.js from https://nodejs.org/.
- MongoDB: Download and install MongoDB from https://www.mongodb.com/try/download/community.
- Clone this repository to your local machine:
git clone https://github.com/Anishkumardiwan/climate_data_managment_system;
- Navigate to the project directory:
cd climate_data_management_system
- Install the project dependencies:
npm install
- Start the server. You can usually do this by running:
npm start
- Add .env file and Declare the variable:
PORT
MONGODBURL
The server will start and listen on port 5000 or Decleare the process.env.PORT in .env file.
To save climate data, make a POST request to the /api/climate
endpoint with the following payload:
{
"climate": "hot",
"area_code": 111,
"temperature": 25,
"humidity": 88,
"chances_of_rain": 40
}
To fetch all saved climate records, make a GET request to the /api/climate
endpoint.
To fetch climate records for a specific area, make a GET request to the /api/climate/:areaCode
endpoint, where :areaCode
should be replaced with the desired area code.
To fetch climate records for a specific climate in a particular area, make a GET request to the /api/climate/:areaCode/:climate
endpoint, where :areaCode
is the area code, and :climate
is one of the climate types (hot,
humid, rainy, or cold).
To calculate climate data delta, make a POST request to the /api/climate/delta
endpoint with the following payload:
{
"from_climate": "hot",
"to_climate": "cold",
"area_code": 111
}
The API returns responses in JSON format with the following structure:
{
"success": true/false,
"error": "If success is false, this will be set, else it will be null and its value would be the reason why the saving of data failed",
"data": {
// Data or result here
}
}
Proper error handling is implemented in the endpoints to handle various scenarios, including validation errors and data not found errors.
Contributions are welcome! If you'd like to contribute to this project, please open an issue or submit a pull request.
This project is licensed under the MIT License - see the LICENSE file for details.