Forbidden City originally was related to Chinese ancient philosophy and astronomy. Chinese people think the theory of oneness of heaven and human as well as interaction of human and heaven. Therefore, Forbidden City was built following the structure of heavenly palaces. In Chinese ancient astronomy, the stars were divided into San Huan(三垣) surrounded with 28 Xiu. Among them, Ziwei Huan or Polaris is located at the center and the center of all Xingxiu as well. Hence, Forbidden City, in Chinese Zi Jin Cheng(紫禁城), Zi（紫）means the Ziwei Huan which symbolizes the superiority and authority, and Jin（禁）means the exclusiveness and solemnity of the palaces where emperors lived.
In 1406, Zhu Di, the third emperor of Ming Dynasty set out the construction of Forbidden City. According the record of History of Ming Dynasty, compiled by high officials of Qing Dynasty, there were in total 100,000 most excellent craftsmen and workmen were mobilized for constructing this imperial palace. The duration of time for construction is 15 years. Afterwards, many emperors of Ming and Qing Dynasties rebuilt or extended the palaces, but in layout, the whole Forbidden City was not changed a lot. In total, there were 24 emperors lived in forbidden city, the first was Zhu Di（朱棣）, and the last was Pu Yi（溥仪）, the last emperor of Qing Dynasty
As to the construction of Beijing Forbidden City, there was another interesting story. Zhu Yuanzhang（朱元璋） and his son, Zhu Di,always planned to build as many and large palaces as possible , when they ordered Liu Bowen（刘伯温） to take charge of the construction of Beijing Forbidden City. They wanted the palaces to be specially magnificent and solemn. One day, for expressing his personal viewpoint, Emperor summoned Liu Bowen and Liu Bowen arrived at once and said:”Your Majesty, last night, I had a dream, and in dream, the Jade Emperor told me’ please inform your emperor that the total number of heavenly palaces is 1000, and the palaces on earth can not surpass this number. Besides, you must tell your emperor that he must have 36 Jing Gang and 72 Di Sha to protect the palace for keeping the country in peace and harmony. You have to remember this!’ Jade Emperor suddenly turned into the fragrant mist and disappeared once completed what he said. And then I waked up.” The Emperor felt strange and thought for a while; finally he ordered Liu Bowen to supervise the construction of Beijing Forbidden City and guaranteed the total number of the rooms of Beijing Forbidden City was less than 1,000, but meanwhile it must be roughly equal to the heaven palace. What is more, Emperor also demanded Liu Bowen to invite Jing Gang and Di Sha to protect the palaces. This news quickly spread in Beijing, and people were all eager to know how to tackle these harshly hard jobs.
After dozens of days, Liu Bowen reported Emperor that the construction of Beijing Forbidden City was completed. Emperor was surely surprised and checked the palaces by himself. The number of the rooms was really not more than 1000, and it was 999 and a half. The whole palaces were so grand and splendid that seemed like being protected by gods. The emperor was quite happy and highly praised and awarded Liu Bowen a lot of treasures. The foreign enemies heard that Liu Bowen invited Jing Gang and Di Sha from heaven to protect the palaces and did not dare to invade Ming Dynasty any more. Later, people gradually understood the so-called 36 Jing Gangs（金刚） were actually the 36 large gold-gilded vats placed in front of palaces and 72 Di Shas（地煞） were 72 underground ditches.