Your excerpt is a compound of two idiomatic phrases:
So much for [x].
and
happily ever after.
The first phrase implies that X did not turn out the way you expected, or did not function in the way you hoped, or that some effort has been pointless. For example:
The owner of the sports team decided to move them to a different city, claiming he could make more money. So much for all the fans who supported the team for over 50 years.
X is (as far as I know) always a noun or a noun phrase. You can replace "fan dedication" with any other noun, like "pepperoni pizza", assuming it makes sense in context:
I tried to cook at home but all I made was a huge mess. So much for pepperoni pizza for dinner tonight. Let's get delivery pizza instead!
Meanwhile the second phrase is used at the end of fairy-tale stories to indicate that the rest of the protagonists' lives were blissful. Again, as far as I can tell it is a noun phrase, although it can be used in compound nouns:
You'd think that they had a "happily ever after" fairy-tale romance, but apparently they fight all the time when they are at home.
Put them together and you sentence implies that the protagonist's story should have had a happy, fairy-tale ending, but it didn't.