Porsche has re-engineered the Panamera for 2017, turning the pudgy, oft maligned sedan into a family car that can handle a day at the track as easily as a trip to the grocery store. And to crank out the best seller, Porsche also re-engineered its Leipzig, Germany, production facility. The $500 million expansion includes a 20,000-square foot quality center for testing parts, augmented reality, a computer-optimized system for just-in-time delivery of parts, and more.

The $98,300 Panamera may make 911 fans roll their eyes, but it makes Porsche piles of cash, so the Germans don’t hold back when it comes to making the cars just right. From the quality control room to the paint shop to the test track, here’s how Porsche builds the Panamera.