Hagia Sophia means "Divine Wisdom" in Greek, this was an Orthodox church dedicated to holly wisdom, not to a Saint Sophia as some people wrongly call it today. Turkish people call it Aya Sofya, it's a former Byzantine church and former Ottoman mosque, now located in Sultanahmet neighborhood being one of the most important museums of Istanbul considered as a World Heritage by UNESCO. It is one of the greatest surviving examples of Byzantine architecture.
The first church of Hagia Sophia was built on the same site in the 4th century by Constantine the Great and renovated by his son Constantinus II in 360 AD. It was a small wooden church in Constantinople. Unfortunately nothing remained from it because it was destroyed during a fire in 404 AD.
After the destruction, a second and larger Hagia Sophia was built at the same location in 415 AD by the emperor Theodosius II. This second church was also burned down during the Nika riots of 532 AD. Some of its columns, capitals, and the stairs can be seen today in the courtyard of the museum.