The Load Management System is a backend API designed to streamline and automate the management of freight and cargo loads within a logistics environment. The primary objective of this system is to provide an efficient and organized way to handle information related to the transportation of goods, catering to the specific needs of shippers and logistics professionals.
- Java (JDK) installed
- Maven installed
- PostgresSQL installed (if applicable)
- Clone the repository:
git clone https://github.com/AryanKumar36/AryanKumar36-Assignment_1_Liveasy
- Navigate to the project directory:
cd AryanKumar36-Assignment_1_Liveasy
- Build the project:
mvn clean install
-
Create a Database and Load Table:
- Open a PostgreSQL client, such as
psql
or pgAdmin, and create a new database (liveasyDb
). Then, create the 'load' table using the following SQL command:
-- Create the 'load' table CREATE TABLE load ( id SERIAL PRIMARY KEY, loading_point VARCHAR(255), unloading_point VARCHAR(255), product_type VARCHAR(255), truck_type VARCHAR(255), no_of_trucks INTEGER, weight DOUBLE PRECISION, comment TEXT, shipper_id VARCHAR(255), date DATE );
- Insert sample data into the 'load' table using the following SQL commands:
-- Insert sample data INSERT INTO load (loading_point, unloading_point, product_type, truck_type, no_of_trucks, weight, comment, shipper_id, date) VALUES ('Delhi', 'Jaipur', 'Chemicals', 'Canter', 1, 100, '', 'shipper:123', '2023-01-01'), ('Mumbai', 'Bangalore', 'Electronics', 'Truck', 2, 200, 'Fragile items', 'shipper:456', '2023-02-15'), ('Kolkata', 'Chennai', 'Textiles', 'Lorry', 3, 150, 'Urgent delivery', 'shipper:789', '2023-03-20');
- Open a PostgreSQL client, such as
-
Update application.properties:
- Update
spring.datasource.url
with your PostgreSQL JDBC URL. - Update
spring.datasource.username
andspring.datasource.password
with your PostgreSQL credentials.
spring.datasource.url=jdbc:postgresql://localhost:5432/liveasyDb spring.datasource.username=your_postgres_username spring.datasource.password=your_postgres_password
- Update
- Run the application:
mvn spring-boot:run
- All endpoints are relative to the base URL:
http://localhost:8080
(Adjust accordingly)
- Endpoint:
GET /load
- Description: Retrieve a list of all loads.
- Example Request:
http://localhost:8080/load
[
{
"id": "Id",
"loadingPoint": "LoadingPoint",
"unloadingPoint": "UnloadingPoint",
"productType": "Type of product",
"truckType": "VehicleType",
"noOfTrucks": "No. of trucks",
"weight": "weight",
"comment": "comment",
"shipperId": "ShipperId",
"date": "DD-MM-YYYY"
},
// Additional load objects...
]
- Endpoint:
GET /load/{id}
- Description: Retrieve details of a specific load by its ID.
- Example Request:
http://localhost:8080/load/{id}
{
"id": "Id",
"loadingPoint": "LoadingPoint",
"unloadingPoint": "UnloadingPoint",
"productType": "Type of product",
"truckType": "VehicleType",
"noOfTrucks": "No. of trucks",
"weight": "weight",
"comment": "comment",
"shipperId": "ShipperId",
"date": "DD-MM-YYYY"
}
- Endpoint:
GET /load
- Description: Retrieve a list of loads associated with a specific shipper using their Shipper ID.
- Example Request:
http://localhost:8080/load?shipperId=shipper:456
[
{
"id": "Id1",
"loadingPoint": "LoadingPoint1",
"unloadingPoint": "UnloadingPoint1",
"productType": "Type of product1",
"truckType": "VehicleType1",
"noOfTrucks": "No. of trucks1",
"weight": "weight1",
"comment": "comment1",
"shipperId": "shipper:456",
"date": "DD-MM-YYYY1"
},
// Additional load objects...
]
- Endpoint:
POST /load
- Description: Save details of a new load.
- Example Request:
POST http://localhost:8080/load
load
(body, required): The load details to be saved.
{
"id": "NewId",
"loadingPoint": "NewLoadingPoint",
"unloadingPoint": "NewUnloadingPoint",
"productType": "NewTypeOfProduct",
"truckType": "NewVehicleType",
"noOfTrucks": 3,
"weight": 300.0,
"comment": "NewComment",
"shipperId": "shipper:789",
"date": "DD-MM-YYYY"
}
"loads details added successfully"
- Endpoint:
PUT /load/{loadId}
- Description: Update details of an existing load.
- Example Request:
PUT http://localhost:8080/load/1
loadId
(path, required): The ID of the load to be updated.
updatedLoad
(body, required): The updated load details.
{
"id": 1,
"loadingPoint": "UpdatedLoadingPoint",
"unloadingPoint": "UpdatedUnloadingPoint",
"productType": "UpdatedTypeOfProduct",
"truckType": "UpdatedVehicleType",
"noOfTrucks": 4,
"weight": 400.0,
"comment": "UpdatedComment",
"shipperId": "shipper:123",
"date": "DD-MM-YYYY"
}
{
"id": 1,
"loadingPoint": "UpdatedLoadingPoint",
"unloadingPoint": "UpdatedUnloadingPoint",
"productType": "UpdatedTypeOfProduct",
"truckType": "UpdatedVehicleType",
"noOfTrucks": 4,
"weight": 400.0,
"comment": "UpdatedComment",
"shipperId": "shipper:123",
"date": "DD-MM-YYYY"
}
- Endpoint:
DELETE /load/{loadId}
- Description: Delete details of a specific load by its ID.
- Example Request:
DELETE http://localhost:8080/load/1
loadId
(path, required): The ID of the load to be deleted.
{
"message": "Deleted the load with id :: 1"
}