In the show’s eighth and final season, some of the players have changed, but the core remains the same. (RON TOM/© 2004 ABC, INC.)

In an era of constant online sharing, filled with cheerful Facebook updates and lovely Instagram photos, we can skillfully edit the image of ourselves we choose to project the outside world — though we know it’s not entirely real.

Because everyone has secrets. Everyone has moments of gripping loneliness and fear and sadness and panic and that one thing, if not many things, in their life that induces that feeling of pure, unadulterated desperation.

And eight years ago, the aptly named “Desperate Housewives,” set in a fictional, idyllic suburban world that masked the characters’ true pain, sharply captured that timeless internal struggle in a way that truly resonated with the audience.

But this is also an era of swiftly canceled shows — so what was it that made the ABC series stick through all these years? During nearly a decade of character ups and downs, falling ratings, and some truly absurd storylines, one thing stayed consistent:“Desperate Housewives” showed us that it’s okay to be a mess.

Sunday night, the soap-tastic dramedy bids farewell for good with a mediocre amount of fanfare for a show that, eight seasons ago, truly started out with a bang.

More specifically, it was a gunshot — a self-inflicted bullet that killed a housewife on Wisteria Lane in the first scene of the pilot back in October 2004. It was a gunshot meticulously planned by a sweet, friendly woman named Mary Alice Young (Brenda Strong), and it happened only after she had served her family waffles for breakfast, done a load of laundry and picked up the dry cleaning.

A grim catalyst for the show, but one that captured millions of people wanting to know the answer to the same question as the characters: Why did a woman with a seemingly perfect life want to die? Soon, it evolved into something more than a mystery. It forced the characters to take a closer look at their own lives, and reevaluate the cost of keeping an image of perfection vs. facing the truth about their troubles — a tantalizing idea for viewers tuning in to a prime-time soap.

Despite its tragic beginnings, “Desperate Housewives” has always been billed as a comedy, collecting dozens of award nominations over the years in the category. It took only seconds in the pilot to go from dark to darkly funny: The nosy neighbor who discovered Mary Alice’s body screamed, called the police and then after grieving for a few moments, ripped off the “Property of Mary Alice Young” sticker on a borrowed blender.

The scene was a sign of the show’s tone, different from anything else on TV at the time, and viewers took notice. It worked: About 22 million people tuned in to the premiere to see Marcia Cross as Bree Van de Kamp, the uptight, Martha Stewartesque homemaker; Felicity Huffman as Lynette Scavo, the harried executive who stopped climbing the corporate ladder to raise her kids; Eva Longoria as Gabrielle Solis, the former fashion model adjusting to the suburbs; and Teri Hatcher, making her return to TV as Susan Mayer, the klutzy single mom with a disastrous love life.

Injecting the right dose of dark humor with soap-tastic plotlines led to an onslaught of press and headlines at the start. Ratings kept climbing: 30 million people watched the first-season finale, a saving grace for ABC, which badly needed a hit. Critics fawned over the series, which put a spotlight on controversial aspects of motherhood. In fact, creator Marc Cherry has said the show was inspired while he was watching coverage of the trial of Andrea Yates, the woman from Texas who drowned her five children in a bathtub.

Unfortunately, the brilliant first season is all some people remember. Though 28 million viewers returned for Season 2, creative unevenness and unfortunate new plot — involving a new housewife (Alfre Woodard as Betty Applewhite) who locked her mentally handicapped son in a basement when she thought he had killed someone — contributed to a loss of viewers.

Ratings eroded over time as Lynette’s husband discovered he had a love child; a scorned wife held a supermarket hostage; a plane crashed into Wisteria Lane; Susan married sexy plumber Mike Delfino (James Denton), divorced him, then married him again; neighborhood seductress Edie Britt (Nicollette Sheridan) tricked an amnesiac Mike into thinking he was in love with her; an elderly neighbor hid her dead husband in a freezer so she could collect his pension checks; Gabrielle found out her daughter was switched at birth; Bree watched her new husband die after she discovered he had poisoned her old husband. That’s nothing compared with a tornado, an angry-mob scene, houses burning down, drug addictions, divorces and many, many affairs.

Interestingly, one element never changed through all the drama: the voiceover, provided by Brenda Strong. Ever since Mary Alice’s death, she has narrated the show, “watching” her friends from the afterlife, setting up each episode with a theme and wrapping it all up at the end. Her calm, slightly eerie narration has tied all the seasons together.

Reached by phone, Strong said that the character of Mary Alice is an especially important one, even though she has been off-screen for the majority of the show. Not only was the character’s death the hub the show revolved around, she was emotional bridge for the audience to say, “This isn’t just Wisteria Lane — this is your life, too.”

Through everything, the viewers still hanging on (last week’s episode had just over 9 million) saw characters evolve, recognizing and ultimately accepting their weaknesses while overcoming what they could. Going into the final episode, Bree is on trial for killing Gabrielle’s stepfather (long story), and Gabrielle grapples with whether to risk her family’s well-being if she spills how he really died. Susan’s still working through the sudden murder of Mike, while Lynette is trying to win back the love of her life, Tom (Doug Savant), after a season-long trial separation. Oh, and Renee (Vanessa Williams, the newest housewife added to spice things up) is getting married to a shady businessman.

Still, for all its wackiness, Wisteria Lane has always been a reassuring place to visit for an hour — to reaffirm that even if things seem beautiful on the surface, everyone is fighting a battle. And that sharing those struggles, not bottling them up, can mean all the difference between changing (or saving) a life.

Strong says that keeping the voice of Mary Alice a part of the series helped to anchor the show and remind viewers of its universal elements .

“It goes from the specific: ‘This is what’s happening on Wisteria Lane,’ ” Strong said. “But then it also says: ‘This is what’s happening because we’re human.’ ”

Desperate Housewives

(one hour) final episode airs Sunday at 9 p.m. on ABC.