The problem with democracy legitimation is concering which or whose definition of democracy you use.
I know Max Weber has a lot to say about legitimacy of a state. He is heavily citated in social sciences as you may know.
If you are looking for work on wether a state is a democracy or not i would suggest reading Przeworski. He uses a black and white definition, either a state is a democracy or a state is not.
Guillermo O'Donnell's Transitions from Authoritarian Rule is a good way to start on how a democracy is formed and when it can be called a democracy. If I'm not mistaken it's a book series or comprised of different volumes.
If you're just looking for datasets I would suggest the ACLP (Przeworski and 3 other peoples), Freedom House (Might be a bit biased) or Polity IV . These 3 are heavily used in litterature on Demoracy, the things before and after and the effects of democracy.
Just let me know if I am completely off or if you need something more.