Skip to content

MCarbono/ccca

Repository files navigation

E-commerce API

Summary


About

This is a basic e-commerce api project created to practice the concepts about clean architecture, ports and adapters, event-driven architecture, CQRS and domain driven design. This code was developed based in the course called "Clean Code e Clean Architecture"(https://app.branas.io/clean-code-e-clean-architecture). The project contains four microservices (catalog, checkout, freight and stock) and a shared folder that has abstractions from libraries that is used by more than one microservice.


Technologies

  • Express
  • Axios
  • PgPromise
  • Amqplib
  • Jest
  • Typescript

Setup

    # clone the repository
    $ git clone projectURL
    # access the project folder
    $ cd projectURL
    # install dependencies with Makefile
    $ make install
    # install dependencies with yarn
    $ yarn
    # install dependencies with npm
    $ npm i

Run server

After cloning the repository, navegate to one of the microservices. Use the command below:

    $ cd microservice_folder_name

To start the server, use one of the commands below:

    # Makefile command
    $ make run
    # npx command
    $ npx ts-node src/main.ts

Infrastructure

The database used is the Postgres. The message broker is the RabbitMQ. In this project root folder there's a docker-compose file that creates the database and the broker. All of the services runs in their default ports. Run one of the commands below inside the root folder of the project:

    # Makefile command
    $ make localenv_up
    # docker command
    $ docker-compose -f docker-compose.yml up --force-recreate 

To delete the containers, run one of the commands below:

    # Makefile command
    $ make localenv_down
    # docker command
    $ docker-compose down

Tests

Unit Tests

Each one of the microservices has unit tests. To run it, use one of the command below inside the microservice folder:

    # Makefile command
    $ make unit
    # Jest command
    $ npx jest test/unit

Integration Tests

Each one of the microservices has integration tests. To run it, you will need to have the database instance. The microservice will use the repository of it's own bounded context, and any external resource will be mocked. Use one of the commands below inside the microservice folder.

    # Makefile command
    $ make integration
    # Jest command
    $ npx jest test/integration

Specific integration tests

The checkout microservice has a specific suite test cases. To run it, you will need to have all the microservices up and the infrastructure. It will do an integration test by the checkout's microservice api. Use one of the commands below inside the checkout microservice folder.

    # Makefile command
    $ make api
    # Jest command
    $ npx jest test/api 

About

Project developed from the content of the course "Clean Code e Clean Architecture"

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages