Question: how viharas came into existence?
Answer: The viharas in India were originally constructed to shelter the monks during the rainy season, when it became difficult for them to lead the wanderer's life. ... A clear idea of their plan can be obtained from examples in western India, where the viharas were often excavated into the rock cliffs.