When Germany was divided by tiny principalities Portugal was a leading global power and we, effectively, and judging by some not-so-reliable studies (as we can't really be certain), had among the world highest GDPs.
More than that, for 2 centuries Portugal was the place where many major scientific breakthroughs occurred. We were an industrious people. European expansion couldn't even have taken place without Portuguese inventions (the caravel, just to name a few). We also had incredibly good rulers, and we had Europe's first centralised state. By 1350/1400 Portugal was a modern country, bureaucracy-wise, with Lisbon as a capital and already some oddly precocious "general law codes" that would only pop up around Europe centuries later.
In fact the Portuguese bureaucratic machine was renowned for being able to hold so many sparse territories under the banner of the Portuguese Kingdom. Corruption was the norm everywhere in Europe, but we had a "proto-meritocracy" going on in Portugal for a while. It was the Portuguese golden age.
Things changed, and I am far from saying that what we accomplished in the past means we can accomplish it now. No. That would make no sense. The Portuguese from the past aren't the Portuguese from today, and many factors that contributed to our success changed.
There are many reasons for that. Religion, being the major one. In fact our religious past still has a lot to do with our current situation, more than you can ever imagine. A good read on Portuguese history would tell you that.
All this to say that some of the factors that contributed to our past success are still there. We no longer have the vibrating Jewish community that made Portugal a technological leader - Fanatical Catholocism took that away from us. But we can still create an educated class that could make us, at least, a country comparable to the Netherlands in that regard.
We still have geography in our side. Historically, it was both our gift and misery. Gift for it pushed us to India, Africa and Brazil, and give birth to modern Portugal. Misery for, when our colonies rebelled, we were now Europe's ass and away, so far away from the European commercial centre and where most Europeans lived, proving to be a major bottleneck for us.
And that's where now Portugal, without its colonies, stands. Portugal is European but never lived like a truly European country. We were always a nation at a crossroad. Our culture is closer to that of Northern Europe than the Spanish, in average, is, for example (we're descendant of the Galicians), but ultimately we're too far away from Europe's heart to foster our economic development without the colonies.
But the world is changing. Especially the Portuguese world, which is changing a lot. And our position can prove to be a major positive feature, again. Brazil and its vast domestic market, its resources, its historical and economical relationship with Portugal.
As an EU state, if the EU lives, that could be a major point for Portugal - we, going back, again, to our commercial past. Because our terrains aren't suit for agriculture like Spain's are. Or France's. But we have a coast, a coast which shaped our history, for better and for worse.
There are studies on this. All this to say that we may have a future, even inside the EU.