DIY light relay system

I have purchased an older home recently that has been upgraded with an older light relay system as shown in the attachments. I am working on replacing that system with a relay system based on an Arduino using MQTT to control the various relays. I could use some assistance. If you think you can help me program this system I would greatly appreciate any help or assistance you can offer.

That is crazy.. stranded wires.. more wire nuts than a squirrel would need for a decade..

Please tell me you have two smoke detectors right above that mess and a couple of fire extinguishers on the wall..

Did you get a estimate to replace with a proper breaker panel and switch rated breakers/ remote contactor before buying?

What system ?

Just looks like a load of blobs and wires to me. If I found that in a house I bought, I would rip it out.

If this is mains lighting, building a remote control system would require a fair bit of experience to build and implement safely.

What is your experience in electronics, Arduino and working with mains electric ?

Bear in mind too - if this is the UK- you are not allowed to do rewire jobs unless you have the qualifications and test gear . You can get it tested afterwards , but it would be hard to get an electrician to approve a non standard installation - sucks I know . What you have is a mess , I’d look at what standard home automation gear you can buy for this task

You may have similar regs where you are .