Mayamatam the ancient Indian Book explains the legend of Vastu Purusha. Brahma the creator of the Universe once experimented creating a large cosmic man, who rapidly grew to devour everything in order to satisfy his hunger. He was raging towards the Earth. Lord Shiva and Vishnu asked Brahma to stop this creature.
Brahma with the help of Astha Dikapalakas- the gods of eight cardinal directions held it flat against the Earth while Brahma jumped on the middle. The Creature begged Brahma “You created me with this nature why am I punished” Brahma offered him a compromise and blessed him with a boon that he would be worshipped by all mortals that builds a structure on earth. He will be knows as Vastu Purusha.
Vastu Shastra is a directive towards construction of building in a way that blessings of vastu purusha fall upon us. These principle are explained with the help of the diagram called Vastu Purusha Mandala.