Part of the problem with this question is that there are many different definitions of democracy. Some of those definitions have become politicized. Let’s start with the basic definitions and build from there.
The concept of democracy in its standard political science meaning is very broad. It refers to a system of government in which the supreme power is vested in the people and policy choices are made by voting. Many government systems meet this description. Some are better than others.
In a direct (or pure) democracy, anyone can vote on any policy proposal. This system has two problems. It is unworkable for large populations of busy people. It also invites mob rule. Any majority can gain power. Once they have it, they can use all sorts of methods to ensure their opposition can never successfully compete again.
Representative democracy is one way to get past the population problem. In this system, only elected representatives may vote on policy proposals. This system remains vulnerable to the tyranny of the majority.
Republican forms of democracy are meant to reduce the risk of tyranny. A republic is a representative democracy with a division of powers between an elected executive and elected representatives in a legislature, congress, or parliament. The executive can be a president elected by the people or by an electoral college or a prime minister elected by members of a parliament.
Liberal republics reduce the risk of tyranny still more. A liberal republican form of government includes guarantees that help secure our liberty (hence the word liberal) and that are essential for free and fair elections. For example, in the United States, our system of government is restricted from infringing upon various rights such as voting, running for office, free speech, freedom of movement and assembly, freedom of worship, freedom of the press, the right to keep and bear arms, and equal protection under the laws. Illiberal republics and illiberal democracies lack such protected rights – or apply them only to favored groups while repressing all others.
Constitutions can be, but are not always, used to protect against tyranny. In most countries, a constitution is the supreme law of the land. Leaders write constitutions to require a specific system of government and, sometimes, a particular economic system. In the United States, our constitution requires a system of liberal, republican governments at the federal and state levels. By contrast, in some countries, leaders have created illiberal constitutions to perpetuate tyranny.
So, is the United States a democracy or a republic? It’s both. However, a more accurate answer would be to say we have a constitutional, federal system of liberal republics.