No Clinton has ever lost the state of California – and Hillary Clinton was determined not to break that streak.

For five days leading up to the state’s primary, the Democratic presidential candidate campaigned furiously across the state. From top to bottom, big events to small, Clinton pounded the pavement in the state like she did in the final days before the Iowa caucuses.

Except that this time, she won and it wasn’t even close.

A week ago, it seemed highly improbable that Clinton would win by a 13-point margin in the Golden State. Her rival, Bernie Sanders, had targeted the state for months as the place where he would mount his last stand. The rallies were monstrously large, roiling with the energy of a “political revolution” waiting to be unleashed on Election Day. Or so they thought.

If there is any diverse state where Sanders could do well, it would be a one that has a long history of being the progressive lifeblood of the Democratic Party.

Virtually every recent public poll put Sanders within a handful of points of Clinton.

And there were other promising signs: California is full of young people who have overwhelmingly skewed toward Sanders. The Latino population – which is about a third of the Democratic electorate in 2008 – also skews younger. More than half of the state’s Latinos who participate in Democratic primaries were younger than 45 in 2008. And perhaps the biggest boon to Sanders of all: The state’s primary was semi-open, meaning independents — who usually favor him by a lot – could participate.

But ultimately, it was Clinton’s quieter, grinding work and attention to the mechanics of the primary that most likely made a difference. And the state's minority communities did not significantly break from a longstanding trend of overwhelmingly supporting Clinton in Democratic primary contests in this cycle.

In the final week before the primary, she and former president Bill Clinton made at least dozens stops in five days. On Monday alone, Bill Clinton headlined five campaign rallies across the state. In the last several weeks, the two had made almost 80 campaign stops in the state.

She held a roundtable on foster care in Oakland, dropped by a senior center in Compton and grabbed a “Fat Bacon Cheese Burger” at a burger joint in a predominantly African American neighborhood in Los Angeles. Both Clintons worked the black church circuit and held events targeted toward Asian American and Pacific Islander voters.

What limited television ads the campaign aired in the state were broadcast in Spanish, Cantonese, Mandarin, Vietnamese and Korean.

The campaign secured a set of key endorsements in the past week, beginning with Gov. Jerry Brown. The Natural Resources Defense Council Action Fund and the Congressional Asian Pacific American Caucus Leadership PAC officially backed her in recent weeks.

Everywhere she went, Clinton played up her longtime connection to the state.

“I worked here in Oakland in the summer of 1971,” Clinton told the congregation at St. Paul Baptist Church, which is led by a former Bill Clinton campaign staffer.

“Dang,” a woman exclaimed from the pews.

“I had just started dating my husband,” Clinton said with a sly smile. “This may be too much information.”

They laughed and clapped.

“So, we kind of got acquainted in the spring of 1971,” she added.

“All right!” the congregation responded.

Clinton’s aides say the campaign followed the formula that has worked for her time and time again, in primary after primary.

Critically, in a state where 57 percent of the electorate is a racial or ethnic minority, she put in time in minority communities that no Democrat can win without.

No exit polls of the state’s primary exist, but Sanders’s loss suggests that his hope of making inroads with minority communities in California fell short. The state's most Latino Congressional districts broke for Clinton.

Another critical factor: The state’s primary rules favored candidates who were meticulously organized and mobilized at the grass-roots level.

In 2008, more than half of the ballots cast in California were mailed in. Those voters tend to be reliable Democrats, and they also tend to be older. The Clinton campaign zeroed in on individual ballots, securing thousands of votes before primary day arrived.

"We just had a far superior ground game that was laser like focused on the early vote. That was a strategic focus on the campaign," said Buffy Wicks, Clinton's California state director. "We focused on this diverse coalition: women, African Americans, Latinos, AAPI voters.

"California is a majority minority state and the diversity of this state really lends itself to her  and the diversity of the country will really lend itself to her in a general election," she added.

Sanders knew his strength would come on Election Day, when his voters — many of them young – would need to arrive at the ballot box. He urged them to increase turnout to maximize his chances.

As The Washington Post’s Dave Weigel reported, the campaign began an effort to re-register voters who were affiliated with one of the state’s other political parties, but faced obstacles in getting them to agree to becoming Democrats — even for a day.

And although independent voters — or more accurately, unaffiliated voters — could participate in the Democratic primary, the process is somewhat cumbersome and is a barrier to participation that did not favor Sanders.

In the final days before the primary, Clinton had a single-minded focus on California even though she did not need to win to secure the nomination. A loss would have been a psychological defeat on a night that her campaign hoped would be a soaring moment steeped in the history she would make as the nation’s first female presidential nominee for a major party.

Clinton had also gone into the final days before the primary having delivered a major address criticizing Donald Trump's foreign policy. The speech heartened her supporters, according to Wicks, and boosted supporters in the final days.

In the last weekend, 22% more supporters showed up for volunteer shifts than had originally signed on, according to the campaign-- a virtually unheard of scenario.

"It was very palpable the feeling on the trail," Wicks said. "It was palpable, the crowd reaction to her. And it was a real crescendo to the campaign."

Not only was California the largest remaining contest, but a victory there would be an affirmation of her candidacy and her appeal to her party’s progressive roots.

Clinton often reminded voters that California is where the “future” begins. It is also a state where progressive values are born on a slew of issues, including immigration, the environment and the economy.

“So much of what we’re doing in California is what I hope we do more of in America,” Clinton said in Los Angeles over the weekend.

The results Tuesday seem to affirm that Clinton successfully persuaded liberal Democrats in the state to support her.

Look no further than California’s 13th Congressional District, the nation’s most liberal. But the Bay Area enclave of liberalism is also 71 percent minority, playing to Clinton's strengths. She ultimately bested Sanders 51.1 percent to 48.5 percent.

Her campaign views California as a harbinger of things to come. By this point, Clinton’s sophisticated campaign organization is a well-oiled machine — tested in a grueling competition against a well-funded opponent. Meanwhile presumed Republican nominee Donald Trump has yet to put in place the kind of organization that has been typical of presidential candidates in both parties for decades.