Twenty-three-year-old Leila, her husband and two small children spent their first week in Germany in a temporary shelter, an austere but desperately needed haven after a traumatic flight from Syria that began when her husband was told to fight for the government.

Among an expected 800,000 asylum seekers flowing into Germany this year — some four times last year's count — she and her family shared a small room built in a converted covered tennis court in downtown Berlin during their first week in the country in August, furnished with three Ikea bunk beds, a small table and a small closet. They received three meals a day in a common room for the 300 refugees in the facility, and bathrooms were shared.

The setup was basic by European standards, but for Leila, who cannot forget the bodies littering the streets of the Syrian city of Aleppo, it was a fresh start.

"We were so afraid, before we came here," said Leila, who requested that her last name not be used for fear of retribution against her family still in Syria. "Now we feel comfortable because we are treated well ... We feel safe here."

The surge in migrants and refugees to Europe from Syria, Afghanistan, Iraq, Eritrea and elsewhere this year has sent countries scrambling to come up with housing — both temporary for those awaiting the outcome of asylum applications, and permanent for those allowed to stay. German authorities say they have 45,000 spots in temporary facilities for new asylum applicants — excluding tent settlements that have been hastily erected — but they need as many as 150,000.

Many European countries face similar problems, but none greater than Germany. Europe's richest economy attracted 43 percent of Europe's 400,000 asylum applications in the first half of the year — more than double the number in the same period of 2014.

The converted tennis court where Leila and her family are being housed was supposed to be closed in May, but it has been kept open to help deal with the flood of newcomers. Funded by the city, it is run by the Berlin City Mission, a Christian nonprofit organization, and staffed largely by volunteers.

Elsewhere in Berlin, portable shipping containers have been converted into small stacks of apartments to accommodate 2,400 refugees around the capital. At one in container village in southwestern Berlin, which is just opening, colorfully painted containers offer comfortable space for 300 refugees. It boasts single rooms with shared kitchens and bathrooms on each floor, as well as small flats for families, and even accommodation for the disabled.

In government and non-governmental projects around the country, former military barracks are being converted to housing, disused nursing homes are being refurbished and even small tent cities are being erected. Chancellor Angela Merkel's government has already doubled the financial assistance available to local authorities to 1 billion euros ($112 billion) and has called a meeting with state leaders in September to discuss the refugee situation further.

Some Germans have taken matters into their own hands. Last year, Berlin resident Jonas Kakoschke decided with his roommate to house a refugee in her place while she was spending six months abroad.

Kakoschke helped the refugee, a Mali-born man from Senegal, learn the language, get his paperwork done and eventually find his own apartment. Now, with the online project "Refugees Welcome" that Kakosche and his roommate founded together, they help find private placements for more new arrivals, by matching ages, language skills and other criteria.

"Many refugees say they don't have direct contact with local population and our project helps them with that," Kakoschke said.

Through July, they say they have placed 64 refugees across Germany and 34 in Austria in private apartments. There's also been reports of people across Germany who have taken in refugees on their own, but it is not clear exactly how many.

Even with a combination of government, NGO and grass-roots efforts, Merkel still sees the migrant situation in Germany as "extremely unsatisfactory."

"Every person who comes is a human being and has the right to be treated as such," she said.

In Berlin, which expects to receive 35,000 refugees this year — almost triple the number in 2014 — Mayor Michael Mueller said the system needs to be streamlined to quickly separate those who will likely be allowed to stay long-term and those who won't.

"We need very quick procedures so that we can know as soon as possible who has a chance to obtain residence and who does not," Mueller said.

Adding to the challenge has been an uptick in anti-foreigner violence, primarily in cities in former East Germany.

A week ago in Heidenau, a town near the Saxony capital of Dresden in eastern Germany, a far-right mob hurled bottles and fireworks at police protecting a temporary shelter being set up for 600 refugees. Merkel, visiting the town on Wednesday, called the incident "shameful and repulsive."

In nearby Meissen, a refugee home was burned down two months ago, just days before it was to open for 32 asylum seekers. And in the Bavarian town of Reichertshofen, a building for 67 refugees was set ablaze last month, just before the asylum seekers were to move in.

Overall, in the first half of the year, 202 anti-foreigner incidents were reported in Germany, more than in all of 2014. Authorities have been forced to take extra precautions, even in places like Berlin where there have been no major incidents.

"Our container village has not experienced any attacks, however we are very concerned," said Detlef Cwojdzinski, who is in charge of managing the construction of one such settlement in southwestern Berlin. "That's why we have had a security service on site since we started the project."

Nora Brezger, an expert from the Refugee Council Berlin, a nonprofit refugee support group, criticized temporary housing options as short-sighted, saying it costs the city approximately 25 euros ($28) per day to house refugees in container villages or shelters. She argued the money could be used to pay for apartments that would help them integrate better into society as well as be more comfortable.

At the shelter where Leila was living, volunteers did their best to make the refugees feel at home. The structure looks like a backpacker hostel with a check-in entrance, a big canteen and lounges. Cultural events, workshops and even a small kindergarten are available for those who stay longer. More than 950 people have worked as volunteers at the shelter since it opened in November, providing psychiatric counseling, medical help and general assistance.

"We don't simply open the doors, point at the beds and say that's it," said Joachim Lenz, the Berlin City Mission's director.

Leila said back home in Syria, her family had no gas, no electricity and little food, barely enough to survive on for her 3 ½-year-old son and six-month-old daughter. Now she has allowed herself to think ahead, about getting her children into kindergarten, then a good education, and eventually rewarding careers.

"There is no better place than a homeland, but now it is safe for us in Germany," she said. "We want our kids to see and live normal life, to have a childhood like everybody else's children."

___

David Rising and Kirsten Grieshaber contributed to this story.