From Data to Dreams: Demystifying the Workings of Generative AI