This repository contains a Node.js TypeScript project that implements a self-service order API using the Domain-Driven Design (DDD) and Hexagonal architecture. The API allows users to place and manage their own orders through a convenient interface.
To run this project, ensure that you have the following installed:
(Back to Table of contents ⬆️)
To run in prod mode:
docker compose up -d
To run in dev mode (with hot reload):
docker compose -f docker-compose-dev.yml up -d
In some OS's its necessary to run these commands as sudo
(Back to Table of contents ⬆️)
We created a collection in postman to execute all challenges steps easily.
You can find inside postman
folder at the root of this project
- Cadastro do cliente
POST
curl --location 'http://localhost:8080/api/customers' \
--header 'Content-Type: application/json' \
--data-raw '{
"name":"Michael Jackson",
"cpf": "38267498709",
"email": "[email protected]"
}'
- Identificação do cliente via CPF
GET
curl --location 'http://localhost:8080/api/customers/38267498709/cpf'
- Criar, editar e remover de Produto
POST (Create Product)
curl --location 'http://localhost:8080/api/products' \
--header 'Content-Type: application/json' \
--data '{
"name": "Nuggets",
"category": "SIDE_DISH",
"price": 5
}'
PUT (Update Product)
curl --location --request PUT 'http://localhost:8080/api/products/48a57c23-b50f-4567-b191-0aa17225d1c0' \
--header 'Content-Type: application/json' \
--data '{
"name": "Big Mac",
"price": 22.00
}'
GET (All Products)
curl --location 'http://localhost:8080/api/products'
DELETE (Delete Product)
curl --location --request DELETE 'http://localhost:8080/api/products/48a57c23-b50f-4567-b191-0aa17225d1c0'
- Buscar produtos por categoria
curl --location 'http://localhost:8080/api/product/category/FOOD'
- Pegar status de pagamento de um pedido
curl --location 'http://localhost:8080/api/payments/order/258da063-caf2-40c3-8c25-ffcbcb554492'
- Listar todos os pedidos
curl --location 'http://localhost:8080/api/orders'
- Endpoint para o Webhook do Mercado Pago
curl --location 'http://localhost:8080/api/payments/webhook/mercadopago' \
--header 'Content-Type: application/json' \
--data '{
"data": {
"id": 1317578927
}
}'
- Atualizar Status de um pedido
curl --location --request PUT 'http://localhost:8080/api/orders/764697de-5c81-437f-8f9b-05394f440bb4/status' \
--header 'Content-Type: application/json' \
--data '{
"status": "READY"
}'
- Criar um pedido (e tambem um pedido de pagamento ja integrando com o mercado pago)
curl --location 'http://localhost:8080/api/orders' \
--header 'Content-Type: application/json' \
--data-raw '{
"customerId": "688dac4f-4781-4ccd-a9cf-74b527eeb91b",
"products": [
{
"id": "4f197bd9-d329-4558-9a39-71f53c0df64e",
"quantity": 5
}
],
"description": "Order payment",
"installments": 1,
"payer": {
"email": "[email protected]"
},
"paymentMethodId": "pix"
}'
(Back to Table of contents ⬆️)
To run this project, ensure that you have the following installed:
- Node.JS (v18.16.0)
(Back to Table of contents ⬆️)
-
Clone this repository to your local machine or download the source code.
-
Open a terminal and navigate to the project's root directory.
-
Run the following command to install the project dependencies:
npm install
(Back to Table of contents ⬆️)
To start the development server, run the following command:
npm run dev
This will compile the TypeScript code, start the server, and watch for any file changes, automatically restarting the server when necessary.
(Back to Table of contents ⬆️)
(Back to Table of contents ⬆️)
(WIP)
(Back to Table of contents ⬆️)
(Back to Table of contents ⬆️)
The project follows a DDD-inspired folder structure to separate concerns and maintain a clear code organization. Here's an overview of the key directories:
src
domain
: Contains the core business models, services, and repositories.application
: Implements the application layer, which orchestrates the domain logic and exposes it through use cases.infrastructure
: Provides infrastructure-related implementations, such as database connectors or external service clients.web
: Handles API-specific concerns such as route definitions and request validation.
(Back to Table of contents ⬆️)
(Back to Table of contents ⬆️)
(Back to Table of contents ⬆️)
(Back to Table of contents ⬆️)
(Back to Table of contents ⬆️)
- Denis Wesley Slapelis - rm348515
- Paulo César Colantuomo Martins - rm349043
- Willian Yoshiaki Kazahaya - rm348581