On knowing how to structure low level code, I highly recommend reading Casey Muratori's blog post on Semantic Compression: https://caseymuratori.com/blog_0015
And, more generally, watching some of his (free) handmade hero video series: https://handmadehero.org/