Skip to content

Project used as a Tech Challenge for the Software Architecture Postgraduate Course at FIAP. This project is an API for a fast food self-service system.

Notifications You must be signed in to change notification settings

IanOliv/fiap-irango-api

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

iRango API

typescript Node 20.10 nestjs mysql redis docker swagger make jest eslint editorconfig typeorm

This project involves the development of an API for a fast food self-service system, proposed as a Tech Challenge for the Software Architecture Postgraduate Course at FIAP.

For this project, we utilized the TypeScript programming language with Node.js and the Nest.js framework. The database management includes MySQL 5.7 to handle information related to Consumidor, Produto, and Pedido. Additionally, an in-memory Redis database is employed for caching.

To build the API documentation, we've used Swagger tool integrated with Nest.js, accessible through the endpoint: {irango_host}/docs

Workspace Dependencies

Project Dependencies

Install project dependencies with:

npm run install

Start Project using Docker

Configure all docker containers and volumes and start the application

make setup

# or try without make

docker network create -d bridge local-network
cp .env.example .env
docker-compose build --progress=plain
docker-compose up
docker-compose exec -it service-irango-api npm run migration:run
docker-compose exec -it service-irango-api npm run seed:run

Start project using npm

Watch mode:

npm run start:dev

Compiled mode:

npm run build
npm run start

Migrations and Seeds:

npm run migration:run
npm run seed:run

How to Use

We developed a seed to populate database with some products and one Consumidor with CPF 123.456.789-00. You can use it or create a new Consumidor.

Endpoints

We developed few endpoints which can be found in consumidores.controller.ts, produtos.controller.ts and pedidos.controller.ts files

Business Requirements:

  1. Cadastro do Cliente

POST {irango_host}/v1/consumidores

  1. Identificação do Cliente via CPF

GET {irango_host}/v1/consumidores/cpf

  1. Criar, editar e remover de produto

POST {irango_host}/v1/produtos

PUT {irango_host}/v1/produtos/:id

DELETE {irango_host}/v1/produtos/:id

  1. Buscar produtos por categoria

GET {irango_host}/v1/produtos/categorias/:termo

  1. Checkout

POST {irango_host}/v1/pedidos

  1. Verificar status do Pedido

GET {irango_host}/v1/pedidos/:id

  1. Atualizar status do pedido

PUT {irango_host}/v1/produtos/:id

  1. Webhook de Pagamento (Mercado Pago)

POST {irango_host}/v1/pedidos/pagamento-webhook/mercado-pago

  1. Listar os pedidos

GET {irango_host}/v1/pedidos

Automated Tests

We developed integration tests which can be run using docker or in directly in local machine (in this case you need change the DB_HOSTNAME env to localhost). Before run the tests, we need to create the test database using:

make test.integration.createdb

# or try without make
docker exec -it ${CONTAINER_MYSQL} mysql -uroot -ppassword -e "DROP DATABASE IF EXISTS ${DATABASE}_test; CREATE DATABASE ${DATABASE}_test;"
docker-compose exec -it ${CONTAINER_BACKEND} npm run migration:run:test

Run all tests (We just have integrations for while)

# With docker
docker-compose run service-irango-api npm run test

# local
npm run test

Run only integration tests

# With docker
docker-compose run service-irango-api npm run test:integration

# local
npm run test:integration

Run a specifc test file

# With docker
docker-compose run service-irango-api npm run test:integration:one <FILE_NAME>

# local
npm run test:integration:one <FILE_NAME>

Make commands

Using Docker

  • Setup Project: make setup. This command will create docker network, containers and volumes. It will also start the project and show its logs.
  • Start Project: make up
  • Stop Projects: make down
  • Show logs: make logs
  • Add Migration: make migration.generate name=MigrationName
  • Run Migrations: make migration.run
  • Add Seed: make seed.generate name=SeedName
  • Run Seeds: make seed.run
  • Access container bash: make bash
  • Access Redis container: make redis

About

Project used as a Tech Challenge for the Software Architecture Postgraduate Course at FIAP. This project is an API for a fast food self-service system.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • TypeScript 96.6%
  • JavaScript 2.1%
  • Other 1.3%