I get anxious when working on back-end code. Data loss, security breaches and scalability/performance issues seem to be lurking around every corner if I don't pay attention. Sure, I can come up with a solution to most problems thrown my way, but with every design choice there's always the thought that maybe I didn't think it through and I forgot about a critical part of the system and it will have serious ramifications in the future.
This feeling is not only at my day job where I work on a fairly complex Rails app, but also in my hobby of game design and development — sketching out ideas and hacking together a prototype is one thing, but building it so that the code is maintainable, scalable, secure and easily understood from the start feels like black magic.
Of course, architecture and design patterns are not only a back-end thing. I've learned to write more or less maintainable code over the years and always seek ways to make it more flexible and concise, but the end result is just cosmetics anyway and the real magic happens elsewhere, so it doesn't feel as important.
Aside from just reading and understanding the source code I'm working on and familiarizing myself with source code of other, open-source applications, what are other good ways to learn the "correct mindset" of building systems? I'm most interested in how to think about the system as a whole and how to divide it into parts that make the most sense, given the overall problem the system is trying to solve; How to think about data flow, single responsibility, patterns that can be applied etc. How and where should I even begin?