A very nice overview of the impressive structure of the Islamic Republic has been published by Persicus Maximus. The author also points out the Western bias that both ignores the impressive Iranian effort to structure a workable system and ignores the democratic features of that system. Iran deserves credit for creating governing mechanisms that look rather good in comparison with those of other regional countries. Americans in particular should also have the honesty to admit that Iran's long effort to understand and adopt the Western concept of democracy would have been far more successful if the U.S. had helped instead of fomenting a coup that destroyed Iran's democratic movement in the early 1950's in order to preserve Western control over Iran's oil resources.
But back to the state structure, which is now under such stress. As I see it, the founders of the Islamic Republic consciously faced the same problem America's constitutional fathers faced: how to prevent dictatorship. They answered in essentially the same way, as well: checks and balances.
Of course, practice has never been perfect. In the US, corporations, government-allied media, and the emerging imperial presidency undercut the democratic structure laid out in the Constitution; in Iran, the Supreme Leader (imagine an imperial president who talks to God) had so much power that the temptation to interfere in politics by screening opponents out before they can even run for office has proven irresistable. As Khomenei was evidently well aware, power corrupts.
This process of power corrupting has now, it seems to me, led to exposure of the great secret compromise on which the Islamic Republic's state structure is based. The compromise is that it is based on two pillars - the Islamic leadership of Allah's representative (velayat-e faqih) and electoral legitimization. The "secret" is that these two concepts are directly contradictory.
Khamenei has exposed the secret by giving in to corruption (i.e., by interfering in the electoral process). This has caused the collapse of the compromise and made it necessary for all the members of the elite who had previously avoided looking too closely at this compromise to choose sides, i.e., do they now support Islamic dictatorship or electoral legitimization? Supporting the former risks the emergence of a harsh dictatorship that will strip them of their privileges (political access, status, and extreme wealth). Supporting the former risks the fall of Islamic rule altogether.