It's no secret that the stock market can put you on a path to financial independence. Unfortunately, many investors lack the patience required to realize that dream. Generally speaking, life-changing wealth doesn't accumulate overnight. But with a long-term mindset and a diversified portfolio, you can earn a fortune before you retire.

Case in point: $200 invested each week would be worth more than $1 million in 25 years' time, assuming an annualized return of 10%. And I think that's reasonable. The S&P 500 has generated an annualized return of 10.2% over the last 25 years, so a portfolio of hand-picked stocks could do even better.

With that in mind, both Shopify (SHOP -2.37%) and MercadoLibre (MELI -0.45%) could set you on a path to retire with $1 million. Here's why.

Young couple using a computing while reviewing financial documents.

Image source: Getty Images.

1. Shopify

Shopify's mission is to make commerce better for everyone. To that end, its software helps merchants manage sales across physical and digital stores, including custom websites, online marketplaces like Amazon, and social networks like Meta Platforms' Facebook. Shopify also provides value-added services like payment processing, discounted shipping, and money management solutions, in addition to thousands of integrations through the Shopify App Store.

In short, the company offers an end-to-end solution for modern commerce. That value proposition has drawn more than 1.7 million businesses to its platform, and those businesses are spending more money over time as they adopt value-added services. For instance, Shopify Payments handled 49% of gross merchandise volume in the most recent quarter, up from 45% in the prior year. That means switching costs are rising, because merchants are becoming increasingly dependent on Shopify.

That trend has translated into tremendous financial growth. Over the past year, revenue rose 71% to $4.2 billion and gross margin ticked up 152 basis points to 54.5%. As a result, free cash flow skyrocketed 150% to $458.2 million. And Shopify is well positioned to maintain that momentum as e-commerce becomes more mainstream.

Of particular note, Shopify is constructing an extensive fulfillment network across the United States. Building on its 2019 acquisition of 6 River Systems, a company that specializes in collaborative mobile robots and warehouse software solutions, the Shopify Fulfillment Network will lean on automation and artificial intelligence to help merchants deliver packages more quickly and cost effectively.

Looking ahead, management puts its market opportunity at $153 billion, but that figure only accounts for small- and medium-sized businesses (SMBs). And while SMBs are the core of its clientele, Shopify Plus -- a platform engineered for larger enterprises -- has seen adoption by merchants like Netflix and McCormick. If that trend persists, Shopify's addressable market will continue to expand.

Either way, the company has plenty of room to grow. And if Shopify continues to execute, I think it could achieve a $1.1 trillion valuation in 25 years' time, which implies an annualized return of 10%.

Upward trending bar graph fading from red to green, covered by a magnifying glass.

Image source: Getty Images.

2. MercadoLibre

MercadoLibre has revolutionized retail in Latin America. The company launched its online marketplace in 1999, positioning itself as a first mover in the regional e-commerce space. A few years later, it rolled out its fintech platform Mercado Pago to facilitate digital transactions on the marketplace.

That move was particularly savvy, because a high percentage of consumers in Latin America lack bank accounts or debit card, making it difficult to shop online. To that end, Mercado Pago has seen tremendous success, so much so that it has expanded beyond MercadoLibre's marketplace to other websites and brick-and-mortar retailers. In fact, the fintech platform now handles more payment volume off-marketplace than on-marketplace.

Fueled by its forward-thinking, MercadoLibre has parlayed its first-mover status into a durable competitive advantage. Today, it ranks as the largest online commerce and fintech ecosystem in Latin America, and its marketplace receives more visitors and sees more page visits than any other rival. Not surprisingly, the company's dominance in two high-growth industries has fueled impressive financial results.

Over the past year, revenue skyrocketed 89% to $6.3 billion, and the company posted a GAAP profit of $1.59 per diluted share, up from a loss of $0.16 per diluted share in the prior year. Also noteworthy, MercadoLibre's take rate -- revenue divided by total payments -- rose on both its marketplace and fintech platform, suggesting that clients are becoming more dependent on its technology. That's good news for shareholders.

Currently, MercadoLibre's market cap sits at $51 billion. But given the sizable market opportunity in both e-commerce and digital payments, I think that figure could easily surpass $555 billion in 25 years' time, a pace that would represent 10% annualized growth. That's why this stock could help you retire with $1 million.