Even though you’re right in that glutamate is a neurotransmitter, eating it doesn’t affect our brain chemistry at all. It can’t pass the blood-brain-barrier. Which is relieving since basically every food group contains it and flooding our brain with that would lead to violent epileptic seizures and certain death. Not insomnia.
And melatonin isn’t a neurotransmitter but a hormone.
So maybe you do in fact sleep better when avoiding specific food groups in the evening, but your explanation certainly isn’t correct.
Just putting this out there since glutamate is such a highly misunderstood molecule surrounded by many misconceptions, this one being a very common one.