Unraveling the Mechanics: Exploring the Working of Generative AI