Some day, people are going to write books about what happened over the last 10 days in the United States. It began with a depressing reminder of what is, perhaps, the worst of America. A disturbed young man, armed with an easily obtainable and high-calibre handgun, shot down nine people in cold blood. It was a shocking act, but largely because Americans have become so inured to the daily carnage of gun violence that the only types of incidents that stand out are those that are uniquely horrific.

Of course, what made the shooting in Charleston, South Carolina, so particularly notable was the where and why – a white gunman, nine African-American victims, a historic black church in the cradle of the former Confederacy. Dylann Roof’s crime was distinctively evil, but the sentiments underpinning it were depressingly familiar. They reflect the original and ongoing sin of this nation – the more than two centuries of mistreatment, prejudice and discrimination visited by white America upon black America.

But then something amazing happened. Practically overnight, America had a national epiphany. For decades, the Confederate flag, which has flown on the grounds of the state capitol building in South Carolina and across the south, became recognised for what it truly is – not a symbol of regional heritage, but a painful, modern symbol of racial exclusion.

Within days of the shooting, politicians across the Deep South couldn’t run fast enough to the nearest microphone or television camera to denounce a flag that a week earlier they would have self-righteously defended. Corporations from eBay to Wal-Mart quickly joined in, announcing their newfound realisation that the stars and bars causes pain. By the end of the week, there were serious discussions taking place in both north and south of removing all vestiges of Confederate reverence – statues to southern generals, schools and highways named after Americans who, at their core, were racists and traitors.

These were largely symbolic acts, but in America, which has for so long denied the racism that is as endemic to our nation’s history as Mom and apple pie, it was a revelation. And the week was far from over.

What has always made America a great nation is that for all our many flaws, we are established on a creed, one that is perhaps the simplest and yet most powerful political idea ever articulated, namely that all men are created equal. Living up to that ideal has been America’s arduous journey for 240 years and at the end of these 10 days we got that much closer to it. On Friday, the US Supreme Court ruled that gay Americans have the same right to marriage as other citizens.

Indeed, in his majority opinion, Justice Anthony Kennedy articulated in one sentence the best of America – the self-corrective nature of our democracy. “The nature of injustice,” he wrote, “is that we may not always see it in our own times. The generations that wrote and ratified the Bill of Rights and the Fourteenth Amendment did not presume to know the extent of freedom in all of its dimensions, and so they entrusted to future generations a charter protecting the right of all persons to enjoy liberty as we learn its meaning.”

Over the past several years, America has come to understand the meaning of freedom as it relates to gay people and, with a healthy majority now supporting the idea that life, liberty and the pursuit of happiness means the right to marry whomever you love, the Supreme Court ratified this sea change. Consider that when Barack Obama finally endorsed same-sex marriage in 2012, only six US states allowed it. Today, it is the law of the land. Obama was late to the game, but to a large extent that it happened on his watch is fitting, because during his presidency America has moved closer to the more perfect union that he movingly spoke of on the campaign trail in 2008.

In the glow of Friday’s decision on same-sex marriage, it was almost forgotten that a day earlier the Supreme Court beat back what is likely the last judicial effort to topple the president’s signature healthcare plan, Obamacare. While Obama must share credit with Democrats in Congress, it is one of his signature achievements. It is a law that doesn’t just provide a means of buying health insurance, but one that lessens the economic anxiety on poor and middle-class Americans and begins the repair of this nation’s increasingly tattered and frayed social safety net. That these court decisions happened within 24 hours were fitting – progress on economic justice and social justice under a president whose very presence in the White House is a symbol of racial reconciliation.

Throw in the president winning free trade authority from Congress and that was a pretty good week for Obama.

But then he went to South Carolina on Friday afternoon to speak at the funeral of Clementa Pinckney, the pastor of the Emanuel African Methodist Episcopal church and one of the nine people slain in Charleston. There, he delivered one of the most extraordinary speeches by an American president. It unblinkingly touched on themes of deep institutional and implicit racism in US society. But it was also a hopeful sermon on the concept of grace and sin that, in a distinctly American way, sought to find reason for optimism in the face of indescribable horror. Here was a black president, speaking to an overwhelmingly black audience in the raucous and welcoming venue of a black church with words that were withering in their honesty and rawness, but also grounded in the basic ideals of not just Christian theology, but America’s secular ideology.

In singing the words of the wondrous hymnal Amazing Grace, a song written by a former slave trader turned abolitionist, Obama reminded Americans of how we’ve fallen short as a nation, but also that the path to redemption and, in turn, grace is within our grasp.

Nations do not usually change course on a dime and one must be careful not to overstate what’s happened. But in the 10 days after a uniquely American tragedy, this diverse, rancorous, often conflicted nation became slightly freer, slightly more generous, slightly more cognizant of its past and slightly more progressive than it was before. To paraphrase vice-president Joe Biden, that’s a big deal.