- Ability to create account with two user roles (admin, customer) and log in
- Admin can add items to the inventory , list items into inventory and suspend a customer user
- Customer can add items to the cart, list items in the cart , list available items in inventory , remove items from cart
- RBAC is implemented for admin and customer users
- JWT token based authentication is implemented for all the APIs
- User is a generic entity which can be either admin or customer
- item is an item which can be added to the inventory , customer can add these items into cart. This is also alternatively referred as original_item in the codebase.
- customer_cart is a cart which is created for a customer user. It has one to one relationship with user and one to many relationship with cart_item.
- cart_item is an item which is added to the customer cart. It has many to many relationship with original_item and many to one relationship with customer_cart. cart_item has a field called quantity_in_cart which represents the quantity of the original_item in the cart.
Complete application is dockerized and docker-compose can be used to run the application. Environment variables can be configured in config/.env file. config/env.sample provided for reference. TO simply run the application with default config, you can run the following command. Application would be available at http://localhost:9999
cd docker && docker compose up
unit tests are also dockerized and can be run using the following command
cd docker_test && docker compose up
- swagger documentation is available at swagger docs when you run the application.
- postman documentation with example requests(success, failure , validation , etc) is also provided at postman docs
- admin and customer can be normalized into separate table and user can be a generic entity which can be either admin or customer.
- item can be normalized into separate tables category and item.
- signup api can be made more secure right now it is open api and anyone can signup as admin or customer.
- logout api can be implemented to invalidate the jwt token.
- redis to improve the performance of the application.
- pagination for inventory and cart list apis.
- adding cart currently adds item to cart and removes it from inventory (this is done to create item out of stock scenarios), this can be improved by having a cart checkout workflow where we would remove items from inventory only at the time of cart checkout.
- e2e testing over rest apis can be added to test the application end to end.