Both series are period pieces with some basis in actual East Asian history, augmented with an inventive supernatural aspect and some creative storytelling. Bakumatsu Kikansetsu Irohanihoheto uses the end of the Tokugawa shogunate as the backdrop for an original story with original characters that weaves in and out of historical events; Koutetsu Sangokushi is largely based on The Romance of the Three Kingdoms which in turn is based on the end of the Han Dynasty in Chinese history. (Both timeframes are notable for their political turbulence, disunity, and action in battle.)
Sengoku Basara is based off of the Sengoku era of Japan while Koutetsu Sangokushi is based off of the Three Kingdom era of China. The main focus of both shows is that the country is at civil war and is looking for a new leader to unify it. They both take a twist on the (historical) characters of the show and adds over the top fantasia to them. Although Koutetsu Sangokushi has more drama than Sengoku Basara, it still has plenty of action scenes to satisfy.
Both animes focus on the relations between a sensei and a pupil. When the teacher chooses a path that will bring destruction to the world, the pupil has to make a difficult choice of stopping him by any means.
In Code Geass, the protagonist Lelouch is basically a lot like Koumei in Koutetsu Sangokushi. However the difference is in the characters and tactical analysis--Code Geass's is...deeper. In Koutetsu Sangokushi the characters are bound by the power of the Sovereign/Imperial Seal, wanting to keep it in their possession, but in Code Geass, the "power/supernatural" thing is the geass--a power that differs with each person.
Of course I don't want to give anything away so therefore I won't say any more. But a recommendation is to watch the first code geass before the second or else you'll be confused in some parts.