To determination of gain formula assume both inputs are equal. Since the positive input is connected to ground the negative input must be at 0 V. The current through R1 is i=V1/R1. Since no current goes into the input the current in Rf is the same and is i= -Vo/Rf. Thus
vo/vi = -Rf/R1
A different and more rigorous determination of gain formula.