Skip to content

A python cli application to tell the weather data of the given city while limiting each user for 20 weather details.

Notifications You must be signed in to change notification settings

daksh-patel-nitw/WeatherTracker

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 

Repository files navigation

WeatherGuard: Encrypted Access and Weather Data Fetching Tool

Setup Instructions

1. Install Dependencies

  • Navigate to the Code folder.
  • Run the following command to install the required dependencies:
    pip install -r requirements.txt
  • (Make sure Python is installed on your system)

2. Set Up OpenWeatherMap API Key

  • Open weather.py and add your API key in the first line between the quotes (''), which you can obtain from openweathermap.org.

3. Set Up MySQL Database

  • Log in to your MySQL database:
    mysql -u root -p
    Enter the password when prompted.
  • Create a new database:
    CREATE DATABASE python_app_cli;
  • Create a new user and grant privileges:
    
    CREATE USER 'weather_cli'@'localhost' IDENTIFIED BY 'password';
    GRANT ALL PRIVILEGES ON python_app_cli.* TO 'weather_cli'@'localhost';
    FLUSH PRIVILEGES;
    

4. Run the Application

  • In the Code Folder, open a terminal (cmd) and run:
    python main.py

Application Flow

  1. Login/Signup:
    • Enter userID and password to log in.
    • If you don't have an account, select 2 to sign up (name, password, unique userID, mobile, and security_phrase required).
  2. Password Reset:
    • If you've forgotten your password, select 3 to reset it using your userID and security phrase.
  3. User Interface After Login:
    After logging in, you’ll see the number of API calls left (out of 20) at the top.
    • View Profile: Displays your name, mobile number, and user ID.
    • Fetch Weather Data: Enter the city, state, and country to retrieve the weather data. This will be saved to the WEATHER_LOGS database.
    • View Logs: Shows previously viewed weather logs with timestamps.
    • Delete Logs: Allows you to delete specific logs using the row ID.
    • Log Out: Logs out and returns you to the login/signup section.

Validations

  • Unique User IDs: User IDs must be unique. If a userID already exists, you will be prompted to choose a new one.
  • Password Validation:
    • Password must be at least 8 characters long.
    • Must contain at least one lowercase letter, one uppercase letter, one digit, and one special symbol.
  • Mobile Number: Must be 10 digits long (Indian mobile number format).
  • Security Phrase: Used to reset your password. Both password and security phrase are hashed using SHA-256 before being stored.

API Call Limitation

  • Users can make a maximum of 20 API calls in a 24-hour period. Once the API call limit reaches 0, you will not be able to make further requests until the next 24-hour cycle.

Database Schema

1. USERS Table

Attribute Type Description
u_ID Varchar Stores the unique user ID of the user.
name Varchar Stores the user's name.
password Char Stores the hashed password (SHA-256).
mobile Varchar Stores the user's mobile number.
security_phrase Char Stores the hashed security phrase (SHA-256).

2. API_USAGE Table

Attribute Type Description
id Int Primary key to uniquely identify each record.
user_id Varchar Foreign key to the USERS table, linking each record to a specific user.
last_update Timestamp Stores the timestamp when the API call count resets (every 24 hours).
request_count Int Keeps track of the user's remaining API call count (maximum of 20 per 24 hours).

3. WEATHER_LOGS Table

Attribute Type Description
id Int Primary key, used to uniquely identify weather log records.
timestamp Datetime Timestamp when the API call was made.
location Varchar The city/state/country searched for weather information.
temperature Varchar Temperature in Celsius for the specified location.
humidity Varchar Humidity level for the specified location.
weather_conditions Varchar Weather conditions (e.g., cloudy, rainy, sunny) for the specified location.
wind_speed Varchar Wind speed for the specified location.
u_ID Varchar Foreign key to the USERS table, indicating which user made the request.

About

A python cli application to tell the weather data of the given city while limiting each user for 20 weather details.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages