Skip to content

hiennguyen9874/go-boilerplate-v2

Repository files navigation

Go Restful API Boilerplate

An API Boilerplate written in Golang with chi-route and entgo. Write restful API with fast development and developer friendly.

Architecture

In this project use 3 layer architecture

  • Models
  • Repository
  • Usecase
  • Delivery

Features

  • CRUD
  • Jwt, refresh token saved in redis
  • Cached user in redis
  • Email verification
  • Forget/reset password, send email

Technical

  • chi: router and middleware
  • viper: configuration
  • cobra: CLI features
  • entgo: orm
  • validator: data validation
  • jwt: jwt authentication
  • zap: logger
  • gomail: email
  • hermes: generate email body
  • air: hot-reload

Start Application

Generate the Private and Public Keys

  • Generate the private and public keys: travistidwell.com/jsencrypt/demo/
  • Copy the generated private key and visit this Base64 encoding website to convert it to base64
  • Copy the base64 encoded key and add it to the config/config-local.yml file as jwt
  • Similar for public key

Stmp mail config

  • Create mailtrap account
  • Create new inboxes
  • Update smtp config config/config-local.yml file as smtpEmail

Run

TODO

  • Traefik
  • Config using .env
  • Linter
  • Jaeger
  • Production docker file version
  • Mock database using gomock