A straw purchase is when a gun is purchased on behalf of someone else. The person buying the gun isn't using their own money, or the person they're giving it to has traded them something of value.
A gift doesn't involve an exchange of reciprocal value. In other words, I can legally take you into a gun store, let you shop, buy the gun for you, then hand it to you. In practice, a gift purchase is almost always when the recipient isn't there, because it looks like a straw purchase.
Ironically, if you take someone shopping to buy them a gun as a gift, by law you're the one that's supposed to have the background check run - not the recipient. Almost all FFLs will deny the sale if you tell them that you're buying it as a gift for someone who is present at the time, and there is no easy and legal way to run a background check on the intended recipient.
If memory serves, a cop was convicted a few years ago of a straw purchase after buying a "blue label" (police discount price) Glock for someone else. That person gave the cop the money, the cop bought it, then gave it to the person. The actual buyer in that case was not a prohibited person, and the straw purchase itself was the only crime committed.
> Ironically, if you take someone shopping to buy them a gun as a gift, by law you're the one that's supposed to have the background check run - not the recipient.
That is contrary to what is on ATF Form 4473 [0]. Form 4473, question 21.a., asks if the purchaser is the actual transferee of the firearm. The form makes it very clear that it is a crime to answer "yes" if the buyer is purchasing the firearm to transfer to another person.
[0] https://www.atf.gov/firearms/docs/4473-part-1-firearms-trans...
It's more of a gray area when it's an intrafamilial transfer.
As far as actually catching perpetrators? Again, without a database its usually down to undercover work and tips.
https://giffords.org/lawcenter/gun-laws/policy-areas/crime-g...
https://giffords.org/lawcenter/state-laws/trafficking-straw-...
https://www.fox32chicago.com/news/56-arrests-dozens-of-narco...
I have my doubts that in the situation that you described that there would be interest and motivation to prosecute, but if that buddy had gone on to commit a felony, or this was a repeated offense, then they would use warrants, subpoenas, and other standard prosecutorial tools to try to find the cache, get electronic records, and compel witnesses to testify. As someone else noted, all that's required is falsifying the the purchase details (Abramski vs US).