Mixing is done first, and mastering is done afterwards. Mixing involves balancing out different elements of a song. This can include EQ, Compression, effects like reverb / delay, and any other processing. Mixing often involves making changes to the individual tracks inside of a song, like the drums, vocals, etc..
Once a song is mixed that track then needs to be mastered. Our mastering engine takes your mixed song and polishes it, making it ready for commercial release. The mastering process handles the entire song as a whole.
In summary, mixing occurs first and focuses on individual elements and making them sound balanced together. Once mixing is done the song can be mastered, and in the mastering process the file itself is processed as a whole rather than in individual parts.