Here's how San Francisco built one of the best offenses in baseball.