https://github.com/archit-p/microservicetemplate
Template for microservices built with Go.
https://github.com/archit-p/microservicetemplate
crud go golang microservices mongodb rest-api
Last synced: 9 months ago
JSON representation
Template for microservices built with Go.
- Host: GitHub
- URL: https://github.com/archit-p/microservicetemplate
- Owner: archit-p
- License: mit
- Created: 2020-08-14T12:39:26.000Z (almost 6 years ago)
- Default Branch: master
- Last Pushed: 2020-08-16T10:48:01.000Z (almost 6 years ago)
- Last Synced: 2025-05-15T12:09:56.649Z (about 1 year ago)
- Topics: crud, go, golang, microservices, mongodb, rest-api
- Language: Go
- Homepage:
- Size: 33.2 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE.md
Awesome Lists containing this project
README
[](https://travis-ci.org/archit-p/MicroserviceTemplate)
[](https://goreportcard.com/report/github.com/archit-p/MicroserviceTemplate)
[](https://www.codacy.com/manual/archit-p/MicroserviceTemplate?utm_source=github.com&utm_medium=referral&utm_content=archit-p/MicroserviceTemplate&utm_campaign=Badge_Grade)
[](https://sonarcloud.io/dashboard?id=MicroserviceTemplate)
[](https://sonarcloud.io/dashboard?id=MicroserviceTemplate)
Go Microservice built using best practices, ideal for use as a starter template. It features an extensible model - Sample - with support for CRUD and Search operations for MongoDB.
## References
This project is inspired by multiple blogs and guides on best practices while writing Go code. I'm sharing links to these below.
### Project Structure
1. [How to Write Go Code](https://golang.org/doc/code.html)
2. [golang-standards/project-layout](https://github.com/golang-standards/project-layout)
3. [Organizing Database Access](https://www.alexedwards.net/blog/organising-database-access)
### Documentation
1. [Documenting APIs with Swagger](https://swagger.io/resources/articles/documenting-apis-with-swagger/)
2. [Documenting Go Code](https://blog.golang.org/godoc)
### Containerization
1. [Docker: Multi-Stage Builds](https://docs.docker.com/develop/develop-images/multistage-build/)
2. [Why You Should Use Microservices and Containers](https://developer.ibm.com/technologies/microservices/articles/why-should-we-use-microservices-and-containers/)
### Testing
1. [Structuring Tests in Go](https://medium.com/@benbjohnson/structuring-tests-in-go-46ddee7a25c)
2. [Testing Web-Apps in Go](https://markjberger.com/testing-web-apps-in-golang/)
## Getting Started
### Clone the Repo
```sh
$ git clone https://github.com/archit-p/MicroserviceTemplate
```
### Build and Run
```sh
$ make help
Run make where target is
help: print out this message
build: build the executables
run: start a clean build, and run executable
test: run go tests
docs: build documentation
clean: clean executables and docs
$ make run
```
## Project Layout
```text
cmd (contains code for our apps)
|-+ web (server router and controllers)
pkg (contains reusable code)
|-+ dto (data-transfer objects)
|-+ models (database models)
|-+ mongodb (models for mongo-db)
|-+ docs (swagger documentation)
```
## Docs
Once the service is running, accompanying Swagger docs can be found at `http://localhost:8080/swagger/index.html`.
## Contributing
Feel free to fork the project for use as a base template for your next microservice or REST API!
## Built Using
[](https://golang.org)
[](https://www.mongodb.com/)
[](https://www.docker.com/)