$\newcommand{\rank}{\operatorname{rank}}$ Can you please check if the following proof is correct?
Let $\phi: G \mapsto H$ be an isomorphism. If $\{g_i\}$ is a generating set of $G$ then $\{\phi(g_i)\}$ is a generating set of $H$. Therefore $\rank(G) = \rank(H)$. Conversely if $\rank(G) = \rank(H)$, then the map $\psi: G\mapsto H$ defined between the respective generators by $\psi(g_i) = h_i$ is an isomorphism.
This proof seems incorrect. Forgive me I'm just a beginner.
Just because two groups have the same rank, that doesn't mean that the corresponding generators have the same order. Specifically, any cyclic group has rank $1$, but they aren't all isomorphic.
Note that this isn't the only thing that can go wrong either. You can have $|G| = |H|$ and $\operatorname{rank}(G) = \operatorname{rank}(H) = n$ with $G = \langle g_1, g_2, \ldots, g_n\rangle$ and $H = \langle h_1, h_2, \ldots, h_n\rangle$ with the order of $g_i$ equal to the order of $h_i$ for all $i$, and still have $G$ and $H$ non-isomorphic. For instance, take the two groups $$ \Bbb Z_4\times \Bbb Z_2 \text{ versus } D_4 $$ (where $D_4$ is the dihedral group acting on $4$ elements; the symmetry group of a square). They both have $8$ elements, they both have rank $2$, and they both have a generating set with one order-$4$ element and one order-$2$ element. Yet one is abelian and the other isn't, so they aren't isomorphic.