This is a classic RS485 circuit that I realize is not that good. It works fine, but it requires that ground always is included because of the 12V diodes.
This simplified circuit is in many ways better as we actually can use a twisted pair only. This shows a none-isolated RS-X port. I also drag both RE and DE into the MCU so we can send and receive at the same time. In fact, I could save a pin by setting RE to GND and always receive. I also avoided the leds and some 47Ohm line resistors. I also change to 3.3V version.
This last circuit is a fully isolated RS485 using ADM2582E. This includes a DC/DC and is completely isolated, but it also requires more space and cost ca 5.- USD more.