Complex sentence: Beyond the prison are residential quarters of the wali, which is the main residential area, and which consists of a succession of rooms built around a terrace in the topmost part the fort.
Split into simpler sentences: Beyond the prison are residential quarters of the wali. It is the main residential area consisting of a succession of rooms built around a terrace in the topmost part the fort.