Komal Ahmad was a UC Berkeley undergrad when she encountered a homeless man begging for food. Something compelled her to stop and invite him for lunch. He scarfed up the food. In between bites, he told her his story: He’d just returned from a second tour of duty in Iraq but hadn’t yet received his benefits. He had been evicted, had no money and hadn’t eaten in three days.

“It hit me like a ton of bricks,” Ahmad said. “He gave the biggest sacrifice for his country, but it turned its back on him.”

To add insult to injury, right across the street was the Berkeley dining hall, which she knew threw out thousands of pounds of food.

“This is dumb; we can fix this,” she recalls thinking.

Five years later, Ahmad, 26, is leading Copia, a company seeking to apply a Silicon Valley playbook to food recovery — retrieving surplus food for donation to nonprofits feeding the hungry.

The problem is vast. About 35 million tons of food are wasted in the United States every year, according to the Environmental Protection Agency, even while 1 in 6 people go hungry. In San Francisco and nearby, the tech industry generates copious leftovers from all the catered lunches, free snacks, lavish parties, events and press conferences. Plus there’s a raft of meal-delivery startups that can end up with surplus food.

Hundreds of local groups nationwide, largely run by volunteers, already pick up surplus food to feed the needy. In San Francisco, nonprofit Food Runners has been active for almost 30 years and has spawned similar efforts on the Peninsula and and elsewhere. Supporting the local efforts, Congress passed a Good Samaritan Food Donation law in 1996 to protect food donors from liability if products given in good faith cause harm. (Once food has been served on a plate, it cannot be donated.)

Ahmad hopes Copia will stand out, with technology to help it quickly become national and even international, including an app for donors and recipients, logistics software and data analytics for donors. That information could be helpful for food-service companies, for instance, she said, helping them assess which items are popular and which aren’t.

Tech companies, parties

Copia is refining its approach in the Bay Area, picking up leftovers from tech companies, Super Bowl parties, Stanford Hospital and others for same-day delivery to nonprofits.

As an immigrant from Pakistan, Ahmad has witnessed extremely poverty first hand, she said. “Not wanting to waste food is deeply embedded in me. I want to scale, create systems, bring more efficiency to an incredibly inefficient system. We don’t need to buy more food, just to redistribute it more effectively.”

While at Berkeley, she persuaded the campus food services department to let students recover surplus to redistribute to shelters. That became the nucleus for Copia, which was originally called Feeding Forward.

Copia is structured as B Corp., a for-profit entity that can consider social and environmental impact among its goals. Ahmad said that will make it more sustainable, as fees from food donors will provide steady revenue. Donors pay $20 to $40 per pickup plus 55 cents or less per pound of food (the amount decreases with higher quantities).

Why would donors pay, especially when nonprofits will pick up food for free? Copia’s data could help them reduce overpurchasing and enhance tax write-offs, Ahmad said, while its reports can show donors their direct community impact, as well as how they’ve reduced their carbon footprint. Guaranteed pickups make the process seamless, she said.

Copia is in the Y Combinator startup accelerator, and it hopes to raise money at Demo Day, when participants present their companies to venture capitalists and others. It has an unspecified amount of financial backing from YC and venture firm Structure Capital. It has hired six staff people and rented a warehouse and office space in the Mission District.

While Copia’s goals are laudable, some experts on food waste said it also could illustrate Silicon Valley hubris.

“There’s a tendency of tech people to think they can fix every possible problem with a snappy new app,” said Joel Berg, executive director of Hunger Free America, a national nonprofit seeking program and policy reforms to end domestic hunger. “Some problems are more challenging than that.”

On one hand, he said, “any ounce of food waste in America that’s recovered is a good thing, especially for the environment” by reducing waste in landfills that turns to methane gas. On the other hand, food banks and soup kitchens, often volunteer staffed and with limited refrigeration, don’t necessarily benefit from random increases in donations of perishable food.

“It’s false to think this is as simple as Silicon Valley fixing a taxi-hailing problem,” Berg said. The real problem is poverty. “Efforts to create jobs, raise wages and give people an adequate safety net” are the best tools to help to stamp out hunger.

Copia is seeking more companies to donate food; Ahmad said it currently works with hundreds of donors and nonprofits. It has redistributed 10 tons of food in each of the past two months.

Food Runners, a three-decade-old San Francisco nonprofit addressing the same issues, handles almost 70 tons of food every month that would otherwise be discarded or composted, said founder and executive director Mary Risley.

As a chef and owner of Tante Marie’s cooking school, Risley always had leftovers while witnessing how many people went hungry. She started the group in her home with help from a couple of neighbors. It now has 200 active volunteers who use their own cars, plus a truck, some cargo bikes and a donated office. With 1½ paid staffers (Risley volunteers her time), it’s run on an annual budget of $350,000, half from foundations and half from an annual fundraising campaign. Its app for donors and recipients is being revised.

The tech boom has contributed an extra two tons of food a week in leftovers from corporate shindigs and on-demand meal companies, Risley said. Besides event food, it picks up daily from every Whole Foods and Trader Joe’s store in the city. Food Runners delivers to 350 recipients, including soup kitchens, halfway houses, rehab centers, group homes and low-income apartments. Food donors do not pay a fee.

Local knowledge

Food Runners’ in-depth knowledge of local groups feeding the hungry makes it extremely effective at collecting donations and matching them with the best recipient, said Bruce McKinney, free meals program manager for Glide Memorial Church, whose soup kitchen serves about 2,000 meals a day and is among the largest in San Francisco.

Infrastructure — having enough vehicles and people — is an impediment for all food-recovery groups, McKinney said. Volumes can be inconsistent and volunteers aren’t always available when there’s a big surplus. Ahmad said that’s why her model relies on paid staff.

Several new groups have popped up in recent years, said McKinney who is familiar with Copia although he hasn’t worked with it. He thinks that personal knowledge trumps technology.

“It truly is an art form to match the surplus food with the right organization,” he said. “The demand is constant, the supply changes all of the time. There is no substitute for experience and knowing what will work where on a given day.”

Carolyn Said is a San Francisco Chronicle staff writer. Email: csaid@sfchronicle.com Twitter: @csaid