rbutti / go-microservices-goldcopy

A Reference project to act as starter for Go Microservices
Apache License 2.0
0 stars 0 forks source link

go-microservices-goldcopy

A Reference project to implement microservices using go programming language. This project acts as a template/goldcopy to setup and implement microservices using Golang within short period of time.

This application has the following features:

Tools and Technologies

This reference project uses the following tools and technologies:

Technology Version Description
Golang 1.13 Programming language
go-chi 2.1.0 Router Framework
mysql 8.0 Database
gorm 1.9.12 ORM framework
zerolog 1.17.2 Logging framework
Docker 18.09.2 Container Creator
git 2.20.1 Soure Code Management
Goclipse 0.16.1 Integrated Developement Environment

Deliverables

The deliverables for the application can be found at the below location Library-Service/deliverables

Deliverable Summary
Swagger.yaml Swagger documentation for library-service API
ProjectStructure.PNG Diagram depicting the project structure

Assumptions

Execution

Run in local

[PROJECT_LOCATION]/go-microservices-goldcopy/library-service/src

Run Docker image

An docker image of the code is currently pushed into public docker hub repository. Follow the below steps once docker is installed in your local machine

Example

Go to browser and hit the following URL : http://localhost:9090/api/v1/library/books

Expected output

[
   {
      "id":1,
      "title":"I Too Had a Love Story",
      "author":"Ravinder Singh",
      "published_date":"2008-01-01",
      "image_url":"https://images-na.ssl-images-amazon.com/images/I/81phwRtlzCL.jpg",
      "description":"I Too Had a Love Story is an English autobiographical novel written by Ravinder Singh"
   }
]

Technical Design

Project Structure

Project Structure

Package Structure
Package Summary
library-service code containing library microservices
library-service/src golang code of microser
library-service/src/config configuration files
library-service/src/main entrypoint to the application
library-service/src/model models for library service
library-service/src/repository classes to interact with database
library-service/src/server contains routers and handlers of the application
library-service/src/setup setup files used during build
library-service/src/server utility and constant files
Model
Class Summary
book.go Domain object representing a book
bookDto.go Data transfer object for book domain object
bookForm.go presentation object for book domain object
Class Design
Class Summary
libraryApp.go Entrypoint to the Application consisting main() method
appConfig.go Contains configuration related to applction like server details etc
ormConfig.go Contains configuration related to database and gorm
bookRepo.go Repository class to perform CRUD operation on Book table
handler.go Application request handler
handlerWrapper.go Wrapper for request handler and logging
rootHander.go handles request to '/'
libraryHander.go handles request to '/api/vi/library-service'
libraryHander.go handles request to '/health'
router.go routes the request to necessary handler
responseInterceptor.go intercepts router reponse
constants.go contains application constants
logger.go wrapper to zerolog framework
logEntry.go log entry formatter

Future Enhancements

Contact Information

Author : Ravikiran Butti, Email Id : (ravikiran763@gmail.com)