High availability cluster -> Spring boot mysql application

Just wondering what is the best way to protect data loss in the event of hardware failure?

The goal is to minimize server downtime and minimize data loss.

We cannot afford big-name cloud database vendors, we will have to do it on our dedicated server(s).

I know traditional backup is not sufficient for this, I am thinking about real-time replication.

One thing I am not sure is, if the master failed due to hardware issues, will the replication automatically becomes master? do I need to config anything from my application (Spring boot)? If the master's hardware issue is fixed, will master automatically sync all data from the replication? Or there are still manual works?

Can someone please recommend a guide for this?

This is what I am thinking, any comments? The proxy/load balancer in the picture is Traefik.