[![Contributors][contributors-shield]][contributors-url] [![Forks][forks-shield]][forks-url] [![Stargazers][stars-shield]][stars-url] [![Issues][issues-shield]][issues-url] [![MIT License][license-shield]][license-url] [![LinkedIn][linkedin-shield]][linkedin-url]
Table of Contents
This project is using Modular Monolith architecture, but it does not rule out the possibility we rewrite using Microservice architecture.
This section we explain what is backend is develop with
- Golang
- PostgreSQL
- Fiber
- Viper
- Reflex
- Air
- Traefik
- Prometheus
- Grafana
- Fluentd
- Elasticsearch
- Redis
- NATS
- cosul
This is an example of how you may give instructions on setting up your project locally. To get a local copy up and running follow these simple example steps.
-
First you need to install Golang
-
After that check the installation and Golang version it must be above than 1.11 because we need the Golang Modules
> go version go version go1.16.3 darwin/amd64
-
Check if your OS have make, to check it run this command (in my case is using OSX)
❯ make -v GNU Make 3.81 Copyright (C) 2006 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. This program built for i386-apple-darwin11.3.0
-
Docker is required trought our development process, so highly need it
❯ docker version Client: Cloud integration: 1.0.14 Version: 20.10.6 API version: 1.41 Go version: go1.16.3 Git commit: 370c289 Built: Fri Apr 9 22:46:57 2021 OS/Arch: darwin/amd64 Context: default Experimental: true Server: Docker Engine - Community Engine: Version: 20.10.6 API version: 1.41 (minimum version 1.12) Go version: go1.13.15 Git commit: 8728dd2 Built: Fri Apr 9 22:44:56 2021 OS/Arch: linux/amd64 Experimental: false containerd: Version: 1.4.4 GitCommit: 05f951a3781f4f2c1911b05e61c160e9c30eaa8e runc: Version: 1.0.0-rc93 GitCommit: 12644e614e25b05da6fd08a38ffa0cfe1903fdec docker-init: Version: 0.19.0 GitCommit: de40ad0
As you can se the Engine > Version > 20.10.6 (on my OSX)
- Clone the repo
git clone https://github.com/jadahbakar/backend-golang.git
- Install Modules packages
go mod update
- Before to next step, firstable you must manual install reflex
go get github.com/cespare/reflex
- Check reflex installation
relex --help
- This is Optional if point 4 shows error, you must manualy add to SYSTEM PATH \n
in my case i'm using zsh, so add it to .zshrc
After that refresh the console with
export PATH="$PATH:$(go env GOPATH)/bin"
Or❯ . ~/.zshrc
❯ source ~/.zshrc
- Run it
make watch
- Clone the repo
git clone https://github.com/jadahbakar/backend-golang.git
- Run it (it will create docker images and container with autoreload)
make devel-up
- Stop
make devel-down
- Create scaffolding for Monolith - Hexagonal Architechture
- Integrating Viper with go for reading environment variable
- Define on
appConfig
withmapstructure
- Define on
- Config REST API with Fiber, this include:
- Middleware
- Prefork=true
- Config Logger (/log/fiber.log)
- Config CORS
- Config Compress
- Config CSRF
- Server
- Shutdown Normaly
- Graceful Shutdown
- Middleware
- Configuration for Build Golang Manualy go build
- mix recepies Golang with Docker
- Using Traefik for Reverse Proxy
-
Create Watcher with reflex for Development with Hot Reloading - Create Development with Docker and Air for Development with Hot Reloading
- Configure Traefik desktop
- Create Monitoring
- Build and Configure Prometheus
- Build and Configure Grafana
- Colaborate Traefik + Prometheus + Grafana
- Node Health Check
- Deploy on Local kubernetes Container Orchestration
- Centralization logger multistaging (Application, Database) with Fluentd + Elasticsearch
- Create Makefile
- Include external environment file (app.env)
- All In One service (up - clean)
- Development (build - run - watch)
- Development with Docker (devel-up - devel-stop - devel-down)
- Build for Docker (go-buil)
- Docker (docker-build - docker-push - docker-remove-image - docker-remove-container - docker-prune)
- Docker-Compose (compose-up - compose-down - compose-clean)
- Deploy and Configure Redis for caching
- Create Authentication Service
- Create Security Service
- Create Authorization Service
- Create Access Control List for User
- Next Will be Microservice Architechture
- Next Will Using NATS for Message Broker (Microservice Architechture)
- Next Will use Centralizen Configuration (Microservice Architechture)
- Next Will use Service Registery with Health Check (Microservice Architechture)
Distributed under the Proprietary License. See LICENSE
for more information.
- Build Docker Image
- Building APIs with Go — Part 2 -> the newest
- hexagonal-architecture-in-go -> using it now
- stygis-golang-hexagonal-architecture
- how-i-structure-services-in-go
- Load config from file & environment variables in Golang with Viper
- Go Fiber
- Go Fiber 2
- semver for versioning
- string to ascii
- how-to-build-a-smaller-docker-image
- go-docker-dev-environment-with-go-modules-and-live-code-reloadingt
- self-compiling-go-docker-container
- monitoring-traefik-with-grafana <-- Next Implementation