Microservice Boilerplate for Golang with gRPC and RESTful API. Multiple database and client supported

Go Microservice Starter

A boilerplate for flexible Go microservice.

Table of contents

  1. Features
  2. Installation
  3. Todo List
  4. Folder Structures

Features:

  • Multiple database supports
  • MongoDB as starter database
  • Clean architecture with SOLID Principles
  • Factory method implemented
  • Separated use case, handler, and data service layer
  • gRPC support
  • Container caching
  • Superfast logging with Zap

Installation

  1. Clone the repository
git clone https://github.com/zuramai/go-microservice-starter
cd go microservice-starter
  1. Install dependencies
make install
# OR
go mod download
go mod vendor
  1. Run server
make runserver
  1. Run the tests
make runtest

Todo list

  • Add ElasticSearch example
  • Add SQL example
  • Add Docker implementation

Folder structures

This is the top-level project structure:

image

app

image

In app folder, it contains config folder in which all the service config are located in here. There are two config (yaml) files app.dev.yaml for development environment and app.prod.yaml for production environment. We also have appConfig.go where we map all the config into structs.

app/container

image

The dependency injection container, which is responsible for creating concrete types and injecting them into each function. We have containerhelper folder which is in charge of creating every use case into a concrete type.

The dataservicefactory folder is responsible to create concrete type of data service. For instance, we have cacheDataServiceFactory which create connection to Cache GRPC Service. We have userDataServiceFactory which connect to the database, in this context it is MongoDB.

servicecontainer is implementation of container interface. It's Only has one file, which is the key for “container” package. The following is the code. The starting point of it is InitApp, which reads configuration data from a file and set the logger.

usecasefactory: For each use case, such as registration , the interface is defined in usecase package, but the concrete type is defined in registration sub-package under usecase package. Also, there is a factory in the container which is responsible to create the concrete use case instance. For the registration use case, it is registrationFactory.go. The relationship between the use case and the use case factory is one-to-one.

Reference

Thanks to @jfeng45

Owner
Ahmad Saugi
Just an ordinary programmer who want to help others to make coding easier!
Ahmad Saugi
Similar Resources

Go microservice for proxying the Twitch API.

Simple drop-in proxy server for the Twitch API. Built for use with microservice architecture in mind.

Mar 17, 2022

MadeiraMadeira boilerplate project to build scalable, testable and high performance Go microservices.

MadeiraMadeira boilerplate project to build scalable, testable and high performance Go microservices.

Sep 21, 2022

Kitex byte-dance internal Golang microservice RPC framework with high performance and strong scalability, customized extensions for byte internal.

Kitex byte-dance internal Golang microservice RPC framework with high performance and strong scalability, customized extensions for byte internal.

Kitex 字节跳动内部的 Golang 微服务 RPC 框架,具有高性能、强可扩展的特点,针对字节内部做了定制扩展。

Jan 9, 2023

Trying to build an Ecommerce Microservice in Golang and Will try to make it Cloud Native - Learning Example extending the project of Nic Jackson

Golang Server Project Best Practices Dependency Injection :- In simple words, we want our functions and packages to receive the objects they depend on

Nov 28, 2022

Kratos is a microservice-oriented governance framework implements by golang

Kratos is a microservice-oriented governance framework implements by golang

Kratos is a microservice-oriented governance framework implements by golang, which offers convenient capabilities to help you quickly build a bulletproof application from scratch.

Dec 27, 2022

Modern microservice web framework of golang

Modern microservice web framework of golang

gogo gogo is an open source, high performance RESTful api framework for the Golang programming language. It also support RPC api, which is similar to

May 23, 2022

Kratos is a microservice-oriented governance framework implements by golang,

Kratos is a microservice-oriented governance framework implements by golang,

Kratos is a microservice-oriented governance framework implements by golang, which offers convenient capabilities to help you quickly build a bulletproof application from scratch.

Dec 31, 2022

Golang Caching Microservice (bequant.io test project to get hired)

bequant test project How to use: Simply type docker-compose up -d --build db warden distributor in terminal while in project's directory. MySQL, Warde

May 14, 2022

Microservice to manager users with golang

User Service Microservice to manager users. Assumptions & Limitations This API a

Dec 27, 2021
Customer-microservice - Microservice of customer built with golang and gRPC

?? Building microservices to manage customer data using Go and gRPC Command to g

Sep 8, 2022
It's a lean boilerplate to start developing a microservice in Go.

Go microservice starter It's a lean boilerplate to start developing a microservice in Go. Features Gin server Godotenv to load environment variables M

Dec 27, 2021
Microservice - Microservice golang & nodejs
Microservice - Microservice golang & nodejs

Microservice Gabungan service dari bahasa pemograman go, nodejs Demo API ms-auth

May 21, 2022
Microservice - A sample architecture of a microservice in go

#microservice Folder structure required. service certs config config.yaml loggin

Feb 3, 2022
Golang Microservice making use of protobuf and gRPC as the underlying transport protocol.

Go-Microservices Golang Microservice making use of protobuf and gRPC as the underlying transport protocol. I will be building a generic microservice,

Jan 5, 2022
Go gRPC RabbitMQ email microservice

Go, RabbitMQ and gRPC Clean Architecture microservice ?? ??‍?? Full list what has been used: GRPC - gRPC RabbitMQ - RabbitMQ sqlx - Extensions to data

Dec 29, 2022
A microservice gateway developed based on golang.With a variety of plug-ins which can be expanded by itself, plug and play. what's more,it can quickly help enterprises manage API services and improve the stability and security of API services.
A microservice gateway developed based on golang.With a variety of plug-ins which can be expanded by itself, plug and play. what's more,it can quickly help enterprises manage API services and improve the stability and security of API services.

Goku API gateway is a microservice gateway developed based on golang. It can achieve the purposes of high-performance HTTP API forwarding, multi tenant management, API access control, etc. it has a powerful custom plug-in system, which can be expanded by itself, and can quickly help enterprises manage API services and improve the stability and security of API services.

Dec 29, 2022
Gecho-starter - A starter/boilerplate for Golang Echo API

gecho-starter gecho-starter is a boilerplate for writing services in Golang quic

Jul 24, 2022
gRPC to JSON proxy generator following the gRPC HTTP spec
gRPC to JSON proxy generator following the gRPC HTTP spec

The gRPC-Gateway is a plugin of the Google protocol buffers compiler protoc. It reads protobuf service definitions and generates a reverse-proxy server which translates a RESTful HTTP API into gRPC. This server is generated according to the google.api.http annotations in your service definitions.

Jan 3, 2023
Go-relax - Framework for building RESTful API's in Go

Go-Relax Build fast and complete RESTful APIs in Go Go-Relax aims to provide the tools to help developers build RESTful web services, and information

Sep 28, 2022