Make sure you have Go 1.22.2 or higher
Execute
go mod tidy
go test -cover ./...
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
- THUMB_SERVICE_URL
We recommend using for development the following values:
DB_USERNAME=user
DB_PASSWORD=pass
DB_HOST=pgsql
DB_NAME=postgres
DB_PORT=5432
THUMB_SERVICE_URL=http://localhost:<PORT_SERVICE_IS_RUNNING>
docker compose build
docker compose up -d
curl --request GET --url http://localhost:8082/health
## Expected response
= Status Code 200
If you're having trouble deploying the application with
docker-compose
(and notdocker compose
), use docker version 27.0.0 or higher.
Go to http://localhost:8080/swagger/index.html#/ after the application is running.
- Go
- Gin Web Framework - Routes, JSON validation, Error management, Middleware support
- PostgresSQL - Database
- swag - Tool to generate swagger documentation
- docker - Containerization tool
- docker-compose - Tool to define and run multi-container Docker applications
This project makes use of the library swag to generate the swagger documentation.
Follow the steps described in the official documentation
swag init -g cmd/http/main.go
The documentation can be founded at the path /docs/swagger.yaml
or accessing this link.
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.thumb
: Directory contains definition of the entity's heights, interfaces, repository and service of the entity Thumb.users
: Directory contains definition of the entity's heights, interfaces, repository and service of the entity User.
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.
This project uses basic authentication to protect the endpoints.
Example:
User | Password |
---|---|
test | test |
curl 'http://localhost:8080/login' -H 'Authorization: Basic dGVzdDp0ZXN0'
Use the Swagger for access the endpoint /user
and create a new user.
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
- Worker flow
- API flow