Awesome Open Source
Awesome Open Source

Build Status codecov MIT Licence Open Source Love

Go (Golang) REST / GraphQL API Boilerplate

Note: in demo, I disabled email

Used libraries:


  • Components Diagram

diagram image

  • See Swagger Doc http://localhost:3000/swagger/index.html

swagger image

  • See GraphQL Playground http://localhost:3000/graphql

graphql image


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.

MAILGUN_API_KEY=key-b9jksfh8s9843uhfsdhds
MAILGUN_DOMAIN=xxxxx.mailgun.org

[email protected]_api_boilerplate.com

DB_HOST=localhost
DB_PORT=5432
DB_USER=your-user
DB_PASSWORD=your-password
DB_NAME=local-dev-db

JWT_SIGN_KEY=secret
HAMC_KEY=secret
PEPPER=secret

ENV=development

APP_PORT=3000
APP_HOST=http://localhost

Run

# 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 tests

maybe?

  • [ ] gRPC
  • [ ] Redis Streams
  • [ ] Redis PubSub
  • [ ] WebSocket
  • [ ] MongoDB

Contribution

Welcome for suggestions



Alternative Project Comparisons
Related Awesome Lists
Top Programming Languages
Top Projects

Get A Weekly Email With Trending Projects For These Topics
No Spam. Unsubscribe easily at any time.
Golang (155,676
Docker (96,957
Rest (29,294
Postgresql (23,137
Rest Api (15,892
Graphql (15,591
Jwt (9,730
Swagger (7,937
Gin (1,607
Gorm (981
Gin Gonic (212
Gqlgen (42
Testify (19