Pyrotechnic mixtures almost always function according to the principle of a REDOX reaction. Simply put, one substance releases oxygen, i.e. is reduced, while another substance takes up oxygen, i.e. is oxidised. However, since a pyrotechnic mixture rarely consists of only two components, the reactions that take place in it are quite complicated.
Take normal black powder as an example, a mixture of 75% potassium nitrate, 15% sulphur and 10% charcoal powder. Potassium nitrate (chemical formula: KN03) is a compound of potassium (K), nitrogen (N) and oxygen (O). As can be seen from the 3 behind the "O", it "consists" of 3/5 oxygen and also releases this very easily to oxidisable substances such as sulphur, charcoal, etc. when starting energy in the form of heat or friction is added to the finished mixture.
On this basis, most mixtures can be made: oxygen-releasing substance + easily combustible (oxidisable) substance. However, one must pay attention to the so-called "chemical" equilibrium, i.e. there must not be more oxygen-releasing substance in a mixture than is necessary for the combustion of the combustible substance, as such an excess would hinder the reaction. The correct ratio can be calculated using the reaction equation, but first you have to come up with a complete reaction equation before you can then do your calculations using the molecular weight (molar mass). But a perfect equilibrium does not mean that a mixture will work well - sometimes you have to do many experiments before you succeed.