Seems like the British systems formed and formalized it, but that that itself was an amalgam of the cultural stratification that was sometimes already there. Multiculturalism turned monstrous...
sad.
There have been a number of genetic studies[1] that can identify caste heredity going back to almost the time of the Vedas showing VERY little genetic mixing between the castes.
Oops, I may have chopped off a few characters. Yeah there were essentially only a handful of upper caste men gathering children with lower caste women and virtually no other mixing for thousands of years.