A Python-based application that fetches real-time weather data for selected cities using the OpenWeather API, visualizes the weather information, and stores the data in an AWS S3 bucket in JSON format.
- Fetches current weather data including temperature, humidity, and weather description for selected cities.
- Automatically creates an S3 bucket (if not exists) to store weather data in JSON format.
- Visualization Feature(add-on): Displays the fetched weather data as charts/graphs (e.g., temperature comparison).
- Python 3.x: Core application language.
- boto3: AWS SDK for Python to interact with Amazon S3.
- requests: For making HTTP requests to the OpenWeather API.
- python-dotenv: For securely loading environment variables.
- matplotlib: For visualizing weather data through charts/graphs.
- AWS S3: Cloud storage for weather data.
├── weather_dashboard.py # Main Python script for the application
├── requirements.txt # Python dependencies file
├── .env # Environment variables file (not committed to source control)
└── README.md # Documentation for the project
Follow these steps to set up and run the project:
cd
It’s recommended to use a virtual environment to manage dependencies:
python -m venv _your_virtual_environment_name_
source _your_virtual_environment_name_\Scripts\activate
Install the required Python libraries using pip:
Here is the list of Python libraries used in your project, based on the script and explanation provided. This can be included in your requirements.txt file:
boto3: For interacting with AWS services (like S3).requests: For making HTTP requests to the OpenWeather API.python-dotenv: For securely loading environment variables from a.envfile.matplotlib: For visualizing weather data as charts or graphs (optional, based on the visualization feature).urllib3: (Optional dependency ofboto3andrequests, typically included automatically).
pip install -r requirements.txt
boto3==1.26.137 python-dotenv==1.0.0 requests==2.28.2 matplotlib==3.10.0 pandas==2.2.3
- Create a
.envfile in the project directory. - Add the following keys and values to your
.envfile:
OPENWEATHER_API_KEY=your_openweather_api_key_here AWS_BUCKET_NAME=your_s3_bucket_name_here
Replace the placeholders (your_openweather_api_key_here, etc.) with your actual API key and AWS credentials.
Note: Never share your .env file or commit it to version control (e.g., GitHub).
Set up your AWS environement with aws configure and input your required access key, secret access key, region output format.
Run the script from your terminal:
python weather_dashboard.py
The application will:
- Check if the specified S3 bucket exists, and create it if not.
- Fetch weather data for the selected cities (hardcoded in the script, e.g., Accra, Lagos, Johannesburg).
- Visualize the weather data in the form of charts/graphs (e.g., comparing temperatures across different cities).
- Print the weather data to the console.
- Save the weather data to the S3 bucket in JSON format, with a timestamp.
As an additional (non-challenge) feature, I included the feature to visualise the weather data stored as json in s3.
Using the matplotlib library, the code in interactive-visualisation.py displays:
the json data in a tabular form
allows you to select the metric to visualize
toggle between the your chart type preference (currently only bar chart and line graph are available)
To view the above run streamlit run interactive-visualisation.py, this should open your visualisation in your default browser automatically. If not you can click on the urls that will be provided in the output to display the visualisation.

