This project is a web application for managing and tracking shipments. It includes a backend built with Django and a frontend built with React and Vite.
Before you begin, ensure you have the following installed on your machine:
- Python 3.8 or higher
- Node.js 14 or higher
- npm or yarn
- PostgreSQL (or any other database supported by Django)
-
Clone the repository:
git clone <repository-url> cd <repository-directory>/backend
-
Create and activate a virtual environment:
python -m venv venv source venv/bin/activate # On Windows use `venv\Scripts\activate`
-
Install the dependencies:
pip install -r requirements.txt
-
Set up the database:
Update the
DATABASES
setting inproject/settings.py
to configure your database.DATABASES = { 'default': { 'ENGINE': 'django.db.backends.postgresql', 'NAME': 'your_db_name', 'USER': 'your_db_user', 'PASSWORD': 'your_db_password', 'HOST': 'localhost', 'PORT': '5432', } }
-
Configure the
.env
file:Create a
.env
file in thebackend
directory and add the following environment variables:DB_ENGINE="django.db.backends.postgresql" # Local database configuration DATABASE_NAME="ITM_SDP_Assignment" DATABASE_USER="postgres" DATABASE_PWD="root" DATABASE_HOST="localhost" DATABASE_PORT="5432" ENV="development" ENVIRONMENT="development" WEBAPP_URL="http://localhost:3000" # Swagger IS_SWAGGER_ENABLED=true SWAGGER_ADMIN_LOGIN_ENABLED=true # Email Service DJANGO_EMAIL_BACKEND="django.core.mail.backends.smtp.EmailBackend" DJANGO_EMAIL_HOST="smtp.gmail.com" DJANGO_EMAIL_PORT=587 DJANGO_EMAIL_HOST_USER="your_email@gmail.com" DJANGO_EMAIL_HOST_PASSWORD="your_email_password"
The
DJANGO_EMAIL_HOST_USER
andDJANGO_EMAIL_HOST_PASSWORD
are mandatory for the email service to work. -
Run migrations:
python manage.py migrate
-
Create a superuser:
python manage.py createsuperuser
-
Collect static files: <-- Not Requiered when running the project Locally
python manage.py collectstatic
-
Navigate to the frontend directory:
cd <repository-directory>/client
-
Install the dependencies:
npm install # or yarn install
-
Create a
.env
file:Create a
.env
file in theclient
directory and add the following environment variables:VITE_API_BASE_URL=http://localhost:8000 VITE_WEBSOCKET_BASE_URL=ws://localhost:8000 VITE_WEBSOCKET_ENABLED=true
-
Start the backend server:
There are two ways to run the backend server:
-
Normal way:
cd <repository-directory>/backend source venv/bin/activate # On Windows use `venv\Scripts\activate` python manage.py runserver
-
With WebSocket support (for real-time shipment updates):
cd <repository-directory>/backend source venv/bin/activate # On Windows use `venv\Scripts\activate` uvicorn project.asgi:application --host 127.0.0.1 --port 8000
-
-
Start the frontend development server:
cd <repository-directory>/client npm run dev # or yarn dev
-
Access the application:
Open your browser and navigate to
http://localhost:3000
.
- Use the login form to authenticate with your email and password.
- Upon successful login, you will be redirected to the home page.
- Use the tracking search form to enter a tracking ID and view shipment details.
- Real-time updates can be enabled or disabled using the toggle button on the shipment detail page.
- Update notification preferences for email, SMS, and push notifications on the shipment detail page.
- Save changes to update your preferences.
- If a shipment delivery is missed, use the reschedule form to provide new delivery details and submit the request.
The client frontend does not perform actions such as creating customer accounts, creating shipment updates, or accepting/rejecting reschedules. These actions should be performed using the Django admin dashboard.
-
Creating Customer Accounts:
- Navigate to the Django admin dashboard at
http://localhost:8000/admin/
. - Log in with your superuser credentials.
- Use the interface to create new customer accounts.
- Navigate to the Django admin dashboard at
-
Creating Shipment Updates:
- Use the Django admin dashboard to create and manage shipment updates.
-
Accepting or Rejecting Reschedules:
- Use the Django admin dashboard to review and manage reschedule requests.
The API documentation is available at the following endpoints:
- Swagger UI:
http://localhost:8000/swagger/schema/
- Redoc:
http://localhost:8000/redoc/
These endpoints provide detailed information about the available API endpoints and their usage.
This project is licensed under the MIT License.