The origin of vaastushastra may have taken place well over thousands of years ago. The learned men of those days may not have lived in houses themselves but they most definately dedicated their lives to the developement of the science "vaastushastra" or "vaastu", as it is popularly known today.
The principles of the science laid down during those days were based purely on the effect of sunrays during different times of the day. The observations and corrections made were noted and concluded only after indepth screening of the situation.
Vastu is a part of Vedas, which are believed to be four to five thousand years old. Through penance and meditation yogis of that period acquired answers believed to have come from the cosmic mind itself to their questions. Hence Vedas are heeded with divine knowledge. The art of Vastu originates in the Stapatya Veda, a part of the Atharva Veda.
It used to be a purely technical subject and it was only confined to architects (Sthapatis) and handed over to their heirs. The principles of construction, architecture, sculpture etc., as enunciated in the epics and treatise on temple architecture, have been incorporated in the science of vastu. Its description is there in epics like Mataysya Purana, Skanda Purana, Agni Purana, Garuda Purana, and Vishnu Purana. There are some other ancient shastras that pass over the knowledge of vastu shastra to next generation, like Vishvakarma Prakash, Samraangan Sutradhar, Kashyap Shilpshastra, Vrihad Sanhita, and Praman Manjaree.
Proofs of vaastushastra can be found during the time of Ramayan and Mahabharat. Even in the cities of Mohanjodaro and Harappa the application of vaastushastra can be seen.
Since the science goes far back to the times of Lord Rama and Lord Krishna there are many interesting mythological stories concering the origin of Vaastupurush (the deity).
In the Mahabharata it is said a number of houses were built for the kings who were invited to the city Indraprastha for the Rajasuya Yagna of King Yuddhistira. Sage Vyasa says that these houses were as high as the peaks of Kailasa mountains, perhaps meaning that they stood tall and majestic. The houses were free from obstructions, had compounds with high walls and their doors were of uniform height and inlaid with numerous metal ornaments. It is said that the site plan of Ayodhya, the city of Lord Rama was similar to the plan found in the great architectural text Manasara. References are also to be found in Buddhist literature, of buildings constructed on the basis of Vastu. They contain references to individual buildings. Lord Buddha is said to have delivered discourses on architecture and even told his disciples that supervising the construction of a building was one of the duties of the order. Mention is made of monasteries (Viharas) or temples, buildings which are partly residential and partly religious (Ardhayogas), residential storeyed buildings (Prasadas), multi-storeyed buildings (harmyas) and Guhas or residential buildings for middle class people.
The Vastu, with word meaning 'dwelling', is believed to be the residing places of god and man. According to its modern meaning it covers all buildings irrespective of their use like residences, industries, business establishments, lodges, hotels etc. It is based on the five basic and essential elements, such as Vayu (air), Agni (fire), Jal (water), Bhumi (earth) and Aakasha (space), which are known as Panchabhutas. Everything on earth is built from these elements.
Lord Shiva had killed a devil named Andhak after a long war which had continued for years. A spirit originated out of the perspiration of Lord Shiva and consumed all the blood from the body of the devil. His hunger was still not satisfied. He then undertook penance. Lord Shiva was impressed and highly satisfied by his penance and offered him a boon. The spirit then went wild and started eating men and animals. This terrified even the Gods in heaven. 81 Gods including Lord Bramha laid the spirit face down and they then sat on different parts of its body. When the spirit asked for forgiveness Lord Brahma offered him a boon: "After building any structure, the people who offer you prayers and worship you as vaastudevta will be blessed with pleasures and prosperity. However only those people, who do not offer you prayers shall be at your mercy and you may trouble them in any way".
There is a possibility that these stories were added in the olden scripts only to scare people and make them conscious about the subject.
The science of vaastushastra is however no mythological story and has stood the test of time for thousands of years.