LOS ANGELES -- When Fred Harvey stepped off the train in Topeka, Kan., darned if he could find a spot nearby with a decent cup of coffee.

He walked into one restaurant and took a gulp of some muddy coffee. And that gulp, back in 1876, eventually changed the way many American travelers dine.

Harvey built a coffee shop at the Topeka train depot -- and went on to develop a chain of 44 clean and efficient restaurants in other locations. Long before the automobile, the railroad was the catalyst to the all-American eatery -- the coffee shop as a chain in America.

More than a century later, restaurant industry observers refer to coffee shops as the "meat and potatoes" of the business. Now coffee shops are feeling competitive heat like never before.

Although sales at the nation's estimated 85,000 coffee shops exceeded $28 billion last year, the fast food spots like McDonald's and Burger King now post higher annual sales than coffee shops. While some chains such as Denny's -- which Marriott Corp. is planning to buy -- have strived to change with the times by upgrading their images, others, like Sambo's, ignored the fast food competitors and disappeared.

"But coffee shops are still the bread and butter of the industry. People just like to go to them," said Peter Berlinski, editor of Restaurant Business, a trade magazine based in New York.

What makes coffee shops special? Many of those who built the chains assumed it was things like cleanliness, quality food and relatively fast service. But at least one well-known psychologist has her own ideas about what puts the perk into coffee shops.

"People go to coffee shops for the ambiance," said Dr. Joyce Brothers, the author and radio talk show host.

By the turn of the century, however, automats began to replace coffee shops in big cities like New York and Philadelphia. But after a short-lived fascination, the public didn't much care for the newfangled restaurants without waitresses. A few years later, customers showed great interest in the soda fountains that began to open in Chicago-area drugstores. And by 1920, luncheonettes -- with long counters and bright lights -- became the craze.

It was Howard Johnson, however, who in 1929 placed a full-service restaurant by a highly traveled road.

After that, it didn't take long for the coffee shop craze to explode in California. The 1,000-plus unit Big Boy chain, for example, began in 1936 when Robert C. "Bob" Wian, sold his car for $300 to buy a 10-seat diner in his home town of Glendale.

The nation's largest and perhaps best-known coffee shop chain, Denny's, got its start as a doughnut shop in Lakewood, Calif. But when founder, Harold Butler, thought the name was getting confused with a competing outfit, Coffee Dan's, he simply changed one letter and converted "Danny's" into "Denny's."

Growth came quickly for Denny's. "After we opened our fifth restaurant," said Butler, who sold his interest in Denny's in 1971, "I looked at all the traveling going on in California and said to myself, 'My God, this is the future.' "

Indeed, it was. Coffee shops peaked in the mid-1970s. It was then that the fast food restaurants began to cut into their business.

Now, some industry consultants see big headaches ahead for the coffee shop industry.

The double whammy of clever marketing by the fast food restaurants, along with the recent popularity of upscale diners with yuppie-oriented blue plate specials, has whittled away at the coffee shops market share.

Some say that coffee shops are trying too hard to appeal to everyone. Said Barbara Dawson, West Coast editor of the trade magazine Restaurants & Institutions, "Denny's can put in a bar and serve a five-course meal, but as far as I'm concerned, they can't afford to forget that above all else they're still a coffee shop."