Skip to content

sekharkaredla/springboot-backend

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

15 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Description

A simple and sophisticated demonstration of backend services development using Spring Boot.

Author

Anantha Sashi Sekhar Karedla

Features implemented

  • Basic CRUD Functionality.
  • Filtering based on fields/inventory count/tags/other metadata.

How to run the services

  1. Goto the res/jar folder.
  2. Download apis.jar.
  3. Make sure you have Java SE 11 or OpenJDK 11 installed on your system.

The below command will start the Spring web services on localhost 8080 port

java -jar apis.jar

Incase your 8080 port is busy, use the below command to run it on a different port.

java -jar apis.jar --server.port=8081

Looks like this:-

  1. how_to_run
  2. how_to_run 2

After running the services

Goto http://localhost:8080/swagger-ui.html and click on item-controller.

Direct link to item-controller.

Some example runs (Basic CRUD)

  1. Creating few items using the /item POST API.

looks like this :-

create

  1. Getting all Items using the /item GET API.
[
  {
    "item": {
      "id": "902a455a-e165-4a6a-9449-d1ccd64ce258",
      "itemName": "avgPhone",
      "itemType": "phone",
      "manufacturingCompany": "banana",
      "manufacturingDate": "2022-01-04T02:02:10.466+00:00",
      "tags": [
        "electronic",
        "cheap"
      ]
    }
  },
  {
    "item": {
      "id": "4e0e0257-e5f1-47a6-a1f5-9c891847b0cb",
      "itemName": "heavyCotton",
      "itemType": "cloth",
      "manufacturingCompany": "farmer",
      "manufacturingDate": "2022-01-01T02:02:10.466+00:00",
      "tags": [
        "country",
        "cheap"
      ]
    }
  },
  {
    "item": {
      "id": "bcd22922-3b03-4a99-b56a-e3fb27da7224",
      "itemName": "avgPhone",
      "itemType": "phone",
      "manufacturingCompany": "orange",
      "manufacturingDate": "2022-01-05T02:02:10.466+00:00",
      "tags": [
        "electronic",
        "costly"
      ]
    }
  },
  {
    "item": {
      "id": "0c2ac0a1-5675-436f-8f5c-a7cbda88b78c",
      "itemName": "tinyPhone",
      "itemType": "phone",
      "manufacturingCompany": "banana",
      "manufacturingDate": "2022-01-05T02:02:10.466+00:00",
      "tags": [
        "electronic",
        "cheap"
      ]
    }
  }
]
  1. Getting an individual item using the /item/{itemId} GET API.

looks like this:-

get

  1. Updating an item using the /item/{itemId} PUT API. Adding an extra tag "broken" to the item.

looks like this:-

put

  1. Deleting an item using the /item/{itemId} DELETE API. Deleting the item which was updated above.

looks like this:-

delete

Fun with filters

  1. filter based on manufacturing company
request URL : http://localhost:8080/item?company=banana

response:

[
  {
    "item": {
      "id": "aa1fa3c7-6adb-4a2a-be93-5bccb1f123ba",
      "itemName": "slowPc",
      "itemType": "laptop",
      "manufacturingCompany": "banana",
      "manufacturingDate": "2021-01-01T02:02:10.466+00:00",
      "tags": [
        "costly",
        "not_worth"
      ]
    }
  },
  {
    "item": {
      "id": "902a455a-e165-4a6a-9449-d1ccd64ce258",
      "itemName": "avgPhone",
      "itemType": "phone",
      "manufacturingCompany": "banana",
      "manufacturingDate": "2022-01-04T02:02:10.466+00:00",
      "tags": [
        "electronic",
        "cheap"
      ]
    }
  }
]
  1. filter based on manufacturing company and item type
request URL : http://localhost:8080/item?type=phone&company=banana

response:

[
  {
    "item": {
      "id": "902a455a-e165-4a6a-9449-d1ccd64ce258",
      "itemName": "avgPhone",
      "itemType": "phone",
      "manufacturingCompany": "banana",
      "manufacturingDate": "2022-01-04T02:02:10.466+00:00",
      "tags": [
        "electronic",
        "cheap"
      ]
    }
  }
]
request URL : http://localhost:8080/item?type=laptop&company=banana

response:

[
  {
    "item": {
      "id": "aa1fa3c7-6adb-4a2a-be93-5bccb1f123ba",
      "itemName": "slowPc",
      "itemType": "laptop",
      "manufacturingCompany": "banana",
      "manufacturingDate": "2021-01-01T02:02:10.466+00:00",
      "tags": [
        "costly",
        "not_worth"
      ]
    }
  }
]
  1. Single tag filter
request URL : http://localhost:8080/item?tags=electronic

response:

[
  {
    "item": {
      "id": "902a455a-e165-4a6a-9449-d1ccd64ce258",
      "itemName": "avgPhone",
      "itemType": "phone",
      "manufacturingCompany": "banana",
      "manufacturingDate": "2022-01-04T02:02:10.466+00:00",
      "tags": [
        "electronic",
        "cheap"
      ]
    }
  },
  {
    "item": {
      "id": "bcd22922-3b03-4a99-b56a-e3fb27da7224",
      "itemName": "avgPhone",
      "itemType": "phone",
      "manufacturingCompany": "orange",
      "manufacturingDate": "2022-01-05T02:02:10.466+00:00",
      "tags": [
        "electronic",
        "costly"
      ]
    }
  },
  {
    "item": {
      "id": "6d327c94-d25e-4814-8ab0-d969a9bb135e",
      "itemName": "tinyPC",
      "itemType": "laptop",
      "manufacturingCompany": "mango",
      "manufacturingDate": "2021-10-01T02:02:10.466+00:00",
      "tags": [
        "cheap",
        "electronic"
      ]
    }
  }
]
  1. Multi tag filter
request URL : http://localhost:8080/item?tags=electronic&tags=cheap

response

[
  {
    "item": {
      "id": "902a455a-e165-4a6a-9449-d1ccd64ce258",
      "itemName": "avgPhone",
      "itemType": "phone",
      "manufacturingCompany": "banana",
      "manufacturingDate": "2022-01-04T02:02:10.466+00:00",
      "tags": [
        "electronic",
        "cheap"
      ]
    }
  },
  {
    "item": {
      "id": "6d327c94-d25e-4814-8ab0-d969a9bb135e",
      "itemName": "tinyPC",
      "itemType": "laptop",
      "manufacturingCompany": "mango",
      "manufacturingDate": "2021-10-01T02:02:10.466+00:00",
      "tags": [
        "cheap",
        "electronic"
      ]
    }
  }
]
  1. Multi tag filter with item type
request URL : http://localhost:8080/item?type=phone&tags=electronic&tags=cheap

response

[
  {
    "item": {
      "id": "902a455a-e165-4a6a-9449-d1ccd64ce258",
      "itemName": "avgPhone",
      "itemType": "phone",
      "manufacturingCompany": "banana",
      "manufacturingDate": "2022-01-04T02:02:10.466+00:00",
      "tags": [
        "electronic",
        "cheap"
      ]
    }
  }
]
  1. The manufacturing date filter
request URL : http://localhost:8080/item?date=2021-01-05

response (there is a timezone, requesting timezone is different from UTC)

[
  {
    "item": {
      "id": "9f860b12-ed97-4ea0-a422-e0328600c4c1",
      "itemName": "k",
      "itemType": "b",
      "manufacturingCompany": "c",
      "manufacturingDate": "2021-01-06T02:41:12.353+00:00",
      "tags": [
        "x"
      ]
    }
  },
  {
    "item": {
      "id": "4ccfbaa4-9f5b-4c06-ab25-6a335ece8920",
      "itemName": "a",
      "itemType": "b",
      "manufacturingCompany": "c",
      "manufacturingDate": "2021-01-06T02:41:12.353+00:00",
      "tags": [
        "x"
      ]
    }
  }
]

Error handling

  1. Handling invalid item ids.

looks like this:-

invalid_id

  1. Invalid inputs during create

looks like this:-

invalid_inputs

About

Shopify intern Assesement

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages