Kinda reminds me of Kharbranth from the Stormlight Archive. It makes it's money by selling access to the biggest library in the world and then funnels that money into free hospitals. This also means that every doctor worth their salt pays to study in the city.