8 months ago, there was only one question that created chaos in my mind. How do banking, healthcare, and government software or private systems work, and what kind of architecture do these systems usually use to separate and maintain business easily?

The Beginning

My first thought was, "They must be monolithic, on-prem etc..." but when complexity increase, it's difficult to maintain the project and obscurity becomes a bottleneck. Somehow, we can separate each business into pieces, but how? After a couple of attempts, I discovered microservice architecture. THAT WAS AWESOME! Because all the questions in my mind were answered in that moment. Then, I've bought books about the microservice. The first book was "Building Microservices: Designing Fine-Grained Systems" by Sam Newman and the other one was "Microservices Patterns: With Examples in Java" by Chris Richardson. Those books gave me the fundamentals I've needed to start a project based on microservice architecture.

The Challenge

But let me be honest, that was incredibly challenging for me because it was difficult to understand how a framework or a useful tool can be integrated into a project that is based on microservice architecture. What about logging, security, deployment, or managing independent libraries… And all these problems have created a learning curve that I've had to handle.

Planning the Project

Finally, I was confident to create a project based on a microservices architecture. I've got a pen and paper, and I started thinking about what type of project I should make. I've decided on a healthcare project because I already knew what a healthcare project looks like from my previous projects that I've worked on with my boys. I've just drawn tons of schema about the database, every module, and connections between the modules and decided which framework, tool, and technology I should use.

Choosing the Programming Language

I've been using Java for almost 3 years and I've gotten used to creating and maintaining Spring Boot projects, so my first attempt was actually using Java as a programming language in my project. But why not Golang? I know both languages and I should give an answer to myself why Java, but not Golang? So it took a week to convince myself.

Here are my notes from that week:

  • Java has a huge ecosystem for creating a microservice project.
  • I can use Spring Boot, and the framework is going to give many and many dependencies as I need.
  • Today's companies are using Java if the project is based on a microservice architecture.
  • I don't need high performance, excellent concurrency; I just need a platform that is suitable, secure and easy to work with.

Choosing the Tools

And here we go, I've decided programming language for creating my project. It was time to choose dependencies and tools that are suitable and would be integrated perfectly into the project.

Message Broker: Kafka

Kafka is a perfect option if you want to make asynchronous communication between the A to B services. RabbitMQ is good too but I want to provide separate data based on topics such as email topic, subs topic, etc. And also, I've worked with Kafka a couple of times in my previous projects and that's why the configuration is not that complicated for me.

API Gateway: Spring Cloud Gateway

I've used Spring Cloud Gateway to ensure security for gathering requests and this way fits in with why I use Java/Spring Boot and its ecosystem.

Databases

What about the databases? Clearly, I was okay with using a different database for each module because loose-coupling is one of the features of microservice architecture:

MySQL for the Doctor Service

Because it's generally optimized for read-heavy operations and offers slightly better performance in that context. I don't need flexibility; just need to read as fast as it should be.

PostgreSQL for the Appointment Service

I've just used PostgreSQL for the Appointment Service because this service is the one that all CRUD operations come to an end. Patient data, doctor data and other related data have created an appointment for a patient. It's the same for the Patient Service and reliable consistency is everything in this module.

MongoDB for the Analytics Service

MongoDB is an excellent choice for the Analytics Service because this service doesn't require ACID, as known as Atomicity, Consistency, Isolation and Durability. MongoDB is optimized for storing large volumes of semi-structured or unstructured data, that's why I've chosen MongoDB.

⚠️ Note: But I must confess this approach is not sustainable if you provide the principles of GreenOps.

Containerization

In containerization, I've chosen Docker and K8s because they were quite easy to manage and maintain but I've upgraded containerization step by step. First of all, I've used Docker all alone but it was harshly difficult to manage multiple containers at the same time. This was the place where K8s welcomed us.

Logging

As a logger, I've just used SLF4J because I wanted to keep it simple as much as I could and I have a long story with SLF4J with Minecraft; I got crashes continuously thanks to this built-in dependency.

The Result

✅ Done: The whole process took 6 months — my sleep schedule collapsed, my friends forgot my face, but at least I got a shiny-tiny microservice project out of it.

The project was not ready-to-deploy but done is better than perfect. After a couple of months, I've just updated the project and named it the Patient Management project. Also, added continuous integration in GitHub to deploy my project to Docker Hub and tons of K8s YAML files. I think the project is super ready to deploy on any cloud platform.

Huh, here is the whole story beyond the project. It was a pleasure to write down in order not to forget the story.