I'm not going to go into all the details about patterns in spanish spelling, only the parts you need to know in order to conjugate verbs and decline other words.
to make the /k/ sound, you need either "c" or "qu" (or sometimes "k", but that's only in some borrowed words and not relevant to this). If it's before an e or an i, you need "qu", otherwise "c". This comes up in verb conjugation in for example the word "buscar". In the preterite, it's "busqué". It's pronounced like "buskar" and "buské", a /k/ sound in both cases, but you can't spell "buské" with a "c" because c before e or i goes /s/, so that one has to be a "qu", busqué; and you can't have "qu" anywhere *except* before an e or an i because spanish says so (totally arbitrarily, french for example doesn't follow the rule), so it has to be a "c", buscar.
to make the /g/ sound before an e or an i, you have to insert a "u", because in "ge" or "gi" the "g" is pronounced like a j. So instead you write "gue" or "gui" and the u is silent. This comes up in "pagar". The preterite is "pagué". <- silent "u".
If a g is before an e or an i, and then the conjugation makes the g be followed by something else (o, a), then you have to change the g to a j to maintain the pronunciation. eg proteger. the yo form of the present indicative is protejo.
Spanish says a z can't come before an e or an i (except in some borrowed words) so sometimes a z has to change to a c. For example, the plural of luz is luces.
Sidenote, if you want to write /gwe/ or /gwi/, you can by putting umlauts on the u, güe, güi. Words with the ü are very rare.
I think that's all.