Laptop Booking Application in Golang and gRPC, load-balancing with NGINX, and fully compatible with HTTPS OpenAPI v3

Laptop Booking Application in Golang and gRPC

ci-test gopherbadger-tag-do-not-edit

Goals

  • GitHub CI & Coverage Badge
  • Serialize protobuf messages
  • Create laptop unary gRPC
  • Search laptop Server-streaming gRPC
  • Chunk uploading image with client-streaming gRPC
  • Laptop rating bidirectional-streaming gRPC
  • gRPC reflection and Evans CLI + grpcui
  • Add user API
  • gRPC interceptor & JWT authentication with refresh token
  • Secure gRPC connection with Mutual SSL/TLS
  • Load balancing gRPC Mutual SSL/TLS services with NGINX
  • Generate RESTful service and OpenAPI documentation with gRPC gateway
  • Using Microcks/Postman to test OpenAPI endpoints

Technology Stack

Get Start

  • Clean the generated Go code: make clean
  • Generate Go code of gRPC proto files: make gen
  • Run the server: make server
  • Run the client: make client
  • Run the tests: make test
  • Run the coverage and update the badge: make badge
  • Run the Evans CLI: make evans
  • Run the grpcui Web Interface: make grpcui
  • Verify the SSL certs: make verifyssl
  • Remake SSL certs: make cert
  • Update NGINX configs and certs: make nginxconf
  • Start server 1 with TLS: make server1tls
  • Start server 2 with TLS: make server2tls
  • Start client with TLS: make clienttls
  • Start base server: make server
  • Start rest server: make rest
  • Start client to populate data: make client

Sample

  • NGINX config
See details
worker_processes 1;

error_log /home/savaka/go/src/github.com/lavantien/go-laptop-booking/log/nginx/error.log;

events {
	worker_connections 10;
}

http {
	access_log /home/savaka/go/src/github.com/lavantien/go-laptop-booking/log/nginx/access.log;

	upstream auth_services {
		server 0.0.0.0:50051;
	}

	upstream laptop_services {
		server 0.0.0.0:50052;
	}

	server {
		listen 8080 ssl http2;

		# Mutual TLS between gRPC client and NGINX
		ssl_certificate cert/server-cert.pem;
		ssl_certificate_key cert/server-key.pem;

		ssl_client_certificate cert/ca-cert.pem;
		ssl_verify_client on;

		location /pb.AuthService {
			grpc_pass grpcs://auth_services;

			# Mutual TLS between NGINX and gRPC server
			grpc_ssl_certificate cert/server-cert.pem;
			grpc_ssl_certificate_key cert/server-key.pem;
		}

		location /pb.LaptopService {
			grpc_pass grpcs://laptop_services;

			# Mutual TLS between NGINX and gRPC server
			grpc_ssl_certificate cert/server-cert.pem;
			grpc_ssl_certificate_key cert/server-key.pem;
		}
	}
}
  • Some REST endpoints:
See details
POST http://localhost:8081/v1/auth/login
{
  "username": "admin1",
  "password": "secret"
}
# Result
{
    "accessToken": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJleHAiOjE2NDE4MjkwNTAsInVzZXJuYW1lIjoiYWRtaW4xIiwicm9sZSI6ImFkbWluIn0.ZEXQ6XAiZsuTthepwUVxioYXJX-O0jXBIFaNtnWsicU"
}

GET http://localhost:8081/v1/laptop/search?filter.max_price_usd=5000&filter.min_cpu_cores=2&filter.min_cpu_ghz=2.0&filter.min_ram.value=3&filter.min_ram.unit=GIGABYTE
# Result (not a list because the nature of server-streaming)
{
    "result": {
        "laptop": {
            "id": "59811686-1bad-4755-9e00-b6519f082479",
            "brand": "Lenovo",
            "name": "Thinkpad X1",
            "cpu": {
                "brand": "Intel",
                "name": "Core i3-1005G1",
                "numberCores": 7,
                "numberThreads": 11,
                "minGhz": 3.25690128346152,
                "maxGhz": 4.869019798140393
            },
            "ram": {
                "value": "13",
                "unit": "GIGABYTE"
            },
            "gpus": [
                {
                    "brand": "NVIDIA",
                    "name": "RTX 2060",
                    "minGhz": 1.4789741714465086,
                    "maxGhz": 1.4922565481488161,
                    "memory": {
                        "value": "6",
                        "unit": "GIGABYTE"
                    }
                }
            ],
            "storages": [
                {
                    "driver": "SSD",
                    "memory": {
                        "value": "745",
                        "unit": "GIGABYTE"
                    }
                },
                {
                    "driver": "HDD",
                    "memory": {
                        "value": "1",
                        "unit": "TERABYTE"
                    }
                }
            ],
            "screen": {
                "sizeInch": 13.32892,
                "resolution": {
                    "width": 6499,
                    "height": 3656
                },
                "panel": "IPS",
                "multitouch": false
            },
            "keyboard": {
                "layout": "QWERTZ",
                "backlit": false
            },
            "weightKg": 1.7393324744695426,
            "priceUsd": 1501.6397915075097,
            "releaseYear": 2016,
            "updatedAt": "2022-01-10T15:36:56.420852677Z"
        }
    }
}
{
    "result": {
        "laptop": {
            "id": "d05e0809-09d2-4f7e-8fed-b1089513885d",
            "brand": "Apple",
            "name": "Macbook Pro",
            "cpu": {
                "brand": "Intel",
                "name": "Core i7-9750H",
                "numberCores": 6,
                "numberThreads": 11,
                "minGhz": 3.1830385478225462,
                "maxGhz": 4.256661649154569
            },
            "ram": {
                "value": "18",
                "unit": "GIGABYTE"
            },
            "gpus": [
                {
                    "brand": "NVIDIA",
                    "name": "RTX 2070",
                    "minGhz": 1.4077473666779245,
                    "maxGhz": 1.964320393328977,
                    "memory": {
                        "value": "2",
                        "unit": "GIGABYTE"
                    }
                }
            ],
            "storages": [
                {
                    "driver": "SSD",
                    "memory": {
                        "value": "303",
                        "unit": "GIGABYTE"
                    }
                },
                {
                    "driver": "HDD",
                    "memory": {
                        "value": "2",
                        "unit": "TERABYTE"
                    }
                }
            ],
            "screen": {
                "sizeInch": 16.230564,
                "resolution": {
                    "width": 3004,
                    "height": 1690
                },
                "panel": "OLED",
                "multitouch": false
            },
            "keyboard": {
                "layout": "QWERTY",
                "backlit": true
            },
            "weightKg": 1.344500870876185,
            "priceUsd": 2369.4463119126813,
            "releaseYear": 2017,
            "updatedAt": "2022-01-10T15:36:56.421404861Z"
        }
    }
}
  • Laptop JSON
See datails
{
  "id": "21d24c33-13fc-49cb-9e15-85969be270b5",
  "brand": "Apple",
  "name": "Macbook Pro",
  "cpu": {
    "brand": "AMD",
    "name": "Ryzen 7 PRO 2700U",
    "number_cores": 4,
    "number_threads": 11,
    "min_ghz": 2.4010226599566113,
    "max_ghz": 3.3472808181192493
  },
  "ram": {
    "value": "56",
    "unit": "GIGABYTE"
  },
  "gpus": [
    {
      "brand": "AMD",
      "name": "RX 580",
      "min_ghz": 1.438777166984461,
      "max_ghz": 1.9419486357490028,
      "memory": {
        "value": "6",
        "unit": "GIGABYTE"
      }
    }
  ],
  "storages": [
    {
      "driver": "SSD",
      "memory": {
        "value": "712",
        "unit": "GIGABYTE"
      }
    },
    {
      "driver": "HDD",
      "memory": {
        "value": "3",
        "unit": "TERABYTE"
      }
    }
  ],
  "screen": {
    "size_inch": 15.036544,
    "resolution": {
      "width": 4325,
      "height": 2433
    },
    "panel": "OLED",
    "multitouch": false
  },
  "keyboard": {
    "layout": "AZERTY",
    "backlit": false
  },
  "weight_kg": 1.7960889307648087,
  "price_usd": 1841.1951352165595,
  "release_year": 2015,
  "updated_at": "2022-01-06T22:55:18.744484334Z"
}
Owner
Tien La
"All is burning.. Burning with what? Burning with the fires of greed, hate, and delusion." - SN 35.28
Tien La
Similar Resources

Go-grpc-template - A small template for quickly bootstrapping a, developer platform independent gRPC golang application

Go-grpc-template - A small template for quickly bootstrapping a, developer platform independent gRPC golang application

go-grpc-template A small template for quickly bootstrapping a developer platform

Jan 20, 2022

Compiler as a Service is a compiler that is available over http/https and gRPC

BlakBoks(CaaS) Elasticsearch but for compiling untrusted code Compiler as a Service is a compiler that is available over http/2 and gRPC. Setup First

Nov 24, 2021

gRPC LRU-cache server and client with load test

gRPC k-v storage with LRU-cache server & client + load test. Specify LRU-cache capacity: server/cmd/app.go - StorageCapacity go build ./server/cmd/*

Dec 26, 2021

Using Envoy Proxy to load-balance gRPC services on GKE with header value based Session Affinity

Using Envoy Proxy to load-balance gRPC services on GKE with header value based S

Aug 24, 2022

Go-grpc - This is grpc server for golang.

go-grpc This is grpc server for golang. protocのインストール brew install protoc Golang用のプラグインのインストール go install google.golang.org/protobuf/cmd/protoc-gen-go

Jan 2, 2022

High-performance PHP application server, load-balancer and process manager written in Golang

High-performance PHP application server, load-balancer and process manager written in Golang

RoadRunner is an open-source (MIT licensed) high-performance PHP application server, load balancer, and process manager. It supports running as a serv

Jan 1, 2023

High-performance PHP application server, load-balancer and process manager written in Golang

High-performance PHP application server, load-balancer and process manager written in Golang

RoadRunner is an open-source (MIT licensed) high-performance PHP application server, load balancer, and process manager. It supports running as a serv

Dec 9, 2021

Server and client implementation of the grpc go libraries to perform unary, client streaming, server streaming and full duplex RPCs from gRPC go introduction

Description This is an implementation of a gRPC client and server that provides route guidance from gRPC Basics: Go tutorial. It demonstrates how to u

Nov 24, 2021

Simple grpc web and grpc transcoding with Envoy

Simple grpc web and grpc transcoding with Envoy

gRPC Web and gRPC Transcoding with Envoy This is a simple stand-alone set of con

Dec 25, 2021
Grpc-train - Train booking demo using gRPC

gRPC Demo: Train Booking Service Description Usage Contributing Development Tool

Feb 6, 2022
Client-Side Load Balancing for Golang

cslb Client-Side Load Balancer This Project is in early developing state Feature Multiple client-side load balancing solutions support Round-Robin DNS

Aug 29, 2022
DNS/DoT to DoH proxy with load-balancing, fail-over and SSL certificate management

dns-proxy Configuration Variable Example Description TLS_DOMAIN my.duckdns.org Domain name without wildcards. Used to create wildcard certificate and

Oct 26, 2022
Seesaw v2 is a Linux Virtual Server (LVS) based load balancing platform.

Seesaw v2 Note: This is not an official Google product. About Seesaw v2 is a Linux Virtual Server (LVS) based load balancing platform. It is capable o

Jan 3, 2023
Consul Load-Balancing made simple
Consul Load-Balancing made simple

Notes From release 1.5.15 onward, fabio changes the default GOGC from 800 back to the golang default of 100.

Dec 27, 2022
Consul Load-Balancing made simple
Consul Load-Balancing made simple

Notes From release 1.5.15 onward, fabio changes the default GOGC from 800 back to the golang default of 100. Apparently this made some sense back in t

Dec 31, 2022
Serve endpoint metadata for client side load balancing

Servok Servok is a service that provides endpoint metadata for client side load balancing. See CONTRIBUTING.md for instructions on how to contribute a

Dec 9, 2021
protoc-gen-grpc-gateway-ts is a Typescript client generator for the grpc-gateway project. It generates idiomatic Typescript clients that connect the web frontend and golang backend fronted by grpc-gateway.

protoc-gen-grpc-gateway-ts protoc-gen-grpc-gateway-ts is a Typescript client generator for the grpc-gateway project. It generates idiomatic Typescript

Dec 19, 2022
Golang http&grpc server for gracefully shutdown like nginx -s reload

supervisor Golang http & grpc server for gracefully shutdown like nginx -s reload if you want a server which would be restarted without stopping servi

Jan 8, 2022
Xray, Penetrates Everything. Also the best v2ray-core, with XTLS support. Fully compatible configuration.

Project X Project X originates from XTLS protocol, provides a set of network tools such as Xray-core and Xray-flutter. License Mozilla Public License

Jan 7, 2023