Turkey has been used for decades now as an example of a successful Islamic country with a secular democracy. This all started with the founder of "modern" Turkey, Mustafa Kemal Atatürk. He said the only way for Turkey to be successful is to modernize like the European powers at the time. He made people learn Latin, outlawed Fez hats, and made many reforms for push Islam away from the government. He made Turkey a Republic and the most successful Islamic country for a middle class and freedoms.
IMO, forcing people to learn Latin and worrying about Fez hats were among some of the sillier things he did. More notable was his unilateral abolishment of the Caliphate in 1924, which ended the Caliphate for good (it having existed in its then-current form for 400 years, and in one form or another since the birth of Islam in the 600s!). This worked essentially because none of the other Islamic nations could decide who to declare as the replacement Caliph, nor which nation should host it. Also key was his separation of church and state (so to speak), the removal of the sharia courts, and the modernization (and secularization) of education. He also was ahead of most nations in promoting equality for women, in law and in culture.
Note that though he pushed towards democratic institutions for Turkey, he was not in his time able to run Turkey democratically. He ruled effectively as a dictator, precisely because he faced tremendous blowback from the Islamic conservatives of his time.
Kemal Atatürk was a very interesting and remarkable man, albeit an authoritarian. Erdogan, meanwhile, is a villain.