Skip to content

OBU Tracker with data aggregation and gateway back-end service: Microservices with GRPC & HTTP transport layers, Kafka, Prometheus, Grafana

License

Notifications You must be signed in to change notification settings

mcgtrt/toll-tracker

Repository files navigation

toll-tracker

OBU Tracker with data aggregation and gateway back-end service.

Stack:

Microservices, Kafka, Prometheus, Grafana

Transport between microservices:

  • HTTP(JSON API) - native http & net servers and listeners, no fancy packages.
  • GRPC with Protobuffers

Microservices structure

  1. OBUs (On-Board Units) => Generate OBUID with coordinates and sends them to data_receiver

  2. Receiver/Producer (data_receiver) => Awaits for OBU Data and produces to Kafka

  3. Kafka (docker installation with zookeeper)

  4. Distance Calculator (distance_calc) => Polls data from Kafka and calculates the distance base on received

coordinates. Then uses the (5. Aggregator)'s Client to store it and process via gRPC or HTTP Transport layer.

  1. Aggregator => CRUD operations for OBU Distance, invoicer, and data provider for the Gateway.

5.1. Prometheus implementation will only be present as the middleware for aggregator interface methods

  1. Gateway => User facing API, communicating with Aggregator API

Bonus

Enterprise-standard implementation of the Aggregator service (go-kit-example/aggsvc)

NOTE

This is a project demonstrating how to structure, connect, and build transport between microservices.

It may not include the full business logic, all endpoints or data storage (like NoSQL).

All operations are handled in memory to prove the concept and make the application work properly.

For business logic implementation, check out the Hotel API or other projects.

Project setup and installation guide

Kafka docker

docker run --name kafka -p 9092:9092 -e ALLOW_PLAINTEXT_LISTENER=yes -e KAFKA_CFG_AUTO_CREATE_TOPICS_ENABLE=true bitnami/kafka:latest 

Also available via included docker-compose.yml file

docker-compose up      (or with daemon / background) -d

Installing protobuf compiler (protoc compiler)

For linux users or (WSL2)

sudo apt install -y protobuf-compiler

For Mac users use Homebrew

brew install protobuf

Installing GRPC and Protobuffer plugins for Golang.

  1. Protobuffers
go install google.golang.org/protobuf/cmd/protoc-gen-go@v1.28
  1. GRPC
go install google.golang.org/grpc/cmd/protoc-gen-go-grpc@v1.2
  1. Set the /go/bin directory to its local dir
PATH="${PATH}:${HOME}/go/bin"
  1. Install the package dependencies
  • Protobuffer package
go get google.golang.org/protobuf
  • gRPC Package
go get google.golang.org/grpc/

Prometheus

  1. Install Prometheus (Docker)
docker run --name prometheus -d -p 127.0.0.1:9090:9090 prom/prometheus
  1. Install prometheus client
go get github.com/prometheus/client_golang/prometheus

Grafana

docker run -d -p 3000:3000 --name=grafana grafana/grafana-enterprise

About

OBU Tracker with data aggregation and gateway back-end service: Microservices with GRPC & HTTP transport layers, Kafka, Prometheus, Grafana

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published