Republics aren't necessarily democratic.
A country is considered a republic when it's government in comprised of representatives of the citizen body. But how should those representatives be selected? The concept of "republic" does not specify how. You could choose them through democratic means; You could elect a president who in turn selects the representatives; or you could have them be chosen based on who is the richest. That would still be a republic.
Democracy comes from the Greek demos, which means people or district, and kratos, which means power. Democracy is when the power is on the people.
Republic simply says the government should be ruled by representatives of the citizen body, Democracy states how those representatives should be selected.
(Please correct me if I'm wrong)
And who will create the automaton? How do we select people to maintain the automaton that will play the role of government?
That automatic government has to be created by a group of people. How do you plant to select them? The government automaton would also need to be maintained, as it is impossible for the authors of the machine to predict what humanity is going to look like 500 years from now. How do you select those?
The logic of "code is impartial, therefore code should be law" is flawed because code as to be written by someone, and that someone is not impartial.