The maintenance of urban societies requires immigration from rural communities; cities never replace their own population
Brunetto Latini defines a city to be a congregation of people under one law; he was a prose writer from Florence who may have been Dante's teacher. Now there are two definition of a city: where the bishop resides, and a people under one law. He wrote an encyclopedia of classical learning in French (not latin) to preserve that knowledge for people in cities
For a market, which is at the heart of any city, is to function, then there must be relative equality between participants. To require merchants to research whether a given customer is of legal age, is a serf, etc. would complicate the transactions too much, so approximate equality is presumed
The 11th century was the first time broad political and social movements arose in the name of liberty. Two sides: ecclesiastical, people concerned about the freedom of the church and insisting the church be free from secular authorities, and the side of self-government of the people. This is unique to the European urban experience; cities in the Muslim world did not strive for self-rule.
A movement for self-government arose in Italy first. There was an emperor, but he did not impress his will on his subjects with any real frequency, and some communities in England had never even heard that a king exists; monarchy was not always nearly so pervasive as one would assume from a modern perspective.
Barbarossa in 11th ce leads an Italian movement in favor of both self-government and ecclesiastical freedom for a year, is defeated, his descendant try again well into the 13th century, they all fail.
Urban life really began in a big way in Italy in the middle ages, and great pasts do tend to create great futures; Italy has preserved a very high literacy rate. The prominence of bishops is also relevant; the bishops provide occasions for lay people to become their agents (medieval clergy cannot attend tribunes/court, or bear arms, so they need /goyim/ to do it for them) which often requires literacy and general knowledge.
The first steps towards self-rule is taken by these people, perhaps with assistance from rural feudal lords.
In Italy municipal governments are still called communes, because in early urban environments people agreed to pool their rights against all comers (communal rights), and they swore an oath to this commune. This is surprisingly revolutionary, but this again represents a convergence between what cities were doing and what the church is doing. The aristocracy let this city oath continue probably for the same reason that thye let church authorities swear oaths that weren't directly to them.
Between the 11th and sometime in the 13th century, city government is relatively open to people generally participating, the pooling of rights defends the community as a whole, it is not particularly oligarchic. It usually employs consular government, with Rome as the archetype.
Every member of the city has a right and an obligation to participate in public affairs. They form a parliament, or a general assembly, with the consuls as executives. This is true for Italian cities in the early development of the communal structure, In the 11th century. There is always the possibility that the consuls will take power and keep it, so term limits are very strict. Often term limits will be as short as 2 or 3 months.
In Bologna (university), a class of people developing, interpreting, and carrying out laws slowly begins to develop: lawyers and bureaucrats.
In 1262 the commune of Sienna publishes what it calls a constitutum, which is a collection of the laws of the commune, is about 800 pages in modern small print. The bishop is the interpreter of their laws, there is a long list of donations of bricks that the commune makes to various institutions within the city, various rules for all the different types of courts, general provisions, etc.
Podesta, which means power, is a single executive who after time replaces consuls: podesta ---> council ---> parliament. The podesta caanot be a citizen. He is hired for a year, he is always an outsider. After a year, a council examines his performance, and if he was good then he is hired for another year. Usually he is a knight, so that he can lead militia, and a graduate of Bologna, so that he is an expert. He has his own body of thugs/policemen who can assist him in the execution particularly of the capital power. The execution of the harsher laws, like capital punishment, can be done by an outsider podesta much better than they could be by someone who grew up in the city; otherwise there would be repercussions to the social health of the city, and probably a bias on the part of the podesta.