Skip to content
This repository was archived by the owner on Dec 2, 2024. It is now read-only.
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
repos:

# Next hooks are Code Quality hooks.
- repo: https://github.com/macisamuele/language-formatters-pre-commit-hooks
rev: v2.14.0
hooks:
- id: pretty-format-golang
args:
- --autofix
17 changes: 7 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
[![Quality Gate Status](https://sonarcloud.io/api/project_badges/measure?project=pangolin-do-golang_tech-challenge&metric=alert_status)](https://sonarcloud.io/summary/new_code?id=pangolin-do-golang_tech-challenge) ![Known Vulnerabilities](https://snyk.io/test/github/pcbarretos/pangolin-do-golang/tech-challenge/badge.svg)
[![Quality Gate Status](https://sonarcloud.io/api/project_badges/measure?project=pangolin-do-golang_tech-challenge&metric=alert_status)](https://sonarcloud.io/summary/new_code?id=pangolin-do-golang_tech-challenge) ![Known Vulnerabilities](https://snyk.io/test/github/pcbarretos/pangolin-do-golang/tech-challenge-customer-api/badge.svg)

Miro Board: https://miro.com/app/board/uXjVKVoZwos=/?share_link_id=718027124865

# Tech Challenge
# Tech Challenge Customer API

## Install

Expand Down Expand Up @@ -45,7 +45,7 @@ docker compose build

docker compose up -d

curl --request GET --url http://localhost:8080/health
curl --request GET --url http://localhost:8085/health

## Expected response
= Status Code 200
Expand All @@ -59,7 +59,7 @@ Go to http://localhost:8080/swagger/index.html#/ after the application is runnin

## Guide

Follow the guide (in portuguese) for a step-by-step guide to the project [here](https://github.com/pangolin-do-golang/tech-challenge/wiki/Guia-de-uso-da-API).
Follow the guide (in portuguese) for a step-by-step guide to the project [here](https://github.com/pangolin-do-golang/tech-challenge-customer-api/wiki/Guia-de-uso-da-API).

## Stack

Expand Down Expand Up @@ -109,7 +109,7 @@ The documentation can be founded at the path `/docs/swagger.yaml` or accessing t

## Infrastructure

[Requirements Infrastructure](https://github.com/pangolin-do-golang/tech-challenge/blob/main/terraform/README.md)
[Requirements Infrastructure](https://github.com/pangolin-do-golang/tech-challenge-customer-api/blob/main/terraform/README.md)

## Kubernetes

Expand All @@ -125,7 +125,7 @@ The order of execution is:
You can forward the port with the following command:

```bash
kubectl port-forward svc/tech-challenge-service 4000:80 -n dev
kubectl port-forward svc/tech-challenge-customer-api-service 4000:80 -n dev
```

### Kubernates Architecture
Expand All @@ -137,11 +137,8 @@ kubectl port-forward svc/tech-challenge-service 4000:80 -n dev
- `cmd`: Application entry point directory for the application's main entry points, dependency injection, or commands. The web subdirectory contains the main entry point to the REST API.
- `internal`: Directory to contain application code that should not be exposed to external packages.
- `core`: Directory that contains the application's core business logic.
- `cart`: Directory contains definition of the entity's heights, interfaces, repository and service of the entity Cart.
- `customer`: Directory contains definition of the entity's heights, interfaces, repository and service of the entity Customer.
- `order`: Directory contains definition of the entity's heights, interfaces, repository and service of the entity Order.
- `product`: Directory contains definition of the entity's heights, interfaces, repository and service of the entity Product.
- `adapters`: Directory to contain external services that will interact with the application core.
- `db`: Directory contains the implementation of the repositories.
- `rest`: Directory that contains the definition of the application's controllers and handlers for manipulating data provided by the controller
- `domainerrors`: Directory that contains the definition of the application's domain errors.
- `domainerrors`: Directory that contains the definition of the application's domain errors.
33 changes: 5 additions & 28 deletions cmd/http/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,18 +6,15 @@ import (
"os"

"github.com/joho/godotenv"
_ "github.com/pangolin-do-golang/tech-challenge/docs"
dbAdapter "github.com/pangolin-do-golang/tech-challenge/internal/adapters/db"
"github.com/pangolin-do-golang/tech-challenge/internal/adapters/rest/server"
"github.com/pangolin-do-golang/tech-challenge/internal/core/cart"
"github.com/pangolin-do-golang/tech-challenge/internal/core/customer"
"github.com/pangolin-do-golang/tech-challenge/internal/core/order"
"github.com/pangolin-do-golang/tech-challenge/internal/core/product"
_ "github.com/pangolin-do-golang/tech-challenge-customer-api/docs"
dbAdapter "github.com/pangolin-do-golang/tech-challenge-customer-api/internal/adapters/db"
"github.com/pangolin-do-golang/tech-challenge-customer-api/internal/adapters/rest/server"
"github.com/pangolin-do-golang/tech-challenge-customer-api/internal/core/customer"
"gorm.io/driver/postgres"
"gorm.io/gorm"
)

// @title Tech Challenge Food API
// @title Tech Challenge Customer Food API
// @version 0.1.0
// @description Fast Food API for FIAP Tech course

Expand All @@ -32,21 +29,7 @@ func main() {
customerRepository := dbAdapter.NewPostgresCustomerRepository(db)
customerService := customer.NewService(customerRepository)

productRepository := dbAdapter.NewPostgresProductRepository(db)
productService := product.NewProductService(productRepository)

cartRepository := dbAdapter.NewPostgresCartRepository(db)
cartProductsRepository := dbAdapter.NewPostgresCartProductsRepository(db)
cartService := cart.NewService(cartRepository, cartProductsRepository)

orderRepository := dbAdapter.NewPostgresOrderRepository(db)
orderProductRepository := dbAdapter.NewPostgresOrderProductsRepository(db)
orderService := order.NewOrderService(orderRepository, orderProductRepository, cartService, productService)

restServer := server.NewRestServer(&server.RestServerOptions{
OrderService: orderService,
ProductService: productService,
CartService: cartService,
CustomerService: customerService,
})

Expand All @@ -69,12 +52,6 @@ func initDb() (*gorm.DB, error) {

err = db.AutoMigrate(
&dbAdapter.CustomerPostgres{},
&dbAdapter.ProductPostgres{},
&dbAdapter.OrderPostgres{},
&dbAdapter.CartPostgres{},
&dbAdapter.CartProductsPostgres{},
&dbAdapter.OrderPostgres{},
&dbAdapter.OrderProductPostgres{},
)
if err != nil {
log.Fatalln(err)
Expand Down
4 changes: 2 additions & 2 deletions docker-compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,12 @@ services:
server:
build:
context: .
container_name: go_tech_challenge_app
container_name: go_tech_challenge_customer_app
restart: always
links:
- pgsql:pgsql
ports:
- "8080:8080"
- "8085:8080"
depends_on:
pgsql:
condition: service_started
Expand Down
Loading