Family says teen feared harsh anti-immigration laws in Texas, and became especially distressed after Dream Act failed to pass

Before he died, Joaquin Luna put on his best suit, white shirt and black skinny tie, the same outfit he wore every Sunday without fail to the Pan de Vida church in his home town of Mission, Texas. As his brother put it: "He dressed himself to go to God."

Then he shot himself in the shower room, leaving behind a note that explained why he ended such a promising life. He spoke of his desperation at what he felt to be the wall blocking out his future and preventing him from attaining his dreams.

A wall reserved for undocumented immigrants in America.

Aged 18, and in his last year at Juarez-Lincoln High School in La Joya, Luna appeared to have it all going for him. He spoke fluent English, had grades that were regularly 100% and never below 85%, and was skilled at operating computer graphics.

"He was one of the smartest kids at school. His passion was for math and engineering, and he had developed his own blueprint for designing houses by computer programme," his elder brother, Carlos Mendoza, says.

The one thing that Luna did not have was the paperwork to grant him legal status in the US. He was born in Ciudad Miguel Alemán in Mexico, right on the border with Texas.

When he was six months old his family, including his parents and five siblings, crossed the border without visas and travelled just about 40 miles to Mission, on the US side of the frontier.

As he grew older, Luna grew more and more anxious about his lack of a social security number that he would need were he ever to find a job. He used to talk about it often to his brothers and sisters, fretting that even if he gained a good college education, he would never be able to find work or support a family of his own.

He also followed politics closely, reading in the newspapers about the harsh immigration laws passed in other southern states such as Alabama and Arizona. "He got angry," Mendoza says. "He said the people passing these laws had no heart: how could they leave so many kids without parents and destroy so many lives?"

When the Dream Act – a law that would have granted undocumented immigrants in higher education such as himself permanent residency status – failed to pass the US senate last year, Luna took it heavily.

"He got depressed real bad," Mendoza recalls. "Every one of us, we all get depressed. Some of us can handle it, some of us can't. Joaquin couldn't."

Shortly after 9pm on Friday, Mendoza received a call on his cellphone from his younger brother. Luna was at their mother's house and sounded strange on the phone.

"He told me to have a good life, and when I asked him why he was saying that to me, he said: 'Because I'm not going to be here.'" In his last words to his brother, Luna said that he felt he couldn't accomplish his dreams because there was a big wall in front of him.

Fearing the worst, Mendoza began running to his mother's house, but arrived only in time to hear the retort of the gun.

The note Luna left is in the keeping of police investigating his death. Detectives have told family members that in it, he tells them that his main motive for suicide was his lack of legal status and the failure of the Dream Act.

Mendoza believes that his brother took his own life for a purpose. "Everybody has a mission in life and I think this was his – to communicate to people what's going on in America."

The family is planning a small funeral for Joaquin Luna on Wednesday.

At the weekend a letter arrived for him from the University of Texas-Pan American. It offered him a place for next year in its undergraduate course in engineering.