Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/yhagio/go_api_boilerplate
🐶Go (Golang)🚀REST / GraphQL API + Postgres boilerplate
https://github.com/yhagio/go_api_boilerplate
docker gin gin-gonic go golang gorm gqlgen graphql jwt postgresql rest-api swagger testify
Last synced: 4 months ago
JSON representation
🐶Go (Golang)🚀REST / GraphQL API + Postgres boilerplate
- Host: GitHub
- URL: https://github.com/yhagio/go_api_boilerplate
- Owner: yhagio
- License: mit
- Archived: true
- Created: 2020-02-03T03:43:28.000Z (almost 5 years ago)
- Default Branch: master
- Last Pushed: 2022-12-03T01:00:40.000Z (about 2 years ago)
- Last Synced: 2024-09-26T15:44:32.234Z (4 months ago)
- Topics: docker, gin, gin-gonic, go, golang, gorm, gqlgen, graphql, jwt, postgresql, rest-api, swagger, testify
- Language: Go
- Homepage: https://go-gin-postgres-api.herokuapp.com/graphql
- Size: 450 KB
- Stars: 144
- Watchers: 4
- Forks: 34
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
[![Build Status](https://travis-ci.org/yhagio/go_api_boilerplate.svg?branch=master)](https://travis-ci.org/yhagio/go_api_boilerplate.svg?branch=master)
[![codecov](https://codecov.io/gh/yhagio/go_api_boilerplate/branch/master/graph/badge.svg)](https://codecov.io/gh/yhagio/go_api_boilerplate)
[![MIT Licence](https://badges.frapsoft.com/os/mit/mit.png?v=103)](https://opensource.org/licenses/mit-license.php)
[![Open Source Love](https://badges.frapsoft.com/os/v1/open-source.svg?v=103)](https://github.com/ellerbrock/open-source-badges/)# Go (Golang) REST / GraphQL API Boilerplate
- DEMO (GraphQL Playground): https://go-gin-postgres-api.herokuapp.com/graphql
- DEMO (REST API Swagger): https://go-gin-postgres-api.herokuapp.com/swagger/index.htmlNote: in demo, I disabled email
**Used libraries:**
- [gin](https://github.com/gin-gonic)
- [gin-swagger](https://github.com/swaggo/gin-swagger)
- [gorm](https://gorm.io/docs/)
- [jwt-go](https://pkg.go.dev/gopkg.in/dgrijalva/jwt-go.v3?tab=doc)
- [godotenv](https://pkg.go.dev/github.com/joho/godotenv?tab=doc)
- [gqlgen](https://github.com/99designs/gqlgen)
- [testify](https://github.com/stretchr/testify)
- [go-sqlmock](https://github.com/DATA-DOG/go-sqlmock)---
- Components Diagram
![diagram image](./docs/components-diagram.png)
- See Swagger Doc `http://localhost:3000/swagger/index.html`
![swagger image](./docs/swagger.png)
- See GraphQL Playground `http://localhost:3000/graphql`
![graphql image](./docs/graphql.png)
---
### Features
- [x] User Auth functionality (Signup, Login, Forgot Password, Reset Password)
- [x] JWT Authentication
- [x] REST API
- [x] GraphQL API
- [x] Gorm (Golang SQL DB ORM) with Postgres implementation and auto migration
- [x] Configs via environmental variables
- [x] Email notification (Welcome email, Reset password email)
- [x] Swagger REST API documentation
- [x] GraphQL playground
- [x] Unit tests
- [x] Dependency injection---
### Run locally
Create `.env` at root, i.e.
```sh
MAILGUN_API_KEY=key-b9jksfh8s9843uhfsdhds
MAILGUN_DOMAIN=xxxxx.mailgun.orgEMAIL_FROM=support@go_api_boilerplate.com
DB_HOST=localhost
DB_PORT=5432
DB_USER=your-user
DB_PASSWORD=your-password
DB_NAME=local-dev-dbJWT_SIGN_KEY=secret
HAMC_KEY=secret
PEPPER=secretENV=development
APP_PORT=3000
APP_HOST=http://localhost
```Run
```sh
# Terminal 1
docker-compose up # docker-compose up (Run postgres)
docker-compose down # docker-compose down (Shutdown postgres)# Terminal 2
go run github.com/99designs/gqlgen -v # Generate Graphql stuff
swag init -g app/app.go # Generates Swagger
go run *.go # Run application
go test -v -cover ./... # Run go test
```---
### Todo
- [ ] Input Validations
- [ ] Custom Error messages
- [ ] Logger
- [ ] More unit testsmaybe?
- [ ] gRPC
- [ ] Redis Streams
- [ ] Redis PubSub
- [ ] WebSocket
- [ ] MongoDB---
### Contribution
Welcome for suggestions