To determination of gain formula assume vo=A(v2-v1). Where the positive input is v2 and the negative input is v1.
Since v2=0, v1 = -vo/A
The current through R1 is i1=(Vi-V1)/R1.
Since no current goes into the input the current in Rf is the same and is if= (V1-Vo)/Rf. Thus
(Vi-V1)/R1=(V1-Vo)/Rf
this gives
vo/vi = -Rf/R1/(1+(1+Rf/R1)/A)
This is true for any gain and gain that changes with frequency. If the gain A is very large, we get the standard formula.
vo/vi = -Rf/R1