Giter Club home page Giter Club logo

cart-service's Introduction

Cart Application

Features implemented

  1. Ability to create account with two user roles (admin, customer) and log in
  2. Admin can add items to the inventory , list items into inventory and suspend a customer user
  3. Customer can add items to the cart, list items in the cart , list available items in inventory , remove items from cart
  4. RBAC is implemented for admin and customer users
  5. JWT token based authentication is implemented for all the APIs

Low level design

  1. User is a generic entity which can be either admin or customer
  2. 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.
  3. 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.
  4. 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.

Running the application

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

Running the tests

unit tests are also dockerized and can be run using the following command

cd docker_test && docker compose up

API Documentation

  1. swagger documentation is available at swagger docs when you run the application.
  2. postman documentation with example requests(success, failure , validation , etc) is also provided at postman docs

Improvements

  1. admin and customer can be normalized into separate table and user can be a generic entity which can be either admin or customer.
  2. item can be normalized into separate tables category and item.
  3. signup api can be made more secure right now it is open api and anyone can signup as admin or customer.
  4. logout api can be implemented to invalidate the jwt token.
  5. redis to improve the performance of the application.
  6. pagination for inventory and cart list apis.
  7. 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.
  8. e2e testing over rest apis can be added to test the application end to end.

cart-service's People

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.