I know that San Marino boasts of being the world's oldest republic, but I'm assuming it wasn't always a democracy? If San Marino was not historically a monarchy, how was it governed, and when did it become a bona fide democracy?
Also, how did it manage to survive for so long without either being absorbed into Italy or any of the other states that later united to become Italy? Surely Mussolini would have been inclined to invade San Marino, especially since it acted as a haven for huge numbers of Italian, and especially Jewish, refugees?
I did a little digging about San Marino a loooong time ago. This might interest you for the first part of your question.
Re 'how has it survived', you'll find a few relevant posts in the FAQ