For free range eggs, over 50 birds and you become subject to the regulations. I don't know what they are, but should be easy to find or someone will come up with them. You would certainly need more than 50 birds to make a profit, and you would have to go down the route of providing artificial light to keep them laying year-round.
I don't know if the 50+ rule is the same for quail, but although their eggs are tiny they do seem to sell well to the restaurant and delicatessen market.
When you say 'has to be viable', do you mean you want to make a good profit, or that the venture has to at minimum support itself?
Apart from major, one-off outlays, our venture now supports itself, but certainly is not providing any income. We keep laying hens and a breeding flock of Hebrideans. It seems to make little difference how many sheep we keep, the outlays always seem to match the income, but we do make our own hay so only pay for coarse mix for the winter, plus meds etc.