This is a POC (Proof of Concept) using Hexagonal Architecture, SOLID, DDD, Clean Code, Clean Architecture

Overview

Projeto Planetas Star Wars:

Esse projeto de trata de uma POC utilizando os conceitos de Clean Arch, Hexagonal Arch, Clean Code, DDD, e SOLID.

O principal motivo por escolher arquitetura hexagonal foi para deixar o desacoplamento, e divisão de responsabilidades bem claras.

Optei por trabalhar com dois "Domínios" sendo "users" um gerenciamento de usuário simples com autenticação JWT e "planets" com endpoints públicos para listar planetas e endpoints de create, update, e delete privados protegidos por autenticação JWT.

Para facilitar os testes adicionei no repositório uma pasta contendo os arquivos do POSTMAN pasta importar os arquivos presentes nesta no POSTMAN e sucesso!

Cobertura por testes:

Para verificar a cobertura de testes basta rodar o comando: make test-cover

Coverage test

Rodando o Projeto

  • Para rodar o projeto é necessário ter o docker, e docker-compose instalado.
  • Com docker devidamente instalado basta rodar o comando docker-compose up
  • Url Base: http://localhost:9099 "Porta pode ser alterada em config.yml "
  • Por padrão quando a aplicação sobe via docker compose um usuário é adicionado:

Rotas de usuários:

Autenticação/login:

  • POST: {{urlBase}}/users/auth
  • BODY: {"email": "[email protected]","password": "123456"}
  • RESPONSE:
{
    "status": 200,
    "code": 100020,
    "message": "Authenticate success",
    "data": "TOKEN HERE"
}

Cadastro de usuários:

  • POST: {{urlBase}}/users
  • HEADER: Authorization: Bearer {{Token}}
  • BODY: {"name": "...","email": "...","password":"..."}
  • RESPONSE OK:
{
    "status": 200,
    "code": 100006,
    "message": "Success",
    "data": {
        "uuid": "...",
        "name": "...",
        "email": "..."
    }
}
  • RESPONSE WITH ERROR:
{
    "status": 400,
    "code": 100021,
    "message": "Validation failed",
    "fields": [
        {
            "code": 100000,
            "message": "Already exists",
            "field": "email"
        }
    ]
}

Lista de usuários:

  • GET: {{urlBase}}/users
  • HEADER: Authorization: Bearer {{Token}}
  • RESPONSE:
{
    "status": 200,
    "code": 100006,
    "message": "Success",
    "data": [
        {
            "uuid": "...",
            "name": "...",
            "email": "..."
        },
        {
            "uuid": "...",
            "name": "...",
            "email": "..."
        }
    ]
}

Lista usuário por UUID:

  • GET: {{urlBase}}/users/{{userID}}
  • HEADER: Authorization: Bearer {{Token}}
  • RESPONSE:
{
    "status": 200,
    "code": 100006,
    "message": "Success",
    "data": {
        "uuid": "...",
        "name": "...",
        "email": "..."
    }
}

Atualiza usuário por UUID:

  • PATCH: {{urlBase}}/users/{{userID}}
  • HEADER: Authorization: Bearer {{Token}}
  • BODY: {"name": "...","email": "...","password":"..."}
  • RESPONSE OK:
{
    "status": 200,
    "code": 100006,
    "message": "Success",
    "data": {
        "uuid": "...",
        "name": "...",
        "email": "..."
    }
}
  • RESPONSE WITH ERROR:
{
    "status": 400,
    "code": 100021,
    "message": "Validation failed",
    "fields": [
        {
            "code": 100000,
            "message": "Already exists",
            "field": "email"
        }
    ]
}

Deleta usuário por UUID:

  • DELETE: {{urlBase}}/users/{{userID}}
  • HEADER: Authorization: Bearer {{Token}}
  • RESPONSE OK:
{
    "status": 200,
    "code": 100006,
    "message": "Success"
}
  • RESPONSE WITH ERROR:
{
    "status": 500,
    "code": 100017,
    "message": "Unable to delete record"
}

Rotas de planetas:

Cadastro de planetas:

  • POST: {{urlBase}}/planets
  • HEADER: Authorization: Bearer {{Token}}
  • BODY: {"name": "...","terrain": "...","climate":"..."}
  • RESPONSE OK:
{
    "status": 200,
    "code": 100006,
    "message": "Success",
    "data": {
        "uuid": "...",
        "name": "...",
        "terrain": "...",
        "climate": "...",
        "films": "..."
    }
}
  • RESPONSE WITH ERROR:
{
    "status": 400,
    "code": 100021,
    "message": "Validation failed",
    "fields": [
        {
            "code": 100001,
            "message": "Required",
            "field": "climate"
        }
    ]
}

Lista de planetas: Na listagem de planetas é possivel aplicar busca por nome, sendo opcional. Se nao informar irá listar todos.

  • GET: {{urlBase}}/planets?name={{planetName}}
  • RESPONSE:
{
    "status": 200,
    "code": 100006,
    "message": "Success",
    "data": [
        {
            "uuid": "...",
            "name": "...",
            "terrain": "...",
            "climate": "...",
            "films": "..."
        },
        {
            "uuid": "...",
            "name": "...",
            "terrain": "...",
            "climate": "...",
            "films": "..."
        }
    ]
}

Lista planeta por UUID:

  • GET: {{urlBase}}/planets/{{userID}}
  • RESPONSE:
{
    "status": 200,
    "code": 100006,
    "message": "Success",
    "data": {
        "uuid": "...",
        "name": "...",
        "terrain": "...",
        "climate": "...",
        "films": "..."
    }
}

Atualiza planeta por UUID:

  • PATCH: {{urlBase}}/planets/{{userID}}
  • HEADER: Authorization: Bearer {{Token}}
  • BODY: {"name": "...","terrain": "...","climate":"..."}
  • RESPONSE OK:
{
    "status": 200,
    "code": 100006,
    "message": "Success",
    "data": {
        "uuid": "...",
        "name": "...",
        "terrain": "...",
        "climate": "...",
        "films": "..."
    }
}
  • RESPONSE WITH ERROR:
{
    "status": 400,
    "code": 100021,
    "message": "Validation failed",
    "fields": [
        {
            "code": 100001,
            "message": "Required",
            "field": "climate"
        }
    ]
}

Deleta planeta por UUID:

  • DELETE: {{urlBase}}/planets/{{userID}}
  • HEADER: Authorization: Bearer {{Token}}
  • RESPONSE OK:
{
    "status": 200,
    "code": 100006,
    "message": "Success"
}
  • RESPONSE WITH ERROR:
{
    "status": 500,
    "code": 100017,
    "message": "Unable to delete record"
}

Dinâmica dos erros possíveis:

Para facilitar e padronizar os retornos em cada endpoint criei um padrão mensagens e codigos.

Codigo Mensagem
100000 Already exists
100001 Required
100002 Invalid
100003 Invalid e-mail
100004 Invalid date
100005 Password must be between 6 and 40 characters.
100006 Success
100007 Not found
100008 Error
100009 Record successfully created
100010 Record successfully updated
100011 Record successfully deleted
100012 Unable to create record
100013 Unable to update record
100014 Unable to delete record
100015 Unable to list record
100016 Authenticate failed
100017 Authenticate success
100018 Validation failed
100019 Endpoint not found
100020 Unexpected
Owner
Marcelo Martins
25 years old, married, father of Cecilia, paying the bills as software developer to over 10
Marcelo Martins
Minimal example app of hexagonal architecture in go

Hexagonal Architecture Minimal example of hexagonal architecture (ports & adapters) in go. Resources T

Rodrigo Gamba 0 Nov 5, 2021
Golang loose implementaion of Domain Driven Design ( DDD )

This template is a loose implementation of golang DDD (Domain Driven Design). Template already setup user register login and refresh session route. It

Arslan Mughal 3 Jan 24, 2022
A repository of random code snippets used to develop proof of concepts

Oddments Oddments is a repository of random code snippets used to develop proof of concepts for techniques used with the Windows operating system. POC

Russel Van Tuyl 6 Feb 23, 2022
A little tool to create small QR code cards for vaccination/test proof.

Icedream's fancy vaccination/test certificate card tool This is just a tool I wrote to transform my vaccine certificate QR codes into something I can

Carl Kittelberger 0 Dec 16, 2021
Go clean architecture fully working example

Burp - clean architecture app Burp is a CRUD app managing beers. Front-end is written in Angular 12. Database in this example is mongodb. Root project

Audren Bouëssel du Bourg 29 Jul 29, 2022
Go Clean Architecture Boilerplate

Go Clean-Architecture Simple Go Clean-Architecture Boilerplate Overview The purpose of the template is to show: How to organize a project and prevent

Muhammad Naufal Rachfian Djamhur 0 Nov 27, 2021
Implement clean-architecture sample by golang

Implement clean-architecture sample by golang

null 2 Feb 17, 2022
dropspy is a (POC-quality) reworking of the C-language dropwatch tool in Go, with some extra features.

dropspy is a (POC-quality) reworking of the C-language dropwatch tool in Go, with some extra features.

fly.io 27 Mar 20, 2022
PoC de infraestrutura de comunicação utilizando RabbitMQ e Kafka

comm-infra PoC de infraestrutura de comunicação utilizando RabbitMQ e Kafka. Pré-requisitos Git Visual Studio Code Docker Docker Compose Go Instruções

Gabriel Kim 2 Jan 16, 2022
Zero-knowledge-proof verification bridge

Submit Bug Rosefintech-Rosl2-Bridge Zero knowledge proof verification bridge Table of Contents Security Background Install Community Contact License S

Rosefintech 16 Jun 4, 2022
A boilerplate/starter project for quickly building APIs using Golang with Clean Architechture

A boilerplate/starter project for quickly building APIs using Golang with Clean Architechture

Nyoman Frastyawan 1 Mar 2, 2022
The High Code Framework (low-code for devs)

hof - the high code framework The hof tool tries to remove redundent development activities by using high level designs, code generation, and diff3 wh

_Hofstadter 280 Aug 11, 2022
🎄 My code for the Advent of Code of year 2021 in Go.

Advent of Code 2021 This repository contains all code that I wrote for the Advent of Code 2021. This year I chose to try and learn Go. Enjoy! Built wi

Nick van Ravenzwaaij 0 Dec 9, 2021
Developed Code for the Fulfillment of the technical task given by Appointy using Go

INSTAGRAM BACKEND API BY KUNAL KULKARNI Table of Contents About The Project Built With Getting Started Prerequisites Installation Usage License Contac

Kunal Kulkarni 1 Oct 10, 2021
Scripts for generating go code using abigen

Scripts for generating go code using abigen

NIDA 0 Nov 15, 2021
Advent of Code 2021 solutions using Go 1.18 Generics

advent-of-code-2021 Here are my solutions for Advent of Code 2021. This year, I chose to write my solutions using Go 1.18 with generics (by building t

Glenn Lewis 4 Aug 15, 2022
traefik-certs-cleaner is a simple helper to clean the Traefik acme.json file by removing certificates

traefik-certs-cleaner If you appreciate this project: Description traefik-certs-cleaner is a simple helper to clean the Traefik acme.json file by remo

Ludovic Fernandez 10 Feb 4, 2022
Morse Code Library in Go

morse Morse Code Library in Go Download and Use go get -u -v github.com/alwindoss/morse or dep ensure -add github.com/alwindoss/morse Sample Usage pac

Alwin Doss 75 Jul 21, 2022
Automatically generate Go test boilerplate from your source code.

gotests gotests makes writing Go tests easy. It's a Golang commandline tool that generates table driven tests based on its target source files' functi

Charles Weill 4.1k Aug 12, 2022