Skip to content
This repository has been archived by the owner on Dec 2, 2024. It is now read-only.

Latest commit

 

History

History
147 lines (95 loc) · 4.98 KB

README.md

File metadata and controls

147 lines (95 loc) · 4.98 KB

Quality Gate Status Known Vulnerabilities

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

Tech Challenge

Install

Go

Make sure you have Go 1.22.2 or higher

Execute

go mod tidy

Defining Envs

To correctly use the project, it is necessary to define a .env file, with the values for the envs:

  • DB_USERNAME
  • DB_PASSWORD
  • DB_HOST
  • DB_NAME
  • DB_PORT

We recommend using for development the following values:

DB_USERNAME=user
DB_PASSWORD=pass
DB_HOST=pgsql
DB_NAME=postgres
DB_PORT=5432

Executing with Docker (Compose)

docker compose build

docker compose up -d

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

## Expected response
= Status Code 200

If you're having trouble deploying the application with docker-compose (and not docker compose), use docker version 27.0.0 or higher.

Accessing Swagger UI

Go to http://localhost:8080/swagger/index.html#/ after the application is running.

Guide

Follow the guide (in portuguese) for a step-by-step guide to the project here.

Stack

DDD with event storm

The team chose to use Miro to document this deliverable, available at the link.

The diagram contains:

  • System documentation in DDD with Event Storm
  • Caption for the ubiquitous language used
  • Additional details to understand the proposed resolution
  • Order fulfillment and payment flow
  • Order preparation and delivery flow

Architecture

This project follows the models proposed by Clean Architecture

Source: https://blog.geisonbiazus.com/static/image/architecture.png

Swagger

This project makes use of the library swag to generate the swagger documentation.

Install

Follow the steps described in the official documentation

Generate

 swag init -g cmd/http/main.go 

Access the documentation

The documentation can be founded at the path /docs/swagger.yaml or accessing this link.

Infrastructure

Requirements Infrastructure

Kubernetes

The Kubernetes templates are located at the /deploy/k8s folder, you can use it to create a local k8s setup with minikube

The order of execution is:

  1. namespaces
  2. secret > you should update the secret value with the database password
  3. deployment
  4. hpa
  5. service

You can forward the port with the following command:

kubectl port-forward svc/tech-challenge-service 4000:80 -n dev

Kubernates Architecture

Diagram

Project structure

  • 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.