The raucous scene inside the M@ dison building is not one usually associated with inner-city Detroit.

It appears as though a wacky slice of California's Silicon Valley has landed smack in the middle of a city now just as famous for catastrophic urban blight as for being the spiritual home of America's car industry.

Two youthful tech engineers play table tennis in the middle of a busy open-plan office, while bubble chairs hang from the ceiling. Around a table three people are having an intense discussion and a snatch of their conversation drifts across the room. "Having an eye patch would be kind of cool," insists one, earnestly.

This is no mirage. Increasingly it is a common sight in the Motor City as over the last few years a flood of hi-tech firms have sprung up in downtown Detroit, sparking talk of an urban renaissance in an area laid waste by poverty and abandonment.

The M@ dison building has just been named one of the world's coolest offices by business monthly magazine Inc. The building is not alone. Around the M@ dison a cluster of tech firms, design boutiques and other web-savvy projects have emerged. In their wake have come bars, restaurants, spas and, that ultimate accolade of hip urban youth in America, an upmarket table tennis club. Most are centred on Woodward Avenue, leading to the once-proud street being dubbed "Webward Avenue" by local media.

But, unlike many previous attempts to rejuvenate downtown Detroit, the growth of a tech industry seems to have legs. Suddenly buildings empty for decades are being snapped up and turned into loft apartments. On "Webward", the sound of construction rings out as new buildings rise skywards. In Detroit, so down on its luck for so long, never underestimate the sheer joy the sound of jackhammers brings. "You are seeing construction. It is pretty exciting," said Jim Xiao, a financial analyst for Detroit Venture Partners, the driving force behind the M@ dison and an investor in new tech firms in the city.

Xiao, a 24-year-old who evaluates tech firms for DVP to finance, has trouble concealing his enthusiasm. He lives in one of the converted buildings nearby, socialises at the new downtown bars and has a keen sense of mission about tech's role in the city's future. "Where else in the country can you make an actual impact on a whole city when you are in your 20s?" he said.

As a former resident of Seattle and Microsoft employee, Xiao is typical of the breed of tech engineers and entrepreneurs popping up in Detroit. Already DVP has invested in 18 startups in under two years. The aim is to set up many of them in the M@ dison and then watch them grow, leave to find their own offices and have their spaces filled by an already long waiting list of new ones looking for a leg up. In a city known for the "big three" of General Motors, Chrysler and Ford, the corporate names around "Webward Avenue" now boldly proclaim their arrival with techie monikers such as Doodle Home, Tapjoy and Bizdom. Nor is it just in downtown that the tech industry is taking hold. In one of the furthest-flung parts of the city, Brightmoor, there are plans to set up a project called TechTown that will help locals start or improve their businesses.

One of the biggest success stories is Detroit Labs, which makes apps for mobile phones, iPads and other tablets. The firm has grown from nothing to being 30-strong in 18 months and is about to move out of the M@ dison for two floors of office space of its own. Detroit Labs co-founder Paul Glomski is another evangelist for the city. "There is the cool grit factor with Detroit. This is a genuine, hardworking place. It is not superficial. It is full of people getting things done," he said.

It is not just new firms giving birth to the hi-tech industry in Detroit. The giant car-makers are playing a role too. The industry, which is bouncing back after a government bailout during the recession, is producing cars increasingly focused on tech. As a result, the big three are hiring thousands of software engineers as vehicles become internet-connected and tech-oriented.

But in Detroit optimism should always be tempered by the brutal realities of half a century of terrifying decline. On "Webward", dilapidated storefronts and cheap liquor stores still far outnumber swanky new firms. The homeless and drug-addicted mingle on the same streets as the new entrepreneurs. And as you travel out along the famous old boulevards, with the evocative names of Grand River and Gratiot, you enter the horror show of much of the rest of the city. Vast tracts are marked by burned-out homes and empty lots on which prairie grasses and trees grow. Abandoned factories and schools loom in empty shattered hulks over the sort of landscape that is usually the product of war or pestilence. The decay is so prevalent that Detroit has become a photographers' paradise for "ruin porn".

The visual shock is matched by the cold, hard facts. Since the 1950s, when it had a population of 1.85 million, the city has been hit by race riots, white flight, industrial decline and terrible mismanagement. Its population is now 700,000: a staggering 1.1 million Detroiters have simply left.

The result is that huge parts of the city lie empty. City Hall itself owns 58,000 empty parcels of land and is shutting down schools and turning off street lights in a bid to save money and shuffle the remaining population into still viable neighbourhoods. One company, Hantz Farms, has been given the go-ahead to plant a commercial forest in the city.

The startling decline of the city has made it a symbol of America's industrial fall. A mini-industry of books and films has been churned out in recent months, including Mark Binelli's The Last Days of Detroit and Charlie LeDuff's Detroit: An American Autopsy and the documentary Detropia.

Away from the written word and silver screen, real life for those remaining in Detroit is hard. The city has a stretched police force struggling to cope with gang violence, waves of arson and endemic drug use. There were almost 400 gun deaths last year – the city's highest rate in 19 years – and for four years running Forbes Magazine named Detroit as America's most dangerous city. Two weeks ago the city mourned the stabbing death of eight-year-old Tameria Greene, allegedly killed by her mother.

Above all that misery looms the threat of bankruptcy. For Detroit's finances are almost as broken as its neighbourhoods. If it can't rescue itself, then it faces the prospect of becoming the biggest municipal bankruptcy in American history.

Yet the tech boom is a cause for optimism, and not just for the urban pioneers swapping San Francisco, Seattle and New York for the Rust Belt. Rich Feldman, a local activist, lifelong Detroiter and former car-worker believes tech can help the community too. He is helping to set up the Detroit Centre for New Work, aimed at harnessing new technologies, especially 3D printers, to enable people to work in different and more sustainable ways. It will look at helping people to make their own clothes or to create energy for their homes and workplaces. The goal will be a self-sufficient, local and modernised economy. For Feldman, who spent three decades at a car plant, the project has seen him become fluent in a whole new vocabulary. "Technology can be used for community development, especially when it comes to things like digital fabrication," he said.

Despite vast differences in age and background, Feldman and Xiao share a common mood. Both are – at long last – optimistic about Detroit's future. "It is an exciting moment for Detroit. It is pivotal. It does not mean there isn't a lot of pain going on, but this is a very optimistic time for the city," Feldman said.