microservices-go

command module
v0.0.0-...-3ccc3fb Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 16, 2023 License: MIT Imports: 12 Imported by: 0

README

Golang Microservices Boilerplate - Clean Architecture

issues license CodeFactor Maintainability

Example structure to start a microservices project with golang. Using a MySQL databaseSQL. Using a Hexagonal Architecture tha is a Clean Architecture.

Manual Installation

If you would still prefer to do the installation manually, follow these steps:

Clone the repo:

git clone https://github.com/phoenixTW/microservices-go

If you need, configure the environment variables in file config.json, if you use docker-compose leave the variables set in the file config.json.example

cp config.json.example config.json

TL;DR command list

git clone https://github.com/phoenixTW/microservices-go
cd microservices-go
cp config.json.example config.json
docker-compose up  --build  -d

Table of Contents

Features

  • Golang v1.21: Stable version of go
  • Framework: A stable version of gin-go
  • Token Security: with JWT
  • SQL databaseSQL: MariaDB using internal sql package of go sql
  • Testing: unit and integration tests using package of go testing
  • API documentation: with swaggo @latest version that is a go implementation of swagger
  • Dependency management: with go modules
  • Environment variables: using viper
  • Docker support
  • Code quality: with CodeFactor and Codacy
  • Linting: with golangci-lint an implementation of a Golang linter

Commands

Build and run image of docker
docker-compose up  --build  -d
Swagger Implementation
swag init -g infrastructure/rest/routes/routes.go

To visualize the swagger documentation on local use

http://localhost:8080/v1/swagger/index.html

Unit test command
# run recursive test
go test  ./test/unit/...
# clean go test results in cache
go clean -testcache
Lint inspection of go
golangci-lint run ./...

Documentation

Overview

Package main is the entry point of the application

Directories

Path Synopsis
application
security/jwt
Package jwt implements the JWT authentication
Package jwt implements the JWT authentication
usecases/auth
Package auth provides the use case for authentication
Package auth provides the use case for authentication
usecases/user
Package user provides the use case for user
Package user provides the use case for user
Package docs Code generated by swaggo/swag.
Package docs Code generated by swaggo/swag.
domain
errors
Package errors defines the domain errors used in the application.
Package errors defines the domain errors used in the application.
user
Package user contains the business logic for the user entity
Package user contains the business logic for the user entity
infrastructure
repository/config
Package config provides the database connection
Package config provides the database connection
repository/user
Package user contains the business logic for the user entity
Package user contains the business logic for the user entity
rest/adapter
Package adapter is a layer that connects the infrastructure with the application layer
Package adapter is a layer that connects the infrastructure with the application layer
rest/controllers
Package controllers contains the common functions and structures for the controllers
Package controllers contains the common functions and structures for the controllers
rest/controllers/auth
Package auth contains the auth controller
Package auth contains the auth controller
rest/controllers/errors
Package errors contains the error handler controller
Package errors contains the error handler controller
rest/controllers/user
Package user contains the user controller
Package user contains the user controller
rest/middlewares
Package middlewares contains the middlewares for the rest api
Package middlewares contains the middlewares for the rest api
rest/routes
Package routes contains all routes of the application
Package routes contains all routes of the application
Package utils contains the common functions and structures for the application
Package utils contains the common functions and structures for the application

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL