comp433-ecommerce

This project used both Apache cxf and Spring.

UML - Class Diagram

Our UML Model shown below features classes that include information on various aspects of the web service, such as the Users, the Items, and the Partner from which the items come from. Our main source of inspiration when creating this model was in strong relation to Amazon.

Note: UML Model expected to expand in complexity as our group progesses through the projects moving forward.

Users: personal information, payment information, address, status of membership, access to adding/deleting from their cart

Cart: items, shipping details, purchase date

Partner: id, name

Inventory: items

Additionally, we have added classes to cover the scenario of an item being returned or an order being canceled.

Updated UML

Tables

State Diagram

API Documentation

API Reference Contents Customer_POST

  • Updates a customer in the database, but can also be used to create the customer if said customer is not already in the database.

    Resource URL

    http://localhost:8080/services/userdata/users

    Example Request

    POST http://localhost:8080/services/userdata/users

    Example Body
   { 
   "userData":{ 
      "userName":"Shailendra",
      "dateOfBirth":"2012-04-23T18:25:43.511Z",
      "primeMember":true,
      "paymentDetails":[ 
         { 
            "cardNumber":"74959454960",
            "cardType":"CREDIT",
            "cardCategory":"VISA",
            "expiryDate":"2020-04-23"
         }
      ]
   }
}

Example Response

  {
    "headers": {},
    "body": {
        "links": [
            {
                "action": "view",
                "url": "http://localhost:8080/services/userdata/users/1575849321320"
            }
        ],
        "userId": "1575849321320",
        "userName": "Shailendra",
        "dateOfBirth": 1335205543511,
        "primeMember": true
    },
    "statusCode": "CREATED"
  }

Customer_GET

  • Retrieves a customer's information.

    Resource URL

    http://localhost:8080/services/userdata/users/1575945796575

    Example Request

    GET http://localhost:8080/services/userdata/users/1575945796575

    Example Response
{
    "headers": {},
    "body": {
        "links": null,
        "userId": "1575945796575",
        "userName": "Shailendra",
        "dateOfBirth": 1335205544000,
        "primeMember": true
    },
    "statusCode": "ACCEPTED"
}

Product_POST

  • Creates/Updates a product in the database.

    Resource URL

    http://localhost:8080/services/product/products

    Example Request

    POST http://localhost:8080/services/product/products

    Example Body
{ 
   "products":[{ 
      "item_category":"Electronics",
      "item_price":27.5,
      "item_quantity_available":10,
      "item_name":"Hello Product",
      "item_description": "Electonics item",
      "item_sold_by": "Partner1",
      "item_review":3.5
   }]
}

Example Response

{
    "headers": {},
    "body": "products added successfully",
    "statusCode": "CREATED"
}

Product_GET

  • Retrieves a product's information.

    Resource URL

    http://localhost:8080/services/product/products/1

    Example Request

    GET http://localhost:8080/services/product/products/1

    Example Response
{
    "headers": {},
    "body": {
        "links": [
            {
                "action": "buy",
                "url": "http://localhost:8080/services/order/orders"
            }
        ],
        "item_id": 1,
        "item_category": "Electronics",
        "item_price": 27.5,
        "item_quantity_available": 10,
        "item_review": 0.0
    },
    "statusCode": "ACCEPTED"
}

Order_POST

  • Creates/Updates an order in the database.

    Resource URL

    http://localhost:8080/services/order/orders

    Example Request

    POST http://localhost:8080/services/order/orders

    Example Body
{ 
   "orderDetails":{ 
      "purchaseDate":"2019-09-23T18:25:43.511Z",
      "orderStatus":"Order Placed",
      "items":[ 
         { 
            "item_id":"item 2",
            "quantity":2
         }
      ],
      "user":{ 
      	 "userId":"1575946565145"
         
      }
   },
   "paymentDetails": 
      { 
         "cardNumber":"74959454959",
         "cardType":"CREDIT",
         "cardCategory":"VISA",
         "expiryDate":"2020-04-23"
      }
   
}

Example Response

{
    "headers": {},
    "body": {
        "links": [
            {
                "action": "order status",
                "url": "http://localhost:8080/services/order/orders/1575947108322"
            }
        ],
        "cartId": "1575947108322"
    },
    "statusCode": "CREATED"
}

Order_GET

  • Retrieves Order data from database.

    Resource URL

    http://localhost:8080/services/order/orders/1575947108322

    Example Request

    GET http://localhost:8080/services/order/orders/1575947108322

    Example Response
{
    "headers": {},
    "body": {
        "cartId": "1575947108322",
        "itemsSold": [
            {
                "item_id": "item 2",
                "quantity": 2
            }
        ],
        "orderStatus": "Order Placed"
    },
    "statusCode": "ACCEPTED"
}

Ship_POST

  • Creates a shipping status in the database for tracking delivery.

    Resource URL

    http://localhost:8080/services/ship/shippingData

    Example Request

    POST http://localhost:8080/services/ship/shippingData/

    Example Body
{ 
   "shippingDetails":{ 
      "shippingStatus":"shipped",
      "shippedBy":"USPS",
      "cart":{ 
      	 "cartId":"1575947108322"
         
      }
   }
}

Example Response

{
    "headers": {},
    "body": {
        "links": [
            {
                "action": "ship_status",
                "url": "http://localhost:8080/services/ship/shippingData/15759483146621575947108322"
            }
        ],
        "trackingNumber": "15759483146621575947108322"
    },
    "statusCode": "CREATED"
}

Ship_GET

  • Retrieves the shipping status of an order from the database.

    Resource URL

    http://localhost:8080/services/ship/shippingData/15720363515651572036341594

    Example Request

    GET http://localhost:8080/services/ship/shippingData/15720363515651572036341594

    Example Response
{
    "headers": {},
    "body": "shipped",
    "statusCode": "ACCEPTED"
}

Configuration details

  1. CXF configuration are at /webapp/WEB_INF/apache-cxf-services.xml
  2. Spring configuration is at /webapp/WEB_INF/ApplicationContext.xml
  3. DataSource configuration is done in ApplicationContext.xml
  4. Hibernate ORM is used for db connectivity and data modeling