SALT LAKE CITY - David Morales was on a Greyhound bus near Las Cruces, N.M., when Border Patrol agents stopped the bus for a routine check.

Morales, 21, rose up and informed his fellow passengers of their rights. That, he says, landed him in detention for nine hours before immigration agents decided to cut him loose.

The experience, he says, was his inspiration for developing an app to inform undocumented people of their rights in a wide array of scenarios ranging from traffic stops by city police officers to a workplace raid by Immigration and Customs Enforcement agents.

"I can't be on every bus, but I can make something that can," Morales told the Deseret News.

The app, Derechos Herencia, which roughly translates as "inherited rights," is available for smartphone and tablet users at iTunes and Google Play.

"I want to make it available to everyone who has questions about immigration," he said.

Morales, who is an illegal immigrant, spent 17 days in jail following a previous encounter with immigration agents on another bus ride when he was 19. He was en route to a Bible college in Louisiana when agents boarded the bus for a routine enforcement check.

When agents asked him if he was a U.S. citizen, Morales told them he was not, and he was held in a detention center to await deportation proceedings.

He was released after his family posted a $4,000 bond. He was eventually granted administrative relief, which he believes was aided by the signatures of 15,000 people who supported him.

The app has a feature to create online petitions on behalf of people facing deportation.

Two lawyers have vetted the content of the app to ensure its accuracy, Morales said. The app is intended to be an educational resource for undocumented people in advance of encounters with local, state or federal authorities.

"It's kind of like the Mexican ACLU," he said, referring to the American Civil Liberties Union.

Morales, who plans to become a Christian minister and possibly attend law school, is also a plaintiff in the ongoing legal challenge to HB497, Utah's immigration enforcement law passed by the Legislature in 2011.

While Morales said he is optimistic that Congress will take up immigration reform, his family is like many others, with mixed immigration status, and different family members encounter a wide variety of challenges.