Tesla Inc. (NASDAQ:TSLA) stock is on the fast track this year. It's gained 53.7% through July 18, versus the S&P 500's 11.1% return.

This performance has naturally increased investor attention. Before considering investing in any company, one of the first things you should know is exactly how it makes money. So let's look at how CEO Elon Musk's growing Tesla empire brings in its green.

Stack of $100 bills with four wheels on it, like a car.

Image source: Getty Images.

The charts below show how the company's revenue and gross profit broke out by segment in its most recently reported quarter, the first quarter of 2017. Because quarterly revenue can be lumpy for many businesses, it's generally best to look at a longer period of time, such as the most recent one-year period, when examining how a company makes its money. However, doing so here would provide an inaccurate picture of Tesla's current business because it's only owned Solar City since November. 

Revenue breakout by segment 

Segment

Q1 2017 Revenue

Percentage of Total Revenue

Automotive

$2.29 billion

84.8%

Energy generation and storage

$213.9 million

7.9%

Services and other

$192.7 million

7.1%

Total

$2.70 billion

99.8%*

Data source: Tesla. *Doesn't add up to 100% due to rounding.

The auto category, which accounts for nearly 85% of Tesla's revenue, includes sales of the company's new electric vehicles. In the first quarter, the company sold two high-end vehicles: the Model S sedan and Model X crossover. Starting in the third quarter, this category should also include sales of the company's first mass-market vehicle, the Model 3 sedan, which Tesla expects to begin slowly delivering this month. Like all new vehicles produced since last fall, the Model 3 will be equipped with all the hardware needed for full self-driving capability. So Tesla's vehicles should simply need over-the-air software updates to activate full self-driving capabilities once autonomous vehicles become legal on public streets across the country, making the stock a solid play on driverless cars.  

Vehicle production in the first quarter increased 64% from the year-ago period, which enabled the company's deliveries to jump 69% to a new quarterly record of 25,051 vehicles. The big surge was driven by Model X deliveries significantly increasing, as Tesla experienced some production issues with the crossover that hampered deliveries in the year-ago period.

Tesla Model 3 driving on road at dusk or dawn.

Tesla Model 3. Image source: Tesla. 

Its energy generation and storage business sells solar panels (with solar roof tiles coming soon) for homes and energy-storage products -- the Powerwall, for residential use, and Powerpack, for commercial or electric utility grid use. These are rechargeable lithium-ion battery stationary-energy-storage products that Tesla makes at its Gigafactory 1 in Nevada. 

Tesla's services and other segment primarily includes revenue from vehicle service and sales of pre-owned Tesla cars. This segment's mix has changed considerably. Early on, it got a big boost from now-defunct partnerships with Mercedes' parent Daimler and Toyota, which included such things as jointly developing EVs and sales of components such as powertrains. These automakers were early Tesla allies, but once it became obvious that EVs were going to go mainstream, they became competitors implementing their own EV strategies and pulled the plug on partnering with Tesla. 

Gross profit breakout by segment 

Segment

Q1 2017 Gross Profit   

Gross Margin    

Percentage of Total Gross Profit

Automotive

$626.9 million

27.4%

93.9%

Energy generation and storage

$62.2 million

29.1% 9.3% 

Services and other

($21.2 million)

(11%) (3.2%) 

Total

$667.9 million

24.8%  100% 

Data source: Tesla. 

Keep in mind that Tesla is not profitable -- it posted a net loss of $330.3 million, equating to a loss of $2.04 per share, or $1.33 per share on an adjusted basis, in the first quarter. With that said, we can still look at the relative profitability of the company's segments since it provides segment gross margins and the necessary data to calculate each segment's gross profit.

Its energy business has a slightly higher gross margin than its auto business. Investors shouldn't be concerned about the services and other segment: Tesla does not try to make money on this segment, but rather aims to roughly break even, which it wasn't far from doing in the quarter. Tesla's almost surely going to need to increase its overall gross margin in order to achieve profitability. 

Where Tesla's business is heading

We can't know for sure what Tesla's business will look like far in the future, but we can predict with some degree of confidence what the company's business will look like in the nearer term. 

It's a pretty safe bet that Tesla's revenue is going to continue growing at a torrid pace. This year's revenue will get a nice lift from the Solar City acquisition and should also get a big boost from initial sales of the Model 3. Sales of the mass-market EV should drive 2018 revenue growth. Wall Street expects Tesla's year-over-year revenue to jump nearly 65% to $11.53 billion this year followed by a nearly 71% leap to $19.67 billion in 2018, for a near tripling of revenue in just two years. 

It's tough to forecast what the auto/energy revenue mix will look like even in the near term. Tesla's outlook for the energy business, provided when the company released first-quarter results, was limited to saying that this business is "positioned for accelerating growth later this year." 

On the radar is another revenue source, which should also help boost sales of Tesla's EVs: Tesla Network, an autonomous ridesharing service that will allow Tesla vehicle owners to pick up some cash by using their vehicles to ferry passengers around. Musk announced this platform last fall, but when it actually starts operating naturally depends upon when fully autonomous vehicles get the green light across the land.

As for profitability -- which ultimately drives stock prices -- it's anyone's guess when Tesla will be in the black. Wall Street analysts don't foresee a profit for at least the next five years, and I'm on board with that opinion. For now, the company's stock performance indicates that investors remain confident that Musk's vision of building an integrated sustainable energy empire will at some point translate to a profitable company. You must believe this in order for Tesla to be a right stock for you. 

Beth McKenna has no position in any of the stocks mentioned. The Motley Fool owns shares of and recommends Tesla. The Motley Fool has a disclosure policy.