Skip to content

adryyy10/shopping-cart

Repository files navigation

Shopping cart

Shopping cart is an application that allows you to add products to your cart (without adding the same one twice) and to be able to make a 10% discount on your final list

How can I see it locally?

It is easy to reproduce it locally

Inside our shopping-cart directory open a terminal and write:

symfony server-start

Then with the helps of XAMPP we will initialize our Apache and MySQL

Alt text

And here we have our products:

Alt text

How the application is structured

For this application I implemented a structural pattern called Hexagonal Architecture which divides the application in 3 main layers and keeps the code separate and understandable:

  1. Infrastructure layer --> Here we have all "external" services that need to be as decoupled as possible: Controllers, Repositories...etc.
  2. Application layer --> Here we have all our UseCases for the application. I used a CQS principle in order to split the validation of data from the logic of the useCase
  3. Domain layer --> Here we have all the business logic: Entities & Interfaces.

Alt text

What is the flow of the application

We start in /products route where we can see all of our available products.

Alt text

If we click on "Add to cart" we will add a new product and it will be shown in the header when we see the number of products refreshed

Alt text

After that, if we click on the same product, it will prompt a message saying "Product already added" and the product won't be added. We could use this exception handling to implement a custom message inside the product with Javascript in nexts features

Alt text

If we click on the "Go to cart" button or in the number of cart product (top-right in the header) we will go to /cart and see all our products added

Alt text

Once we are in /cart we can see the list of our chosen products, and if we clicked in "Apply 10% discount" we will get a 10% discount (in a more efficient way I would created an Entity of discounts and I'll associated with existing users to only show that option for those users)

Alt text

Alt text

Tests

I created Unit Tests in /tests folder that tests the use cases of the application and check the type of the variables we are receiving

We can run our tests by running the following command:

php bin/phpunit ./tests

Alt text

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published