Skip to content

A simple job scheduler microservice application using various programming languages for different services to demonstrate the flexibility of microservices architecture in terms of independence from specific technologies..

License

Notifications You must be signed in to change notification settings

KhaledHosseini/play-microservices

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Play microservice

play-microservices

A simple job scheduler app using microservices architecture. Users can # (as admin or normal role).

  • Admins can query the list of all users.
  • Admins can schedule email jobs to be run in the future.
  • Admins can query the reports.

Just run docker-compose up from the root directory(This downloads half of the internet onto your computer! A considerable amount of disk space is needed!). Then go to http://localhost:3000/

Image1

Image2

Articles:

  • Plan: Read
  • Authentication service: Rust Read
  • Scheduler service: Go Read
  • Email service: Python Read
  • Report service: Python Read
  • API gateway service: Go Read
  • Client service: Typescript Read
  • Integration via docker-compose: Read
  • Security: Read

Choreography

Choreography


CI / CD Flow diagram

Choreography


Technologies per service

  • Auth service

    • Rust: Programming language
    • postgres: database
    • redis: cache
    • Tonic: gRPC framework for Rust
    • Diesel: Query builder and ORM for our database communication.
    • Redis : For our redis server communications in rust.
  • Scheduler service

    • Golang : programming language
    • gRPC-GO: gRPC framework for golang
    • Mongo driver: Query builder for our database communication.
    • Kafka go for our message broker communications from go.
    • Quartz for scheduling purposes.
  • Email job executor service

    • Python : programming language
    • Kafka-python: For our message broker communications from go.
  • Reports service

    • Python : programming language
    • grpc: gRPC framework for python
    • Pymongo: Query builder for our database communication.
    • Kafka-Python for our message broker communications from python.
    • grpcio-tools For compiling .proto files to python.
  • API gateway service

    • Golang : programming language
    • gRPC-GO: gRPC framework for golang
    • Gin: Is a web framework written in Golang
    • gin-swagger for our rest api documentation.
  • Client service


How to add my simple service?

  • Backend GRPC service
    • Create and develop your gRPC service independently. For authentication, consider accepting an environment variable called AUTH_PUBLIC_KEY_FILE to read authentication public key for verifying authorization header which is a simple jwt with role (admin or user ) for authorization.
    • Do the follwing to the api-gateway service (For more info see Here).
      • Put your .proto file inside proto folder. Run source build_grpc.sh to compile your .proto file.
      • In api-gateway, inside internal/models folder create a file named <yourmodelname> and create the necessary rest layer models and the conversion to/from proto models.
      • Add <YOURSERVICE>_URL to the config/config.go
      • Create a folder named <yourmodelname> inside internal/models
      • Inside <yourmodelname> folder create a folder named grpc and then a file named client_service.go. Put your grpc service communication logic here (Read <YOURSERVICE>_URL from config).
      • Inside <yourmodelname> folder create a folder named handler and then a file named handler.go. Put your rest api for your grpc model here.
      • Add your rest-api end points to internal/api/router.go
  • Front-end service
    • Check the api-gateway rest api from here.
    • Develop your client application to communicate with the rest api.

Finally add your service to the docker-compose.yml of the play-microservices. Add <YOURSERVICE>_URL to the api gateway environment variables. Also add AUTH_PUBLIC_KEY_FILE=/run/secrets/auth-access-public-key environemt variable to your service.


Developing / Debuging

Services have been developed independently from each other. To debug each of the services, just run docker-compose up -d --build from the folder of the service. Then using VSCode extension Dev Containers attach to the running container (Each service has several other dependent services in developement. Select the main service). Then open usr/src/app folder inside the container and finally run the appropriate commands based on the project (For more information on how to debug the services, see articles above). Example: Auth service

  • cd to auth folder
  • Run docker-compose up -d --build
  • While running, click on the bottom left button to open a remote window via Dev Containers
  • Select attach to running container then select authentication-service. Wait until the vscode new window starts.
  • Open folder usr/src/app inside container. This folder is mounted to auth-service folder inside the host.
  • Open a new terminal and run cargo run
  • Start debugging. For more info see Here

Roadmap

  • Add tests
  • Add tracing
  • Deploy to CI/CD environment via Jenkins

License

MIT License

About

A simple job scheduler microservice application using various programming languages for different services to demonstrate the flexibility of microservices architecture in terms of independence from specific technologies..

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published