It goes without saying that Star Trek and Silicon Valley share a special bond: one is a fictional world full of technological wonders; the other is the nerve center of the industry actively making those futuristic technologies real. Smartphones and tablets and voice search all entered the national imagination through Star Trek, not to mention the wearable devices and driverless vehicles we can look forward to in the coming months and years. But the affinity between these two institutions runs much deeper than mere gadgets. Both have deep Bay Area roots, for overlapping reasons.

San Francisco serves, in Star Trek’s fictional universe, as the site of Starfleet Command – the headquarters of the good guys – and despite all the time they spend boldly going where no one has gone before, the Enterprise and its sister ships make it back home surprisingly often. (In Star Trek Into Darkness, the franchise’s latest outing, the crew spends nearly half the film in the city). The Golden Gate Bridge is a valuable asset in a sci fi series like Star Trek, since it signals to the audience that our heroes are conducting business on Earth and not some alien world. The Statue of Liberty or the Eiffel Tower could serve this function just as well, but San Francisco has a few additional winning qualities that other cities lack.

Perhaps the most attractive thing about San Francisco from Trek creator Gene Roddenberry’s point of view was its significance to the U.S. Navy. Roddenberry himself was a pilot in the Army Air Corps during World War II, and was ferried from California to the Pacific theater by Navy vessels, so he was well aware of San Francisco’s shipyards.

“The reason the Enterprise looks so realistic, even though it’s futuristic, is that there’s certainly these trappings of the Navy,” said John Tenuto, a sociology professor at Illinois’ College of Lake County who studies the production of Star Trek. “Although Roddenberry has a sort of progressive view of the future, those military experiences certainly appeared in Star Trek and shaped it.” Indeed, naval traditions permeate the show, from Starfleet’s ranking system to the boatswain’s whistle ahead of ship-wide announcements to burying lost crewmen at space.

Matt Jefferies, the legendary art director who designed the original Enterprise and many of its iconic sets (and the inspiration for Jefferies Tubes), was an Air Corps veteran like Roddenberry and together they drew inspiration from the Navy in establishing the new show’s design aesthetic.It’s not surprising, then, that the city’s very first mention in the Trek universe, spotted by eagle-eyed fans of The Original Series, was on a dedication plaque which says that the Starship Enterprise was constructed in a San Francisco shipyard just like its nautical predecessors.

Silicon Valley also sprang up in the Navy’s wake, so to speak. In 1933 the military opened Naval Air Station Sunnyvale, now called Moffett Federal Airfield, to develop Navy dirigibles; Hangar One, a retired blimp storage facility and one of the world’s largest freestanding structures, is still clearly visible from US-101 on the drive between San Francisco and San Jose. The outpost attracted a number of technology firms to the area in the thirties, and more still Lockheed when the Navy gave up on dirigibles and passed the airfield on to the National Advisory Committee for Aeronautics, the forerunner to NASA.

Silicon Valley has obviously outgrown its military origins, as has Star Trek. Tenuto says Starfleet is more like the Coast Guard than the Navy: an agency in place to offer assistance to those who need it. The Federation fleet’s central mission is not one of conquest, but of scientific exploration: “to explore strange new worlds, to seek out new life and new civilizations.” It makes sense that Roddenberry would be similarly drawn to the optimistic, progressive culture of San Francisco, the city where the founding charter of the United Nation was signed.

The United Nations logo next to that of the Federation of Planets. Images courtesy of Wikipedia and Memory Alpha.

Following the same progressive impulse, the casts of Star Trek’s various incarnations are famously diverse: Russians and Americans serving improbably side-by-side in the sixties, followed by Klingons and humans in the eighties and a female captain in the nineties. Star Trek may have dropped the ball on the LGBT front–a particularly ironic note, in light of its San Francisco origins–but the makeup of its crews has historically been a good-faith attempt to break down prejudice. San Francisco is hardly free from its own race- and class-based animosities, but its reputation as a tolerant community is a perfect match for Star Trek.

Hikaru Sulu, the Japanese helmsman in the original series, actually hails from San Francisco, likely a reflection of the large Asian-American population in today's San Francisco. It’s also fitting that George Takei, the actor who portrayed Sulu in the high-tech future, has harnessed modern social media for a second round of celebrity as an affable mischief-maker and gay rights advocate on Twitter and Facebook.

Sulu’s origins were revealed in 1986’s Star Trek IV: The Voyage Home, which marked the pinnacle of Star Trek/San Francisco relations. After fleshing out a 23rd Century San Francisco in the first three films, the crew of the Enterprise time travels back to 1986 to kidnap a humpback whale and bring it back to the future (it’s not worth explaining why). Unlike the previous movies, Star Trek IV was filmed on location in San Francisco, where the crew parks their (invisible) ship in Golden Gate Park, and then visits the very institutions from which Star Trek draws its inspiration.

Uhura and Chekov sneak aboard a Navy aircraft carrier in Alameda to tap into their power supply, while Scotty and McCoy teach a plastics manufacturer how to make something called “transparent aluminum.” Enterprise Engineer Scotty, failing to understand that the Macintosh Plus he is trying to use does not accept voice commands, holds the mouse to his mouth like a microphone and speaks: “Hello, computer.” Jokes about antiquated technology are practically custom-made for Star Trek’s audience in the Valley.

Plenty of science fiction is city-specific: it's impossible to imagine RoboCop anywhere but Detroit, or Blade Runner outside of Los Angeles. What sets Star Trek apart is the attention it pays to one little city, barely seven miles across, when the other points on its journey are not cities or countries, but planets and star systems. Many of Star Trek’s struggles take place not long ago in a galaxy far, far away, but in a city we have already built, just a couple centuries down the road. And it’s a city whose culture of curiosity, craftsmanship and tolerance have left an indelible mark on one of the world's most successful sci-fi franchises.