Skip to content

Java Spring-boot Micro-services blueprint

License

omerahmed41/java-microservices

Repository files navigation

Java Spring-boot- Microservices

Java Spring-boot Micro-services blueprint

Features:

  • Spring-boot fresh build
  • docker with Docker compose.
  • open API and swagger.
  • makefile.
  • Logs slf4j.
  • message broker - rabbitmq.
  • auth service- keycloak ( todo).
  • Service registry.
  • API-gateway.
  • Design patterns (Pub-Sub, Command, Repository, Singleton).
  • layer architecture (DDD).
  • SpringBoot CI/CD Pipeline.
  • kubernetes.

System Architecture:

billie

Setup:

run:

  • make build
  • make run
  • to reload the Service use make reload

RabbitMq Dashboard:

rabbitmq

Eureka Service:

to see all Instances currently registered with Eureka

Services

Docs:

I used OpenAPI with swagger for API docs, also followed Domain driven design with services Layer architecture to make it easy to understand the code

Lastly the Naming of Classes, methods and objects is meaningful.

to check the API docs on localhost:

When use frontend like React.js or any client we can the advantage of the API gateway.

Communications:

For Async communications I used rabbitmq, and for sync I used normal http calls later on grpc will be good use, also we can use REDIS as improvement.

Calculate Invoices:

To achieve low latency: we crete empty invoice with Due_date based on client billing_interval everytime We are adding new client, then every time we add a new transaction to the system we process it and add it to the invoice, then we run a cron job every day to process all Due date invoices. after invoice is processed we mark it as done and create new one with new due date.

Design Patterns:

  • Pub-Sub: I used bub-sub model along with events streaming broker rabbitmq.
  • Command: I used two commands class for chargeClientCommand and createInvoiceCommand.
  • Repository: Used repository pattern to decouple Domain layer from DB layer, for example we can mock the repository and use DB memory.
  • Singleton: Singleton pattern is used in Spring bean.

CI/CD:

Two steps: Build with tests, then Deploy.

I commented the part of pushing the images to DockerHub then uploading it to the cloud but, you can easily uncomment that to make it work.

Todo:

the goal was to build the skeleton and base Architecture of the system, but these are Things need to be done when have more time:

  • Review and add more unit, integrations, contracts and App tests.

  • Build Frontend with React.js.

  • Add more App Validations.

  • Focus more on documentation.

  • Auth Service with Keycloak.

  • REDIS.

  • GRPC (support HTTP2/Websocket).

  • Note make sure you have Docker installed and give it enough memory from the setting, because we have 6 services running with 4 DBs.

Screen Shot 2022-08-07 at 3 53 13 PM

About

Java Spring-boot Micro-services blueprint

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages