Control several binary outputs with raspberry pi, CD74HC273 D-type flip flops and 5v relays
I think it would be very helpful for the community if you explain us for which application on the secondary side you want to build this circuit. I'm confused about your "relay" (not a simple relay) shown in your link above. The relay itself is a good isolator, so the primary side (arduino) is completely galvanically isolated from your 12V system and there is no need to add an optocoppler to it. The optocoppler is useless. Rather, the optocoupler needs an additional current, space, costs and last but not least, it also ages and may fail. I also found a good replacement of your shown relay similar but with a high-level trigger e.g. here:
https://www.amazon.fr/dp/B07V1X2RSP/ref=psdc_2908498031_t3_B07BVXT1ZK?th=1

But I would build such a circuit by myself.
BTW, I hope you'll place some C (10nF or 100nF) to the 74HC273 IC for stabilization the power supply. 







simulate this circuit &ndash; Schematic created using CircuitLab

Update:
@Ouhbelle Probably this is the circuit of the relay I have linked? Because this schematics has two important problems. The transistor's Collector and Emitter have to be swapped. And the diode (LED) in the signal line my cause problems in the long run. You know company Eumig? - They put in something like this to do some sort of rectification. After a couple of months, one after the other devices have failed. And ruined their business. Imagine, if the signal (from 74HC) is 0, and the transistor ages and get higher temperatures, there is a little flow from 5v reverse current from C to the B of the transistor and it could start a current flow heating up the transistor. Remedy: Short-circuit (bypass) the LED and change resistor to a higher value of about 1k - 2k2 or you could place an additional resistor from B to GND.

I think for your application, you do not need a relay - why not using the same circuit which I demonstrated - just exchange the relay with your lock and drive the lock from a 12V at the upper side; then it would be better to use  another D1 possibly a 1N4007 etc. ? For higher currents, you could also replace the BC547 with a low-side MOSFET.

Edit: Just a suggestion schematics:
https://easyeda.com/oe1tkt/hc273_lock

The R4 is optional but when powering up, it does hold the IRL3103 MOSFET Gate to GND when there are same statics through the contol curcuit. the diode D1 has to be as closed to the LOCK (connector). Additionally a varistor would secure the MOSFET.
You should also limit the current through the 12V supply, eventually with a fuce.
BTW: Your hand schematics has a little problem with the CLK and MR line (the MR signel is the CLR in my schematics) and with this signal I can reset both or more ICs. With the CLK signal I can choose wich D-FF to set.
Compare your and my schematics ....