I would split it up into multiple parts. Make the code be generated into multiple separate files (you likely can combine them back later if that is important to you). Focus on getting each part correct. separate out the different parts... HTTP server part, request decoding, cache file storage/ range checking, HTTP request. I suspect concurrency is going to be a big issue so tell the AI to make sure it takes that into account.