Mastering Generative AI from Scratch