All Projects → vardius → Go Api Boilerplate

vardius / Go Api Boilerplate

Licence: mit
Go Server/API boilerplate using best practices DDD CQRS ES gRPC

Programming Languages

go
31211 projects - #10 most used programming language
golang
3204 projects

Projects that are alternatives of or similar to Go Api Boilerplate

Ultimate Backend
Multi tenant SaaS starter kit with cqrs graphql microservice architecture, apollo federation, event source and authentication
Stars: ✭ 978 (+162.2%)
Mutual labels:  microservices, event-sourcing, ddd, cqrs, boilerplate
Quiz
Example real time quiz application with .NET Core, React, DDD, Event Sourcing, Docker and built-in infrastructure for CI/CD with k8s, jenkins and helm
Stars: ✭ 100 (-73.19%)
Mutual labels:  microservices, helm-charts, helm, ddd, cqrs
Pitstop
This repo contains a sample application based on a Garage Management System for Pitstop - a fictitious garage. The primary goal of this sample is to demonstrate several software-architecture concepts like: Microservices, CQRS, Event Sourcing, Domain Driven Design (DDD), Eventual Consistency.
Stars: ✭ 708 (+89.81%)
Mutual labels:  microservices, event-sourcing, ddd, cqrs
Nestjs Cqrs Starter
NestJS CQRS Microservices Starter Project
Stars: ✭ 80 (-78.55%)
Mutual labels:  microservices, event-sourcing, ddd, cqrs
Cronus
Cronus is a lightweight framework for building event driven systems with DDD/CQRS in mind
Stars: ✭ 139 (-62.73%)
Mutual labels:  microservices, event-sourcing, ddd, cqrs
Akkatecture
a cqrs and event sourcing framework for dotnet core using akka.net
Stars: ✭ 414 (+10.99%)
Mutual labels:  microservices, event-sourcing, ddd, cqrs
Akka Ddd
Akka CQRS/ES framework
Stars: ✭ 330 (-11.53%)
Mutual labels:  microservices, event-sourcing, ddd, cqrs
Practical.cleanarchitecture
Asp.Net Core 5 Clean Architecture (Microservices, Modular Monolith, Monolith) samples (+Blazor, Angular 11, React 17, Vue 2.6), Domain-Driven Design, CQRS, Event Sourcing, SOLID, Asp.Net Core Identity Custom Storage, Identity Server 4 Admin UI, Entity Framework Core, Selenium E2E Testing, SignalR Notification, Hangfire Tasks Scheduling, Health Checks, Security Headers, ...
Stars: ✭ 639 (+71.31%)
Mutual labels:  microservices, grpc, oauth2, cqrs
Event Sourcing Jambo
An Hexagonal Architecture with DDD + Aggregates + Event Sourcing using .NET Core, Kafka e MongoDB (Blog Engine)
Stars: ✭ 159 (-57.37%)
Mutual labels:  microservices, event-sourcing, ddd, cqrs
Kreta
Modern project management solution
Stars: ✭ 177 (-52.55%)
Mutual labels:  microservices, event-sourcing, ddd, cqrs
Digital Restaurant
DDD. Event sourcing. CQRS. REST. Modular. Microservices. Kotlin. Spring. Axon platform. Apache Kafka. RabbitMQ
Stars: ✭ 222 (-40.48%)
Mutual labels:  microservices, event-sourcing, ddd, cqrs
Ddd Leaven Akka V2
Sample e-commerce system #Microservices #Akka #Reactive-DDD #CQRS
Stars: ✭ 362 (-2.95%)
Mutual labels:  microservices, event-sourcing, ddd, cqrs
Go Micro Boilerplate
The boilerplate of the GoLang application with a clear microservices architecture.
Stars: ✭ 147 (-60.59%)
Mutual labels:  microservices, grpc, rpc, boilerplate
Dotnet New Caju
Learn Clean Architecture with .NET Core 3.0 🔥
Stars: ✭ 228 (-38.87%)
Mutual labels:  microservices, event-sourcing, ddd, cqrs
Golang Gin Realworld Example App
Exemplary real world application built with Golang + Gin
Stars: ✭ 1,780 (+377.21%)
Mutual labels:  api, restful, best-practices, boilerplate
iam-ddd-cqrs-es-nestjs
Identity and Access Management
Stars: ✭ 34 (-90.88%)
Mutual labels:  cqrs, ddd, event-sourcing
delta
DDD-centric event-sourcing library for the JVM
Stars: ✭ 15 (-95.98%)
Mutual labels:  cqrs, ddd, event-sourcing
RCM
RCM is a simple CRM application designed for Auto Parts Store made with ASP.NET Core based on DDD, CQRS and SOLID Principles.
Stars: ✭ 29 (-92.23%)
Mutual labels:  cqrs, ddd, event-sourcing
ftgogo
FTGOGO - event-driven architecture demonstration application using edat
Stars: ✭ 82 (-78.02%)
Mutual labels:  cqrs, ddd, event-sourcing
order-demo
Axon demo - `Order Management` Information System - A part of the systems landscape https://github.com/fraktalio/courier-demo, https://github.com/fraktalio/restaurant-demo, https://github.com/fraktalio/order-demo
Stars: ✭ 72 (-80.7%)
Mutual labels:  cqrs, ddd, event-sourcing

🧰 Golang API Starter Kit

Build Status Test Go Report Card codecov license baker sponsor

logo

Go Server/API boilerplate using best practices, DDD, CQRS, ES, gRPC.

Table of Contents

📖 ABOUT

The main purpose of this project is to provide boilerplate project setup using best practices, DDD, CQRS, ES, gRPC. Featuring kubernetes for both development and production environments. Allowing to work with environment reflecting production one, allowing to reduce any misconfigurations.

This is mono-repository of many services such as authentication or user domain. Each service has it own code base with exception of shared packages to simplify things for this boilerplate. Services communicate witch each other using gRPC. Each service might expose HTTP API for external communication or/and gRPC.

This project setup should reduce the time spent on environment configuration for the whole kubernetes cluster and/or each of microservice. Extracting each of services to own repository or keeping it as mono-repo should be a matter of preference.

Please look for comments like @TODO and @FIXME to better understand things than need attention.

Web UI example (React)

This boilerplate includes simple Web UI to demonstrate example interaction with API. Once deployed and hosts are set please visit https://api.go-api-boilerplate.local to access UI.

Web UI

Key concepts:

  1. Rest API
  2. Docker
  3. Kubernetes
  4. Helm chart
  5. gRPC
  6. Domain Driven Design (DDD)
  7. CQRS
  8. Event Sourcing
  9. Hexagonal, Onion, Clean Architecture
  10. oAuth2

Worth getting to know packages used in this boilerplate:

  1. gorouter
  2. message-bus
  3. gollback
  4. shutdown
  5. pubsub
  6. pushpull
  7. gocontainer
  8. ardanlabs/service

📚 DOCUMENTATION

🏫 EXAMPLE

Quick start

Localhost alias

Edit /etc/hosts to add localhost alias

➜  go-api-boilerplate git:(master) cat /etc/hosts
##
# Host Database
#
# localhost is used to configure the loopback interface
# when the system is booting.  Do not change this entry.
##
127.0.0.1 go-api-boilerplate.local api.go-api-boilerplate.local maildev.go-api-boilerplate.local mysql.go-api-boilerplate.local

Build release

Local image

make docker-build BIN=auth
make docker-build BIN=migrate
make docker-build BIN=user
make docker-build BIN=web

GitHub Package Registry

Creating tag with metadata will trigger github workflow and publish docker image to GitHub Package Registry.

Tag v1.0.0+user will trigger build for user service releasing 1.0.0 docker image tag. you can create release for all services in cmd directory.

v1.0.0+auth
v1.0.0+user
v1.0.0+web
v1.0.0+migrate

Replace image details in values.yaml

  image:
-    repository: go-api-boilerplate-user
+    repository: docker.pkg.github.com/vardius/go-api-boilerplate/user
-    tag: latest
+    tag: 1.0.0
    pullPolicy: IfNotPresent

repeat for all services and migrate init containers.

Private Registry

If you want your k8sto Pull an Image from a Private Registry on your k8 machine login to docker:

docker login

Then create a secret in go-api-boilerplate namespace as follows:

kubectl create secret generic regcred --from-file=.dockerconfigjson=.docker/config.json --type=kubernetes.io/dockerconfigjson --namespace=go-api-boilerplate

Set imagePullSecrets in your values.yaml file (simply look for all occurrences and uncomment).

+  imagePullSecrets: regcred

Install Cert Manager

helm repo add jetstack https://charts.jetstack.io
helm repo update

make helm-dependencies

Deploy release

make helm-install

Build tags

Build flags are used for different persistence layers. Please see servvices.go file for details. Provided layers are mysql, mongo and memory. If desired in similar way new layer can be easily added, following given patter.

go build -tags=persistence_mysql

Available build tags

  • persistence_mysql (mysql service container)
  • persistence_mongodb (mongodb service container)

Important persistence layer defaults to memory if no flag is provided (Docker image sets persistence_mysql flag), see each service Dockerfile for details.

Domain

Dispatching command

Send example JSON via POST request

curl -d '{"email":"[email protected]"}' -H "Content-Type: application/json" -X POST https://api.go-api-boilerplate.local/users/v1/dispatch/user/user-register-with-email --insecure

View

Public routes

Get user details https://api.go-api-boilerplate.local/users/v1/34e7ed39-aa94-4ef2-9422-401bba9fc812

{"id":"34e7ed39-aa94-4ef2-9422-401bba9fc812","email":"[email protected]"}

Get list of users https://api.go-api-boilerplate.local/users/v1?page=1&limit=10

{"page":1,"limit":20,"total":1,"users":[{"id":"34e7ed39-aa94-4ef2-9422-401bba9fc812","email":"[email protected]"}]}

Protected routes

Access protected route using auth token https://api.go-api-boilerplate.local/users/v1/me.

{"code": "401","message": "Unauthorized"}

Request access token for user

curl -d '{"email":"[email protected]"}' -H "Content-Type: application/json" -X POST https://api.go-api-boilerplate.local/users/v1/dispatch/user/user-request-access-token --insecure

Get your access token from mail catcher https://maildev.go-api-boilerplate.local.

Access protected route using auth token https://api.go-api-boilerplate.local/users/v1/me?authToken=eyJhbGciOiJIUzUxMiIsInR5cCI6IkpXVCJ9.eyJhdWQiOiJyXHUwMDE277-977-977-977-9IiwiZXhwIjoxNTU5NjEwOTc2LCJzdWIiOiIzNGU3ZWQzOS1hYTk0LTRlZjItOTQyMi00MDFiYmE5ZmM4MTIifQ.pEkgtDAvNh2D3Dtgfpu4tt-Atn1h6QwMkDhz4KpgFxNX8jE7fQH00J6K5V7CV063pigxWhOMMTRLmQdhzhajzQ

{"id":"34e7ed39-aa94-4ef2-9422-401bba9fc812","email":"[email protected]"}

💲 Sponsoring

🚀 Contributing

Want to contribute ? Feel free to send pull requests!

Have problems, bugs, feature ideas? We are using the github issue tracker to manage them.

👨🏻‍💻👩🏾‍💻 Core Team:


Rafał Lorenz

Marin Kirkov

👥 Backers

Support us with a monthly donation and help us continue our activities.

🥇 Sponsors

Proudly sponsored by Open Collective sponsors.

📜 License

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].