Git Product home page Git Product logo

e-commerce's Introduction

This Repository includes backend part of the Spring Boot based E-Commerce application. Users can select products which they desire to buy from several categories and add to their carts. After adding, deleting, or updating the quantity of the items, they can buy these product through payment service API provided by Craftgate.

The application uses dockerized PostgresSQL database and Hibernate as JPA implementation to get benefit from ORM.

For security, I implemented my own security settings different from the default settings which are provided by Spring Security. Application uses JWT token to authenticate a user. Also, it uses refresh token to prevent users to authenticate themselves repeatedly and improve security. For more enhanced security, application uses role-based access mechanism along with @PreAuthorize annotation. Application includes three different roles which are “ROLE_USER”, “ROLE_ADMIN” and “ROLE_SUPER_ADMIN”. Users who have “ROLE_ADMIN” have access to the product and the category related APIs which means they can made changes on products and categories. On the other hand, only “SUPER_ADMIN” role can use APIs related to user and roles which means only “SUPER_ADMIN” can create new roles, change someone’s role and delete an existing role. “USER” role is the default role. All endpoints excluding these: “/api/auth/register“, “/api/auth/login“ require authentication. Therefore, only a registered users can benefit from e-commerce services which is provided by this application. The application uses SecurityContextHolder to get authenticated user and add products to her/his special cart.

I have created custom Exception classes to handle edge cases such as when there is no existing Product or Category with that id. Also these exception classes under exception package return informative responses to the client. With using, @RestControllerAdvice annotation for GlobalControllerExceptionHandler.class and @ExceptionHandler annotation for related methods, returned responses inform clients about what happened which means what caused to an error. Also, with using Slf4j logging, server is also informed about what cause to that error.

To test the application, unit and integration tests has been created with JUnit5, Mockito and AssertJ. For now, only CartController, CartRepository and CartService classes methods has been tested. To test repositories, application uses embedded H2 database.

To integrate a payment service, I have used Craftgate API due to it’s well-structured integration design. To pay the price of whole cartItems which means to make payments, a user can send her/his card information to the server (Application only have test API keys so only test cards will be accepted. One could get test cards from here.). If the payment doesn’t accepted, CraftgateException will be thrown with the appropriate message. Also application doesn’t persist card information in the database. To get more information about Craftgate API, you can click here.

The program is still under development. Therefore, I will add more features in the future.

If you encounter any issues or have suggestions or want to contribute code, I would be very happy. Thank you for your interest in my project, and I appreciate your support!

e-commerce's People

Contributors

ahmetkaanozbek avatar

Watchers

 avatar

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.