I can't remember but I seem to recall that it was based loosely on a true story? In any case City of God is one of those films that seem to capture the essence of the world it inhabits, in this case the slums of Rio. Man life must be crazy in those places.
Yes, it is based on a true story told by the photographer character in the movie who became a photographer in real life. I have been to Rio and one of the things I told everyone after I came home was how the beach area (which you always see on postcards and in movies) is beautiful, but the streets behind the hotels are slums. Apparently, it isn't quite as dangerous now as it was in the 1960s through 1980s (the time period when the film takes place). But you still wouldn't want to wander away from the hotel zone at night. The guy at the front desk of our hotel told us if we went to the beach we should stay where there were large groups of people. Apparently, if you go to the less populated areas of the beach criminals will rush you, grab all your valuables, and run away into the streets.