ツンデレ is, at bottom, a story about embarrassment: the affection is real, the coldness is armour over it, and the audience is in on the gap. The archetype comes in two classic shapes — a character who starts hostile and thaws over the whole story, and one who flips within a single scene, snapping and blushing in the same breath. Modern usage leans to the second.
The word is built from two mimetics. Japanese has a vast stock of sound-symbolic words for manner, and both halves are ordinary members of it: ツンツンしている describes any prickly, unapproachable person, and デレデレしている anyone visibly melting over someone. Fuse them and you get a personality with a switch in it. The word is native Japanese coinage from net culture — English later borrowed it whole.
ヤンデレ swaps the first ingredient. The ヤン is from 病む, to sicken: the affection itself is the illness. A ヤンデレ is sweet on the surface and dangerous underneath — jealousy, stalking, worse — the exact inversion of ツンデレ's cold-shell-warm-heart. The two get confused in English; in Japanese the first two morae keep them straight.
Applied to real people, it is a tease with warmth in it. Calling a friend ツンデレ says their gruffness fools nobody — gruff dads, brusque coworkers who quietly fix your mistakes, texts that scold and end with a heart. It is affectionate to say and usually taken well, which makes it one of the safer pieces of otaku vocabulary to use outside fandom.