You could have Supreme Courts without representative Democracy.
You could have direct democracy on issues (Brexit e.g.) within representative democracy.
Majority agrees with this form of government including Supreme Court and Constitutional Rights. If 99% of USA agreed to not follow constitution, would Supreme Courts be able to enforce their opinions? Majority agrees to give that power to Supreme Court and is upholding it everyday.
If you think we gave our constitution to ISIS today, they would function the same way, without buying into it?