Actually it may not be too close at all. The people in the city have to eat. It all depends on who lives in the city. If the city is military and merchants, there may well be another settlement for the farmers in the area. The farmers would retreat to the walled city if there were a threat. The only reason to have the farmers living in the city itself is if the area is under constant threat, requiring them to sleep within the fortifications and travel to the fields by day.
The south gate of the city looks fine. There would probably be a market close to the gate so that the farmers don't need to travel far in to the city to sell their wares.