Li Yi transmigrates to the Tang dynasty, finding himself outside Chang'an. Using his knowledge of history, he manages to enter the city, where a stroke of luck brings him into contact with Cheng Yaojin. Impressed by Li Yi's cleverness, Cheng recommends him to Li Shimin.
Li Shimin admires Li Yi's novel insights and extensive knowledge, and keeps him on at the palace. Li Yi uses modern knowledge to advise him and solve numerous problems, from improving agricultural irrigation to proposing new business strategies, gradually earning Li Shimin's trust. At court, Li Yi receives the care of Empress Zhangsun, but clashes with Li Tai, who grows jealous of the attention Li Yi receives and plots against him.
With his intelligence and the help of those around him, Li Yi overcomes the crises. He also uncovers Li Tai's plot to seize the throne and joins forces with Cheng Yaojin and other loyal ministers to help Li Shimin expose the scheme and stabilize the court.
As Li Yi's influence grows, he takes part in major historical events, including campaigns against the Turks and diplomatic affairs, contributing to the Tang dynasty's prosperity and stability. He also finds love with a noble family's daughter and ultimately makes a name for himself in the Tang dynasty, becoming a legend.