A city built on a spot that not many generations ago was the watering place of cattle for the Masai and Kikuyu tribes, Nairobi to a casual visitor today is a city of wide avenues, landscaped gardens and estates hidden by hedges.

A deeper look, however, discloses a sprawling range of crudely built wood shanties and muddy, congested roads in the Mathare Valley section on Nairobi's outskirts.

Poor and primitive, Mathare is a city unto itself - the first stopping place for an estimated 40,000 residents who come to the capital yearly from rural Kenya.

One visitor to the "other side of Nairobi" yesterday was District of Columbia Mayor Marion Barry, who found it "like nothing I've ever seen in my life."

Mathare's low, tin-roofed, rough wood dwellings have no running water, electricity, sewage or garbage collections.

"Sure, there are similarties to Shaw or some parts of Mississippi," said Barry, who during his mayoral campaign last year, and again since taking office, has made housing a major issue.

"The mudholes, the trash and the kids looking so sad make you want to cry," Barry said yesterday.

Every morning, one local official said, Mathare empties out as thousands of its residents go to their unskilled, menial jobs in the city.

"I don't know what we'd do if 40,000 people a year came to Washington without skills and training," Barry said.

Barry's concern about housing problems was one of the subjects of a half-hour meeting yesterday with Kenyan President Daniel Arap Moi.

Standing afterward in a rose garden outside the statehouse, Moi said he and Barry talked about strengthening the relations between Nairobi and Washington.

"What we need is housing," Moi said. "Workers here need to have shelter. That is the basic human rights that people advocate."

Barry said that Moi talked a great deal about the Wamachi, Swahili for "little people," and of "taking services to the people."

Among the programs cited by Moi was free milk distribution fro primary schools.

From the depressing conditions in Mathare, Barry went to a City Council-sponsored project called Umoja, built with financial help from the U.S. Agency for International Development to help relieve overcrowding in Nairobi. Analysts for the agency have declared Umoja the most successful of its projects in the world.

The masonry shells, built on plots that allow room to expand, are neither painted nor plastered. The finishing touches are left to the owner, who can buy the unit for $4,000 and pay for it over 25 years. Using this method, the city has been able to construct 3,200 units.

He said he found it similar to projects by Pride Inc., in Washington and others nationally to give unskilled youngsters elementary training and produce items that sell for profit to sustain the project.

Women bowed their heads over Single treadle sewing machines, stitching play clothes on a terrace of the center's courtyard. Potters turned lumps of brown moist clay into symmetrical bowls. The work progressed to the rhymthic clack to huge looms spinning rough yarn into rugs.

Barry said Mathare, and his other stops in and around the Kenyan capital, "have given me a lot of ideas for when I return to Washington." He said he is not ready to discuss them yet, but has a reinforced resolve to push for more U.S. aid to Africa and to seek congressional authority for AID funds for urban as well as rural projects.

Despite the brevity of his call on Moi, they mayor said "the main thing is that it is very unlikely that if (an African mayor) came to Washington, they would even get close to meeting with the president. Yet, it's four out of four."

Barry has met with heads of state in Senegal, Liberia and Kenya. He is scheduled for a "working breakfast" with Zambian President Kenneth Kaunda in Lusaka on Wednesday.