To the contemporary view of what the parties now stand for, there has been considerable crossover between the Democrats and Republicans.
The Democratic party was born out of the Anti-Federalist movement. The Antifederalists were generally opposed to ratification of the Constitution, as it led to a more centralized government than the Articles of Confederation, which was in effect at the time. It's notable that in terms of ratification, George Washington was a Federalist, which is likely the justification for him being a Republican in the game even though he never belonged to a party.
During Washington's terms, the first political parties actually formed. Ratification Federalists tended to gravitate around Secretary of the Treasury Alexander Hamilton's political viewpoint and formed the Federalist Party, while Thomas Jefferson largely attracted Anti-Federalists into the Republican party, which was shortly thereafter known as the "Democratic-Republican" party, then later "Democratic." This was the start of the modern Democratic party.
The D-Rs were opponents of strong central government, fearing it was a threat to individual rights. They were strong opponents of John Adams' Alien & Sedition Acts, and Jefferson won on that platform in 1804. Their platform was pro-states' rights, generally anti-commercial, and strong on civil rights.
The Federalists were generally pro-British (the D-Rs were pro-French) and paid the price after the War of 1812, not winning another Presidential election and eventually disintegrating. The Democrats split after the 1824 election, into one faction supporting Andrew Jackson, and another being the National Republicans who later became known as the Whigs (after the British anti-Monarchist party). Jackson had moved the Democrats into a modern national political party, and the Whigs felt he was grabbing too much power.
As largely a single issue party (the issue being not liking Andrew Jackson) and with the Democrats being the only strong established party for so long, the Whigs varied internally on policies. They tended to support strong federal government (somewhat oddly) and business interests but were split over slavery.
As slavery became more of a hotbed issue, it and less underlying party philosophies tended to dominate political battles. Other single-issue parties took advantage of this to come to some prominence such as the Know-Nothing party (anti-immigration, especially anti-Catholic immigration) and the Prohibition Party. Not surprisingly, the single-issue abolitionist party, the Republicans, garnered the most support. They drew enough support to absorb the majority of the fractuous Whigs and even siphoned off a number of Democrats. While the Democrats were not necessarily pro-slavery, the states' rights stance that the party had historically taken could be taken as a tacit approval of the "peculiar institution." By trying to mandate the abolition of slavery, the Republicans by needs supported a stronger Federal government.
The Democrats split in the 1860 election into a pro-slavery faction and the heart of the party which was neutral on the issue or anti-slavery but still pro-states' rights, allowing Lincoln to win the election which triggered the Civil War. During reconstruction, the Republican platform was retaliatory toward the south, in favor of black rights, pro-business, favoring a strong central government, and for tight money (the gold standard). The Democrats generally wanted to end reconstruction, were pro-states' rights, generally pro-labor/agrarian, pro-segregation, and for loose money (the silver standard).
As you can see, there's still a mix on the parties at this point between what the platforms today are of the two parties, and what's considered "conservative" vs "liberal." The next shift came as the 20th century neared and the U.S. industrialized. The Republicans intensified their support for business and urban industrialization, while the Democratic party largely did nothing besides the rise of the "Southern Democrats," who were segregationist whites working to disenfranchise blacks.
Due to their active stance on current issues, the Republicans largely kept power through the start of the 20th century. Howerver, the Progressive movement grew, seeking to use the strong central government to protect labor and consumers. While a Progressive Party formed, their policies were eventually absorbed by the Democrats. This marked a major shift in moving toward the current poltiical party profiles, as Democrats became the party of labor, while the Republicans that of business, and the Democrats largely dropped their states' rights plank except in the south. In fact, the Southern Democrats could well have been considered a different party in coalition with the rest of the Democrats, in opposition to the Republicans -- each for their own reasons.
When the Great Depression hit, the pro-business and in-power Republicans took the blame for it domestically, and FDR was swept into power. FDR's New Deal coalition brought together urban relgiious minorities like Catholics and Jews who benefitted from the New Deal programs, social liberals who felt the party leadership was open to their ideas due to their strong pro-labor stance, labor workers, and the Southern Democrats. Through the influence of the social liberals, the Democratic party shifted into strong Civil Rights supporters, especially for blacks.
Following WWII, this naturally formed a rift between the states' rights (read: segregationist) white Southern Democrats and the new black democrats in the south, which had moved to the party due to its civil rights stance, starting with FDR, and going through LBJ. This led to a split with Strom Thurmond's unsuccessful "Dixiecrat" movement in the late 40's and early 50's.
The Republicans, largely out of power in this period except for Eisenhower, who was a civil rights moderate progressive, started courting Southern whites with their anti-Democratic position, adopting states' rights as a platform to win them over, and embracing social conservatism.
And really, that's pretty much where we are today. The Democrats have gone from anti-federalists to strong central government types, but have consistently been for the consumer and worker over business interests, and their shift over view on the strength of government has largely been driven by their social agenda.
The Republicans flipped the other way on government, largely as an attempt to embrace Southern social conservatives in a long stretch in opposition in order to build a voting base. They've been consistently pro-business for both their own history and that of their ideological predecessors. So, there's not as much shifting as you think, it's really only been one major item that's moved between the parties. It's also interesting to see that the largest shifts within each party (the Democrats embracing the labor movement and the Republicans embracing states' rights and social conservatism) were largely done in a period of strong opposition to just provide an opposing view to the in-power party.