(CNN) — The al-Qarawiyyin Library has long been a source of fascination for residents in Fez, Morocco, as few of them have ever passed through its doors. Opened in 859, it is thought to be the world's oldest library, and the maze of rooms were closed off to all but a few scholars and students of the university where it was housed.
"We knew where it was more or less, but could not enter. It was this big, mysterious place," recalls Aziza Chaouni, a Fez native and the architect who has overseen al-Qarawiyyin's restoration. "I had no idea what lay behind its gigantic iron doors."
In 2012, a woman from Morocco's Ministry of Culture contacted Chaouni for an assessment. When the Toronto-based architect and engineer stepped inside the building, however, she was shocked to discover it was rotting.
"It was exquisite, but it was in a very bad state," she recalls. Over the centuries, rain water poured off the roof of the neighboring mosque and infiltrated the library. After excavating, Chaouni discovered what she described as a river running underneath the floors. To rescue the structure from further damage, she built an underground canal system to lead the water into the sewer.
"When you have books and water, it's a horrible recipe," she says.
Though the structural changes were, she admits, a major undertaking, they pale in comparison to the work she's done to bring the 9th century complex into the 21st century. Making it modern, and making it open to the public -- and not just to researchers -- are the cornerstone of Chaouni's vision for al-Qarawiyyin.
Chaouni added a new lab to treat, preserve and digitize some of the oldest texts, which include a ninth-century Quran, written in Kufic (the oldest form of Arabic calligraphy) on camel skin. State-of-the-art machinery can mend holes in ancient paper rolls, and prevent cracks in ancient scrolls.
"Hopefully, by digitizing, we can make some of these manuscripts available online, and spread the knowledge way beyond Fez and Morocco," she says. Though the library isn't yet open to the public, it is expected to be in 2017.
In a way, the library's interior had an added allure for Chaouni, who grew up hearing family stories about her great grandfather, who to Fez from his village on a donkey to study at the illustrious university, and who spent many hours studying in the reading room at al-Qarawiyyin Library. What she hadn't anticipated was the many secret nooks that lay behind boarded up walls and doors.
"We were always discovering things as we were ripping out walls," she says. One standout discovery for her was a hidden room that had a 12th century cupola made with intricate lattice wood.
"It was this extremely refined and unusual type of roof that was hidden away," she recalls. "It's typical of the element of surprise you fine in Fez. You'll have these narrow streets and find a small door that enters into an amazing courtyard."
Chaouni is the latest is a line of women that have shaped the library's history. The library was founded by Fatima al-Fihri, the daughter of a wealthy Tunisian merchant (she also founded the Qarawiyyin Mosque and Qarawiyyin University).
Chaouni also believes that her own role in restoring the library was made possible by the fact it was a woman at the Ministry of Culture that reached out to her.
"I was lucky that it was a lady from the Ministry who heard of me. If it was a man, he probably would have hired another man, one of his friends."
She is quick to point out that though her gender presented challenges, they weren't unique to Morocco.
"As a woman in Toronto, I still have to work twice as hard in a technical field to make myself heard. Sure, this gender-thing exists in Morocco, but it's still changed immensely from when I was a young girl and the time of my mother."
In the end, though, it was worth it to Chaouni to bring the library back to its former glory, and to make it accessible to the public for the first time.
"It's probably the thing I'm most proud of," she says. "The heritage needs to live. It can't be thought of as this mummy we need to preserve."