Republic

A republic (from Latin res publica or "public matter") is a form of government in which power is delegated by law rather than heredity. This is in contrast to those systems of government where the ultimate power resides with the head of state, typically a monarch, theocrat or dictator, rather than a set of laws. Republican forms of government are the antipode of hereditary monarchy.

In the case of democratic republics, power is usually held by elected representatives of the people.

In a constitutional republic, those powers are derived from (and limited by) a constitution.

In other republics, this power could be delegated to a traditional group of elders such as the jirga in the transitional government of the Islamic Republic of Afghanistan. The leaders of Islamic republics such as the Islamic Republic of Iran are typically a group of elder clerics who govern in accordance to Islamic law. The mostly extinct class of People's republics are communist countries which pretend to be governed by the people but where in reality the people have very little power, such as the People's Republic of China or the DPRK. In most cases (if not all), a non-democratic republic is essentially a form of aristocracy since all the power is in the hands of a group of elites. (And a lot of democratic republics can be seen as slowly going in the same direction due to the existence of an entrenched political class.)

Republics and democracies
In the United States, a slogan popular among conservatives is that "The US is a republic, not a democracy." usually served with a wink towards the names of the two major parties (the Republican and the Democratic). Robert Welch, the founder of the extreme right-wing John Birch Society, was fond of saying, "This is a republic, not a democracy. Let’s keep it that way!" Welch had argued that 'republic' and 'democracy' were antonyms, and not like synonyms. Almost 60 years later, Senator Mike Lee (R-UT) echoed Welch's claim in an essay titled, "Of Course We're Not a Democracy". Lee's support for a republic and repudiation that the US was a democracy was matched by his high level of support for autocratic tendencies during the Trump presidency.

In reality, the two labels are not mutually exclusive, though, as nothing prevents a republic from being a democracy.

"A common definition of 'republic' is, to quote the American Heritage Dictionary, 'A political order in which the supreme power lies in a body of citizens who are entitled to vote for officers and representatives responsible to them' — the US is that. A common definition of 'democracy' is, 'Government by the people, exercised either directly or through elected representatives' — the US is that, too."

In fact, internationally, and professionally (in the study of government), democracy means rule by the people (in whatever form) and republic means a government without a monarch. That's why North Korea is uncontroversial calling itself a republic - it is a republic, though it's certainly not a democracy. The UK is a democracy but not a republic (if you tell a bunch of Brits they live in a republic you might find yourself subject to a withering glance, because they would recognize that you just told them they have no king or queen). The US is both a republic and a democracy. In fact no country of any real size aside from Switzerland to an extent uses direct democracy in a big way, because direct democracy does not scale well.

This false dichotomy is usually justified by using a very narrow definition of 'democracy' — a pure direct democracy — and then howling about how much the Founding Fathers hated democracy and how republics prevent tyranny of the majority. What those people fail to realize is that nowadays 'democracy' is usually a shorthand for 'representative democracy with a constitution and/or separation of powers' (guess which was the first major one), and those angry Founding Fathers specifically stated that they were talking about direct democracies:

It may be concluded that a pure democracy, by which I mean a society consisting of a small number of citizens, who assemble and administer the government in person, can admit of no cure for the mischiefs of faction.

[...]

A republic, by which I mean a government in which the scheme of representation takes place, opens a different prospect, and promises the cure for which we are seeking. Let us examine the points in which it varies from pure democracy, and we shall comprehend both the nature of the cure and the efficacy which it must derive from the Union.

The two great points of difference between a democracy and a republic are: [...]

In modern times, there are only two types of functioning democracies — democratic republics and parliamentary monarchies (such as the UK).

Anyway, republics do nothing to prevent tyranny of the majority; that's what constitutions are for.

Also ironic is that up to the 1900s, the political affiliations of Democrats and Republicans in the US were pretty much flipped around, especially after passage of the Civil Rights Act (which finally flipped Southern Democrats, aka Dixiecrats).

President
Republics are usually headed by a president. The powers of presidents vary wildly, from mere figureheads (for example, in Germany) to absolute dictator. Figurehead presidents are often appointed by the national parliaments, dictators often force their way to power, and the rest, with limited powers, are usually popularly elected. There are a few hereditary presidencies, but these are de facto inheritances rather than constitutional provisions. The UAE president, for example is customarily held by the emir of Abu Dhabi — himself a hereditary ruler.

Republicanism
Republicanism is not just a form of government but a larger political ideology that tends to make more specific demands and/or requirements of democratic republics and its relationship with citizens to be considered a just form of government. Almost all forms of republicanism have common agreements with each other such as the need for civic virtue, some degree of egalitarianism (being defined by citizenship), a desire to achieve human 'excellence' within the Republic, emphasis on the common good, and a desire to separate the private and public sphere to some degree.

Republicanism can be considered different from liberalism despite in practice both often supporting self-rule, mixed government, and liberty. Republicanism could be considered much more 'communitarian' in nature, often disliking the 'atomization' that liberalism is viewed as supporting and believing that democracy is only functional when there's an educated, trusting community where citizens act for the common good and trust one another. Whereas liberals believe that people are primarily motivated by self-interest, republicans believe that people can be educated into being primarily motivated for the common good.

Whereas liberalism tends to define freedom as being from a lack of interference, republicanism often views an absence of 'domination' as being a truer form of liberty. On the upside, this means republicanism has a better philosophical reason to oppose massive differences in say economic inequality, which liberals very often have a more difficult time defending some degree of 'enforced' moderate economic egalitarianism that doesn't conflict with their own public philosophy. On the other hand the extreme emphasis on citizen choice and a more unified political culture in which 'domination' can be defined and controlled by the public could be seen as leading to events such as Athens voting for the death Socrates in response to disrupting the public sphere through his incessant questioning of status quo beliefs. In practice most Enlightenment philosophers mixed liberal and republican ideologies, though while initially the latter was favored slowly over time liberalism came to dominant pro-Enlightenment and democratic thought.

Also note that 'Republicanism' can be differentiated from the totalitarian communist/theocratic/fascist republics in that the former philosophically supports a stronger republic as the end goal in-and-of-itself while the latter merely view it as a vehicle for their different political utopias with the republic only being (theoretically speaking) a temporary necessity. In practice the former will virtually always place a heavier emphasis on elections and debate than the latter. One example of 'extremist' Republicanism however would be Jacobin France, which feeling that enemies of liberty were everywhere, enforced a nationwide purge targeting enemies of the nation.

Also, 'Republicanism' does not actually relate to the modern Republican Party apart from neither supporting the establishment of outright monarchy.

Examples
Classical Republicanism: The earliest form of democracy with the Greeks placing more emphasis on direct democracy and the Romans on the rule of law. Heavy emphasis on not just citizen virtue but also defending themselves from outside threats and in practice had aristocratic classes that would occasionally weaken the more democratic aspects of the republics. Rights were only allocated to citizens of the Republic. This led many philosophers at the time, such as Plutarch, to note that extreme inequality tends to be the death knell of republics. Citizenship was also only fully extended to free males and in practice the landowning class tended to have an even "higher" form of citizenship and like most people at the time tended to have a cultural imperialist/supremacist mindset. Arguably the finishing blow for classical republicanism was the transformation of the Roman Republic into the Roman Empire.

Civic Humanism: Supported by Machiavelli, these Republicans were present in late Medieval times and were partly inspired by the classical republics (when the ruling class wasn't using it just as an excuse to claim they weren't as bad as the absolute monarchies). This type of republic influenced later Enlightenment philosophers, and placed a heavier emphasis on commerce with examples including Venice and Florence. Despite being more democratic than the neighboring monarchies it tended to be ruled by the upper class, which famously led to a backlash in Florence when religious fanatics briefly took over the area. A modernized version was arguably promoted by anti-totalitarian writer Hannah Arendt amongst others.

Modern Republicanism: In practice mixing liberal and republican ideas this was the concept supported by the American Founding Fathers onwards and is the form that most modern democratic republican states take. At first, citizenship was often limited to landowning white males but was continuously expanded. Unlike the former republics, it mixed natural rights with republicanism. There is much internal disagreement about the form this should take as seen by splits amongst the founders themselves (such as Jeffersonian vs Madisonian vs Hamiltonian republicanism, in order of favoring least to most centralization).

Neo-Republicanism: This is a modern form of Republicanism supported by political philosophers who believe that liberalism does not offer a robust enough form of liberty by not having enough checks on non-political forms of inequality (such as via wealth) and that the fall of communities leads to citizens who distrust one another and will run to an authoritarian for protection. The most famous adherents are Philip Pettit and Michael Sandel. While civic humanism places more emphasis on civic virtue and public debate, neo-republicanism tends to trend more toward policy prescriptions and economic/social egalitarianism. Or to be dramatic about it, the modern forms of civic humanism tend to favor an updated Greek classical republicanism while neo-republicanism is more "rule of law" focused and thus admires an updated form of Roman classical republicanism while also taking in more liberal influences.