The book Code by Petzold talks about computers at this low level (relays) and works up to a small processor. It's pop tech, very readable, second edition came out a couple years back. If you're interested in how these relays would work for something like this, he goes into it.
https://codehiddenlanguage.com
https://codehiddenlanguage.com/Chapter08/ - illustrates logic with relays.