This mosaic-adorned rooftop cafe in a dilapidated building behind the Zitouna Mosque can be hard to find, but its view over the mosque courtyard is the best in the medina. It's extremely popular with local students. Enter through the blue doors into a seemingly empty space and then climb the rickety stairs to find it.
If asking for directions, it may be worth mentioning La Maison d'Orient carpet shop, which is on the 1st floor.