/book_store_oauth-api

OAuth API

Primary LanguageGoMIT LicenseMIT

book_store_oauth-api

OAuth API

This application follows a Domain Driven Development, starting from the Domains (Entities) to the backward layers (Services, Controllers, and Infrastructure Providers).

Also, it uses the concepts of Dependency Injection. You can read more about it by reading this book.

It also uses the gin HTTP framework to handle the server.

User is the core domain of this application.

alt text

Getting Started

Prerequisites

Environment variables

export USER_API_URL=http://localhost:5001 &&

export OAUTH_CASSANDRA_HOST=127.0.0.1 &&

export OAUTH_CASSANDRA_PORT=9043

Installing and running locally

# Install dependencies
make install

# Run postgres locally as a container
make env

# Run server locally
make run

# Run server locally with custom environment variables
MYSQL_URL=root:passwd@tcp(127.0.0.1:3305)/users_db?charset=utf8 \
make run

Setting up git hooks

After cloning the repository, change the git hooks path so it's only possible to commit code with the required quality.

make git-config

Running the tests and coverage report

To view report of tests locally use the following command:

make env # prepares environment for testing
make test

Running the lint verification

make lint

Lint report generate by GolangCI-lint.

Running vulnerability check in Go dependencies

make audit

Audit report generate by Nancy.

Deployment

Build

make build

Create release image, add tag and push

Tip: Do not forget to login to docker hub account.

docker login -u "username" -p "access_token" docker.io
make image tag push

OR

make image
make tag VERSION=1.0.0
sudo make push VERSION=1.0.0

Note: Change the version to the desired version.

Run registry image locally

Tip: Before running it locally you need to prepare the environment with the following command.

make env

It creates the network and the database containers.

make run-docker

make remove-docker

Project Structure

Package organization

The package structure used in this project was inspired by the golang-standards project.

Project layers organization

The project layers structure used in this project was inspired by the Hexagonal Architecture (Ports & Adapters).

Contributing

See CONTRIBUTING documentation for more details.

Changelog

See CHANGELOG documentation for more details.