ProblemStatement For t4 Track
ProblemStatement For t4 Track
They hired you to develop a distributed e-commerce platform to move their business
online. As an initial MVP you are required to develop a restful API backend application in
springboot.
Here is the requirement for the application.
* Role CartProduct
roleId - Integer cpId - Integer
role - String cart – Cart
*product – Product
quantity - Integer
User *
userId - Integer
1
username - String 1
password - String Cart
roles - Role cartId - Integer
1 totalAmount - Double
user - User
cartProducts - CartProduct
*
Product
productId - Integer
productName - String
1 Category
price - Double
categoryId - Integer
seller – User * categoryName - String
Category - Category
Product CartProduct
price, productName, categoryId, sellerId cartId, productId, quantity
29190, 'Apple iPad 10.2 8th Gen WiFi iOS Tablet', 2, 3 1, 2, 2
10, 'Crocin pain relief tablet', 5, 4
Your job is to create the following APIs, use JWT authentication with roles to protect
consumer and seller specific endpoints. The JWT is included in the header with key JWT
and value as jwt token.
• Consumers can search, add, update and delete items in cart.
• Sellers can add, update and delete products to the database.
• APIs preceeding with /api/public are public APIs and can be accessed by anyone.
• APIs preceeding with /api/auth/consumer are authenticated and consumer APIs.
• APIs preceeding with /api/auth/seller are authenticated and seller APIs
• if authenticated endpoints are accessed without JWT, return 401.
• if a consumer endpoint is accessed with seller JWT or viceverse, return 403.
/api/public/login - POST - takes username and password in json body, authenticates and
returns JWT. Can authenticate both consumer and seller.
request body - {"username": "bob","password": status 200,
"pass_word"} response body –
eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIx
MjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiaWF
0IjoxNTE2MjM5MDIyfQ.SflKxwRJSMeKKF2QT4fwp
MeJf36POk6yJV_adQssw5c
request body - {"username": "bob","password": status 401
"password"}
Take a look at the testcases to understand more on how the validation works.
Good Luck and Start Coding!