Want to understand global socioeconomic trends and your role within them? Just look to the history of how we buy groceries.

Ancient food markets played a significant role in the development of local economies and also contributed to the social fabric of communities. In addition to being places of trade, markets were also meeting points. Vendors knew their regular clients’ names and buying habits, and shoppers encountered their friends, neighbors, and acquaintances on a daily basis. There was a familiarity and loyalty between vendors and shoppers, which promoted an ethic of quality products and honest exchange.

Sounds more idyllic than waiting idly in line for 20 minutes at Whole Foods, right?

In Public Markets and Civic Culture, historian Helen Tangires writes, “The public market is a key piece in understanding the profoundly important shift from agrarian to industrial food systems in 19th-century America.” More than a place to buy and sell food, public markets were civic spaces, the common ground “where citizens and governments defined the shared values of the community.”

What has come of them now? And what do today’s markets mean for our local economies, the way we interact with our neighbors, and our culinary consumption overall? To trace the evolution of markets, you need to start with the development of agriculture and trade.

The agricultural trade era

Most societies were once made up of hunters and gatherers and survived on what nature could provide. This pattern transformed with the development of agriculture. Bands still relied on hunting and gathering skills, but when animals were domesticated, seeds planted and crops harvested, there was sufficient food for the farmer’s household, and leftovers for trade.

Along with the evolution of commerce and the invention of currencies, the physical forms of markets varied and progressed. In later centuries, as communities grew further in size, commerce became more important and formalized in location and process. Weekly days were chosen for buying and selling livestock and other commodities, an activity named “market”—mercatus in Latin, which means the activity of trading, dealing or buying, as well as the marketplace where these activities occur. Along with the evolution of commerce and the invention of currencies, the physical forms of markets varied and progressed.

When trading evolved and the institution of middleman flourished, commerce and the place of business changed as well. Growers no longer needed to travel to markets, but traded with merchants who then sold to the public. The vendors needed stalls for storage and display and, of course, they needed a flow of customers.

Permanent public markets and the shift to wholesale

With the expansion of cities came the realization that markets were valuable sources of tax revenue. Formal covered structures replaced ramshackle stalls as municipal governments saw the advantages of being able to better maintain hygiene.

Market architects aimed to create safe and attractive buildings that would draw bourgeois consumers. Whereas earlier markets had been rough-and-ready places from which the upper classes, particularly women, stayed away, public markets now offered an appealing environment, with tiled floors and walls, lots of space to move around, and attractive well-lit vending counters.

Food growing and trade evolved in the aftermath of the Industrial Revolution. Mechanization enabled large-scale production with fewer helping hands. Agricultural produce could be brought to market rapidly by railway. Greater variety from afar and larger quantities were sold at lower prices. With rapid urbanization and the emergence of the sprawling metropolis, larger quantities of food had to reach cities. Daily direct supply by growers to large and small markets with many stalls was cumbersome.

This led to the development of wholesale terminal markets—a single structure or series of buildings designed for storage and distribution of produce, like the Bronx Terminal Market in New York City. They were linked to railways, highways, and waterways. Food was stored there, often refrigerated, before it got distributed regionally. It became common for vendors in small markets and shops to buy directly from wholesalers whom they visited daily. The gap between the growers and consumers expanded.

The supermarket

Enter the supermarket. Suitably named by Hollywood during the 1930s, two types of supermarkets emerged. The first emphasized style. The other specialized in lower prices and larger volume, the forerunner of today’s Costco. They were initiated by independent merchants who wanted to challenge the dominance of food retailers who sold to grocery stores.

Supermarkets dealt public markets a major blow and affected food consumption and buying habits. Fresh produce and environments that promoted a close-knit social fabric were traded for convenience and formal, less-engaging human relationships. On weekends, busy householders drove to a food store to stock up for the week. Eventually, some supermarkets began to disguise themselves as markets by changing the way produce was displayed or even dressing employees in period clothing. They began to prepare cooked food on site. There were mini fish and meat markets, and bakeries fragrant with the smell of fresh bread, all under one roof, along with aisles full of canned food and other household goods.

Agricultural production changed as family-run farms were replaced by large industrial operations that supplied food processors and wholesalers. Direct exchange between farmers or vendors and citizens in markets, which for centuries contributed to making places livable, all but disappeared.

Fresh produce and environments that promoted a close-knit social fabric were traded for convenience and formal, less-engaging human relationships. Food consumption habits changed. Households gradually shifted to ready-to-serve convenience food. According to a 2004 Newsweek article, in the US only a third of all dinner entrees were entirely homemade; fully 47% of all suppers eaten at home did not involve turning on the stove at all, and the area in supermarkets dedicated to selling prepared dinners has increased by 168% since 1993. When asked in 2010, Canadian consumers indicated that convenience is more important than price when it comes to food purchasing. Indeed, few peel tomatoes to make Nonna’s lasagne, and even that American icon, the burger, is sold frozen in a bun with condiments.

Once-a-week shopping for convenient, ready-to-serve food has led to expanded cupboard space and larger refrigerators, and many households have added a separate freezer in the basement for long-term storage. Meanwhile, the actual kitchens where food is prepared have in many cases moved to efficient plants somewhere in the industrial part of town.

The resurgence of farmers markets

Yet, it seems that the natural instincts of the buying public have served it well when it comes to saving vital commercial and social institutions such as old-style markets from complete extinction. The quest for freshness, lower prices, and direct exchange with the grower has led to a resurgence of farmers markets situated at fixed locations where products are sold by the farmers themselves. The number of farmers markets in Canada has grown substantially in recent years. In Ontario alone, the number of farmers markets has tripled since 1980. In 2008, there were 508 recognized markets across Canada, a number that is predicted to rise 5-7% each year.

The quest for freshness, lower prices, and direct exchange with the grower has led to a resurgence of farmers markets. Studies show that growers are inclined to sell in farmers markets because they often see them as the best, or the most profitable, venue for selling their produce. Consumers visit them because they provide high-quality produce at a reasonable price. In a survey of reasons for shopping in farmers markets, 63% of the responders answered that freshness was their prime reason, 54% indicated price savings, and the social atmosphere drew 12%. Patrons come primarily from neighborhoods adjacent to the market; once again, markets have begun to play an important social role by creating a local public meeting point. Their contribution to local economies is of high value, as they lead to spending in nearby shops, which generates further tax revenue.

Farmers markets create jobs, build new businesses, strengthen and diversify regional agriculture, and elevate farm profitability. Granville Island Public Market in Vancouver created 3.2 full-time and 4.3 part-time jobs per vendor, for example. Some markets, such as Kensington Market in Toronto, have become tourist attractions. In certain cities, farmers markets have been the catalyst for downtown urban renewal, with free bus shuttles on market days, and the turning of some streets into pedestrian malls where local artisans display their work as well.

The increased popularity of farmers markets contributes to the sustainability of communities. Local growers are supported. Food does not travel from afar and emission levels are reduced. Produce that is to be sold directly by the grower does not have to be chemically treated to increase its shelf life, which improves overall public health.

* * *

Urban environments are made up of land uses whose primary function is to support basic human needs. We build homes to shelter people, and build factories to work in. There are, however, public places that play a dual role. They not only provide basic amenities and contribute to economic vitality, but act as social magnets and draw people to them. Markets are such places. They are scenes of trade, as well as places for communal interaction and gathering spots where one can watch or engage in the theater of life.

Buying habits and places where we shop for food are evolving. Nostalgic tendencies coupled with a desire to consume fresh and organic produce led to the resurgence of farmers market in many cities. Public markets are also transforming to combine food vending and dining in the same location. There is a sharp rise in the number of community gardens and backyard farming where citizens can cultivate and exchange produce with one another. Urban agriculture has been used to revitalize rundown urban areas by reclaiming vacant lots. These are all welcome initiatives that attest to the vitality and longevity of this rudimentary social pillar. We should patronize them and keep them vibrant no matter what shape they take.

This was adapted from an excerpt in Avi Friedman’s latest book, A Place in Mind: Designing Cities for the 21st Century (Véhicule Press, Montreal, 2016). Learn how to write for Quartz Ideas. We welcome your comments at ideas@qz.com.