This Django project is designed to provide end-users with the ability to track shipments and obtain current weather conditions at their specified location. It offers a RESTful API for retrieving shipment details and weather data based on tracking numbers and carriers. The project integrates with a weather API service to fetch weather information and caches it to minimize API calls.
-
Retrieve Shipments: Users can query shipments based on tracking numbers or carrier names.
-
Shipment Details: The API provides shipment details such as tracking number, carrier, sender and receiver addresses, article information (name, quantity, price, SKU), and shipment status.
-
Automated Weather Integration: Weather data for the receiver's location (determined by zip code) is automatically integrated into the shipment data.
-
Current Weather Data: The system fetches current weather conditions from an external weather API (Weatherbit) based on the receiver's zip code.
-
Weather Data Caching: To minimize API calls and reduce response times, weather data is cached. Weather information for the same location (zip code) is refreshed at most every 2 hours.
The project includes the following data models:
-
Shipment Model: Stores shipment information, including tracking number, carrier, sender and receiver addresses, article details, SKU, and status.
-
Weather data: Stores weather information in Redis cache.
Clone the project repository to your local machine:
git clone https://github.com/shirani98/shipment_tracker.git
- Create a .env file in the project's root directory.
- Add your Weather API Key to the .env file as follows:
WEATHER_API_KEY=your_weather_api_key_here
Replace your_weather_api_key_here with your actual Weather API Key.
Create and activate a virtual environment (optional but recommended):
python -m venv venv
source venv/bin/activate
Install project dependencies:
pip install -r requirements.txt
Ensure that Redis is installed and running on your system. Update the CACHES settings in settings.py to point to your Redis instance.
Apply database migrations:
python manage.py migrate
Start the Django development server:
python manage.py runserver
The project will be accessible at http://localhost:8000.
- Retrieve shipments by tracking number or carrier: GET /api/shipments/?tracking_number=TN12345678
- Retrieve shipments by carrier: GET /api/shipments/?carrier=DHL