The starting point at constant $T, p$ is the Gibb's energy in any phase $\Pi$ with components $j$.
$$ dG^\Pi = \sum_j \mu_j^\Pi\ dz_j^\Pi $$
At phase equilibrium, the total Gibb's energy change is zero.
$$ dG = 0 = \sum_\Pi \sum_j \mu_j^\Pi\ dz_j^\Pi $$
In any given phase, we have the mass balance equation.
$$ \sum_j dz_j^\Pi = 0$$
We have as many of these as we have phases.
The remaining analysis is an exercise in applying the proper mathematics to combine the phase equilibrium equation with the $\Pi$ mass balance equations.